Chromium Code Reviews| Index: base/trace_event/trace_config.cc |
| diff --git a/base/trace_event/trace_config.cc b/base/trace_event/trace_config.cc |
| index 045c58ff10273979fa015e2e5bc5a139905d6204..462232bed0f450b4e5643a41ef0941f638418d55 100644 |
| --- a/base/trace_event/trace_config.cc |
| +++ b/base/trace_event/trace_config.cc |
| @@ -47,6 +47,7 @@ const char kSyntheticDelayCategoryFilterPrefix[] = "DELAY("; |
| // String parameters that is used to parse memory dump config in trace config |
| // string. |
| const char kMemoryDumpConfigParam[] = "memory_dump_config"; |
| +const char kAllowedDumpModesParam[] = "allowed_dump_modes"; |
| const char kTriggersParam[] = "triggers"; |
| const char kPeriodicIntervalParam[] = "periodic_interval_ms"; |
| const char kModeParam[] = "mode"; |
| @@ -75,6 +76,17 @@ class ConvertableTraceConfigToTraceFormat |
| const TraceConfig trace_config_; |
| }; |
| +std::set<MemoryDumpLevelOfDetail> GetDefaultAllowedMemoryDumpModes() { |
| + std::set<MemoryDumpLevelOfDetail> all_modes; |
| + for (auto mode = MemoryDumpLevelOfDetail::FIRST; |
| + mode <= MemoryDumpLevelOfDetail::LAST; |
| + mode = static_cast<MemoryDumpLevelOfDetail>(static_cast<uint32_t>(mode) + |
|
oystein (OOO til 10th of July)
2016/06/20 17:02:18
This seems a little awkward. Maybe just make 'mode
ssid
2016/06/20 19:12:06
This is awkward at only one place.
MemoryDumpLevel
ssid
2016/06/21 01:06:08
Sorry, I just understood what you said. I made mod
|
| + 1)) { |
| + all_modes.insert(mode); |
| + } |
| + return all_modes; |
| +} |
| + |
| } // namespace |
| @@ -99,6 +111,7 @@ TraceConfig::MemoryDumpConfig::MemoryDumpConfig( |
| TraceConfig::MemoryDumpConfig::~MemoryDumpConfig() {}; |
| void TraceConfig::MemoryDumpConfig::Clear() { |
| + allowed_dump_modes.clear(); |
| triggers.clear(); |
| heap_profiler_options.Clear(); |
| } |
| @@ -515,9 +528,23 @@ void TraceConfig::AddCategoryToDict(base::DictionaryValue& dict, |
| void TraceConfig::SetMemoryDumpConfigFromConfigDict( |
| const base::DictionaryValue& memory_dump_config) { |
| + // Set allowed dump modes. |
| + memory_dump_config_.allowed_dump_modes.clear(); |
| + const base::ListValue* allowed_modes_list; |
| + if (memory_dump_config.GetList(kAllowedDumpModesParam, &allowed_modes_list)) { |
| + for (size_t i = 0; i < allowed_modes_list->GetSize(); ++i) { |
| + std::string level_of_detail_str; |
| + allowed_modes_list->GetString(i, &level_of_detail_str); |
| + memory_dump_config_.allowed_dump_modes.insert( |
| + StringToMemoryDumpLevelOfDetail(level_of_detail_str)); |
| + } |
| + } else { |
| + // If allowed modes param is not given then allow all modes by default. |
| + memory_dump_config_.allowed_dump_modes = GetDefaultAllowedMemoryDumpModes(); |
| + } |
| + |
| // Set triggers |
| memory_dump_config_.triggers.clear(); |
| - |
| const base::ListValue* trigger_list = nullptr; |
| if (memory_dump_config.GetList(kTriggersParam, &trigger_list) && |
| trigger_list->GetSize() > 0) { |
| @@ -563,6 +590,7 @@ void TraceConfig::SetDefaultMemoryDumpConfig() { |
| memory_dump_config_.Clear(); |
| memory_dump_config_.triggers.push_back(kDefaultHeavyMemoryDumpTrigger); |
| memory_dump_config_.triggers.push_back(kDefaultLightMemoryDumpTrigger); |
| + memory_dump_config_.allowed_dump_modes = GetDefaultAllowedMemoryDumpModes(); |
| } |
| void TraceConfig::ToDict(base::DictionaryValue& dict) const { |
| @@ -609,6 +637,15 @@ void TraceConfig::ToDict(base::DictionaryValue& dict) const { |
| if (IsCategoryEnabled(MemoryDumpManager::kTraceCategory)) { |
| std::unique_ptr<base::DictionaryValue> memory_dump_config( |
| new base::DictionaryValue()); |
| + std::unique_ptr<base::ListValue> allowed_modes_list(new base::ListValue()); |
| + for (MemoryDumpLevelOfDetail dump_mode : |
| + memory_dump_config_.allowed_dump_modes) { |
| + allowed_modes_list->AppendString( |
| + MemoryDumpLevelOfDetailToString(dump_mode)); |
| + } |
| + memory_dump_config->Set(kAllowedDumpModesParam, |
| + std::move(allowed_modes_list)); |
| + |
| std::unique_ptr<base::ListValue> triggers_list(new base::ListValue()); |
| for (const MemoryDumpConfig::Trigger& config |
| : memory_dump_config_.triggers) { |