Index: base/trace_event/trace_config.cc |
diff --git a/base/trace_event/trace_config.cc b/base/trace_event/trace_config.cc |
index e9e5a099893377e844be716845b0bbcfe90a2639..eb65d2e7efaa26f1e905e03a05ece04bfa25e317 100644 |
--- a/base/trace_event/trace_config.cc |
+++ b/base/trace_event/trace_config.cc |
@@ -50,6 +50,8 @@ const char kMemoryDumpConfigParam[] = "memory_dump_config"; |
const char kTriggersParam[] = "triggers"; |
const char kPeriodicIntervalParam[] = "periodic_interval_ms"; |
const char kModeParam[] = "mode"; |
+const char kHeapProfilerOptions[] = "heap_profiler_options"; |
+const char kBreakdownThresholdBytes[] = "breakdown_threshold_bytes"; |
// Default configuration of memory dumps. |
const TraceConfig::MemoryDumpTriggerConfig kDefaultHeavyMemoryDumpTrigger = { |
@@ -75,6 +77,29 @@ class ConvertableTraceConfigToTraceFormat |
} // namespace |
+ |
+TraceConfig::HeapProfilerOptions::HeapProfilerOptions() : |
+ breakdown_threshold_bytes(kDefaultBreakdownThresholdBytes) {}; |
+ |
+TraceConfig::HeapProfilerOptions::~HeapProfilerOptions() {}; |
+ |
+void TraceConfig::HeapProfilerOptions::Clear() { |
+ breakdown_threshold_bytes = kDefaultBreakdownThresholdBytes; |
+} |
+ |
+TraceConfig::MemoryDumpConfig::MemoryDumpConfig() {}; |
+ |
+TraceConfig::MemoryDumpConfig::MemoryDumpConfig( |
+ const MemoryDumpConfig& other) = default; |
+ |
+TraceConfig::MemoryDumpConfig::~MemoryDumpConfig() {}; |
+ |
+void TraceConfig::MemoryDumpConfig::Clear() { |
+ triggers.clear(); |
+ heap_profiler_options.Clear(); |
+} |
+ |
+ |
TraceConfig::TraceConfig() { |
InitializeDefault(); |
} |
@@ -257,9 +282,9 @@ void TraceConfig::Merge(const TraceConfig& config) { |
included_categories_.clear(); |
} |
- memory_dump_config_.insert(memory_dump_config_.end(), |
- config.memory_dump_config_.begin(), |
- config.memory_dump_config_.end()); |
+ memory_dump_config_.triggers.insert(memory_dump_config_.triggers.end(), |
+ config.memory_dump_config_.triggers.begin(), |
+ config.memory_dump_config_.triggers.end()); |
disabled_categories_.insert(disabled_categories_.end(), |
config.disabled_categories_.begin(), |
@@ -281,7 +306,7 @@ void TraceConfig::Clear() { |
disabled_categories_.clear(); |
excluded_categories_.clear(); |
synthetic_delays_.clear(); |
- memory_dump_config_.clear(); |
+ memory_dump_config_.Clear(); |
} |
void TraceConfig::InitializeDefault() { |
@@ -489,7 +514,12 @@ void TraceConfig::AddCategoryToDict(base::DictionaryValue& dict, |
void TraceConfig::SetMemoryDumpConfig( |
const base::DictionaryValue& memory_dump_config) { |
- memory_dump_config_.clear(); |
+ SetTriggers(memory_dump_config); |
+ SetHeapProfilerOptions(memory_dump_config); |
+} |
Primiano Tucci (use gerrit)
2016/04/22 14:18:29
I'd just do everything in this method, just to avo
Maria
2016/04/25 18:37:24
Done.
|
+ |
+void TraceConfig::SetTriggers(const base::DictionaryValue& memory_dump_config) { |
+ memory_dump_config_.triggers.clear(); |
const base::ListValue* trigger_list = nullptr; |
if (!memory_dump_config.GetList(kTriggersParam, &trigger_list) || |
@@ -514,14 +544,33 @@ void TraceConfig::SetMemoryDumpConfig( |
trigger->GetString(kModeParam, &level_of_detail_str); |
dump_config.level_of_detail = |
StringToMemoryDumpLevelOfDetail(level_of_detail_str); |
- memory_dump_config_.push_back(dump_config); |
+ memory_dump_config_.triggers.push_back(dump_config); |
+ } |
+} |
+ |
+void TraceConfig::SetHeapProfilerOptions( |
+ const base::DictionaryValue& memory_dump_config) { |
+ const base::DictionaryValue* heap_profiler_options = nullptr; |
+ if (!memory_dump_config.GetDictionary(kHeapProfilerOptions, |
+ &heap_profiler_options)) |
+ return; |
+ |
+ int min_size_bytes = 0; |
+ if (heap_profiler_options->GetInteger(kBreakdownThresholdBytes, |
+ &min_size_bytes) |
+ && min_size_bytes >= 0) { |
+ memory_dump_config_.heap_profiler_options.breakdown_threshold_bytes = |
+ static_cast<size_t>(min_size_bytes); |
+ } else { |
+ memory_dump_config_.heap_profiler_options.breakdown_threshold_bytes = |
+ HeapProfilerOptions::kDefaultBreakdownThresholdBytes; |
} |
} |
void TraceConfig::SetDefaultMemoryDumpConfig() { |
- memory_dump_config_.clear(); |
- memory_dump_config_.push_back(kDefaultHeavyMemoryDumpTrigger); |
- memory_dump_config_.push_back(kDefaultLightMemoryDumpTrigger); |
+ memory_dump_config_.Clear(); |
+ memory_dump_config_.triggers.push_back(kDefaultHeavyMemoryDumpTrigger); |
+ memory_dump_config_.triggers.push_back(kDefaultLightMemoryDumpTrigger); |
} |
void TraceConfig::ToDict(base::DictionaryValue& dict) const { |
@@ -569,7 +618,7 @@ void TraceConfig::ToDict(base::DictionaryValue& dict) const { |
std::unique_ptr<base::DictionaryValue> memory_dump_config( |
new base::DictionaryValue()); |
std::unique_ptr<base::ListValue> triggers_list(new base::ListValue()); |
- for (const MemoryDumpTriggerConfig& config : memory_dump_config_) { |
+ for (const MemoryDumpTriggerConfig& config : memory_dump_config_.triggers) { |
std::unique_ptr<base::DictionaryValue> trigger_dict( |
new base::DictionaryValue()); |
trigger_dict->SetInteger(kPeriodicIntervalParam, |
@@ -582,6 +631,17 @@ void TraceConfig::ToDict(base::DictionaryValue& dict) const { |
// Empty triggers will still be specified explicitly since it means that |
// the periodic dumps are not enabled. |
memory_dump_config->Set(kTriggersParam, std::move(triggers_list)); |
+ |
+ if (memory_dump_config_.heap_profiler_options.breakdown_threshold_bytes != |
+ HeapProfilerOptions::kDefaultBreakdownThresholdBytes) { |
+ std::unique_ptr<base::DictionaryValue> heap_profiler_options( |
+ new base::DictionaryValue()); |
+ heap_profiler_options->SetInteger( |
+ kBreakdownThresholdBytes, |
+ memory_dump_config_.heap_profiler_options.breakdown_threshold_bytes); |
+ memory_dump_config->Set(kHeapProfilerOptions, |
+ std::move(heap_profiler_options)); |
+ } |
dict.Set(kMemoryDumpConfigParam, std::move(memory_dump_config)); |
} |
} |