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)13const 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)28const char* MemoryDumpLevelOfDetailToString( 29 const MemoryDumpLevelOfDetail& level_of_detail) { 30 switch (level_of_detail) { 31 case MemoryDumpLevelOfDetail::BACKGROUND: 32 return "background"; 33 case MemoryDumpLevelOfDetail::LIGHT: 34 return "light"; 35 case MemoryDumpLevelOfDetail::DETAILED: 36 return "detailed"; 37 } 38 NOTREACHED(); 39 return "unknown"; 40 } 41 StringToMemoryDumpLevelOfDetail(const std::string & str)42MemoryDumpLevelOfDetail StringToMemoryDumpLevelOfDetail( 43 const std::string& str) { 44 if (str == "background") 45 return MemoryDumpLevelOfDetail::BACKGROUND; 46 if (str == "light") 47 return MemoryDumpLevelOfDetail::LIGHT; 48 if (str == "detailed") 49 return MemoryDumpLevelOfDetail::DETAILED; 50 NOTREACHED(); 51 return MemoryDumpLevelOfDetail::LAST; 52 } 53 54 } // namespace trace_event 55 } // namespace base 56