• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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::PERIODIC_INTERVAL:
16       return "periodic_interval";
17     case MemoryDumpType::EXPLICITLY_TRIGGERED:
18       return "explicitly_triggered";
19     case MemoryDumpType::SUMMARY_ONLY:
20       return "summary_only";
21   }
22   NOTREACHED();
23   return "unknown";
24 }
25 
StringToMemoryDumpType(const std::string & str)26 MemoryDumpType StringToMemoryDumpType(const std::string& str) {
27   if (str == "periodic_interval")
28     return MemoryDumpType::PERIODIC_INTERVAL;
29   if (str == "explicitly_triggered")
30     return MemoryDumpType::EXPLICITLY_TRIGGERED;
31   if (str == "summary_only")
32     return MemoryDumpType::SUMMARY_ONLY;
33   NOTREACHED();
34   return MemoryDumpType::LAST;
35 }
36 
MemoryDumpLevelOfDetailToString(const MemoryDumpLevelOfDetail & level_of_detail)37 const char* MemoryDumpLevelOfDetailToString(
38     const MemoryDumpLevelOfDetail& level_of_detail) {
39   switch (level_of_detail) {
40     case MemoryDumpLevelOfDetail::BACKGROUND:
41       return "background";
42     case MemoryDumpLevelOfDetail::LIGHT:
43       return "light";
44     case MemoryDumpLevelOfDetail::DETAILED:
45       return "detailed";
46   }
47   NOTREACHED();
48   return "unknown";
49 }
50 
StringToMemoryDumpLevelOfDetail(const std::string & str)51 MemoryDumpLevelOfDetail StringToMemoryDumpLevelOfDetail(
52     const std::string& str) {
53   if (str == "background")
54     return MemoryDumpLevelOfDetail::BACKGROUND;
55   if (str == "light")
56     return MemoryDumpLevelOfDetail::LIGHT;
57   if (str == "detailed")
58     return MemoryDumpLevelOfDetail::DETAILED;
59   NOTREACHED();
60   return MemoryDumpLevelOfDetail::LAST;
61 }
62 
63 }  // namespace trace_event
64 }  // namespace base
65