1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "base/trace_event/memory_dump_request_args.h"
6 
7 #include "base/logging.h"
8 
9 namespace base {
10 namespace trace_event {
11 
12 // static
MemoryDumpTypeToString(const MemoryDumpType & dump_type)13 const char* MemoryDumpTypeToString(const MemoryDumpType& dump_type) {
14   switch (dump_type) {
15     case MemoryDumpType::TASK_BEGIN:
16       return "task_begin";
17     case MemoryDumpType::TASK_END:
18       return "task_end";
19     case MemoryDumpType::PERIODIC_INTERVAL:
20       return "periodic_interval";
21     case MemoryDumpType::EXPLICITLY_TRIGGERED:
22       return "explicitly_triggered";
23   }
24   NOTREACHED();
25   return "unknown";
26 }
27 
MemoryDumpLevelOfDetailToString(const MemoryDumpLevelOfDetail & level_of_detail)28 const char* MemoryDumpLevelOfDetailToString(
29     const MemoryDumpLevelOfDetail& level_of_detail) {
30   switch (level_of_detail) {
31     case MemoryDumpLevelOfDetail::LIGHT:
32       return "light";
33     case MemoryDumpLevelOfDetail::DETAILED:
34       return "detailed";
35   }
36   NOTREACHED();
37   return "unknown";
38 }
39 
StringToMemoryDumpLevelOfDetail(const std::string & str)40 MemoryDumpLevelOfDetail StringToMemoryDumpLevelOfDetail(
41     const std::string& str) {
42   if (str == "light")
43     return MemoryDumpLevelOfDetail::LIGHT;
44   if (str == "detailed")
45     return MemoryDumpLevelOfDetail::DETAILED;
46   NOTREACHED();
47   return MemoryDumpLevelOfDetail::LAST;
48 }
49 
50 }  // namespace trace_event
51 }  // namespace base
52