| 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..25a0cd6d40b5d7aee19c68a9eb06a54f2c665bd5 100644
|
| --- a/base/trace_event/trace_config.cc
|
| +++ b/base/trace_event/trace_config.cc
|
| @@ -50,12 +50,14 @@ 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 = {
|
| +const TraceConfig::MemoryDumpConfig::Trigger kDefaultHeavyMemoryDumpTrigger = {
|
| 2000, // periodic_interval_ms
|
| MemoryDumpLevelOfDetail::DETAILED};
|
| -const TraceConfig::MemoryDumpTriggerConfig kDefaultLightMemoryDumpTrigger = {
|
| +const TraceConfig::MemoryDumpConfig::Trigger kDefaultLightMemoryDumpTrigger = {
|
| 250, // periodic_interval_ms
|
| MemoryDumpLevelOfDetail::LIGHT};
|
|
|
| @@ -75,6 +77,26 @@ class ConvertableTraceConfigToTraceFormat
|
|
|
| } // namespace
|
|
|
| +
|
| +TraceConfig::MemoryDumpConfig::HeapProfiler::HeapProfiler() :
|
| + breakdown_threshold_bytes(kDefaultBreakdownThresholdBytes) {};
|
| +
|
| +void TraceConfig::MemoryDumpConfig::HeapProfiler::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 +279,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 +303,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,39 +511,54 @@ void TraceConfig::AddCategoryToDict(base::DictionaryValue& dict,
|
|
|
| void TraceConfig::SetMemoryDumpConfig(
|
| const base::DictionaryValue& memory_dump_config) {
|
| - memory_dump_config_.clear();
|
| + // 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) {
|
| - return;
|
| - }
|
| + if (memory_dump_config.GetList(kTriggersParam, &trigger_list) &&
|
| + trigger_list->GetSize() > 0) {
|
| + for (size_t i = 0; i < trigger_list->GetSize(); ++i) {
|
| + const base::DictionaryValue* trigger = nullptr;
|
| + if (!trigger_list->GetDictionary(i, &trigger))
|
| + continue;
|
|
|
| - for (size_t i = 0; i < trigger_list->GetSize(); ++i) {
|
| - const base::DictionaryValue* trigger = nullptr;
|
| - if (!trigger_list->GetDictionary(i, &trigger))
|
| - continue;
|
| + MemoryDumpConfig::Trigger dump_config;
|
| + int interval = 0;
|
|
|
| - MemoryDumpTriggerConfig dump_config;
|
| - int interval = 0;
|
| + if (!trigger->GetInteger(kPeriodicIntervalParam, &interval)) {
|
| + continue;
|
| + }
|
| + DCHECK_GT(interval, 0);
|
| + dump_config.periodic_interval_ms = static_cast<uint32_t>(interval);
|
| + std::string level_of_detail_str;
|
| + trigger->GetString(kModeParam, &level_of_detail_str);
|
| + dump_config.level_of_detail =
|
| + StringToMemoryDumpLevelOfDetail(level_of_detail_str);
|
| + memory_dump_config_.triggers.push_back(dump_config);
|
| + }
|
| + }
|
|
|
| - if (!trigger->GetInteger(kPeriodicIntervalParam, &interval)) {
|
| - continue;
|
| + // Set heap profiler options
|
| + const base::DictionaryValue* heap_profiler_options = nullptr;
|
| + if (memory_dump_config.GetDictionary(kHeapProfilerOptions,
|
| + &heap_profiler_options)) {
|
| + 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 =
|
| + MemoryDumpConfig::HeapProfiler::kDefaultBreakdownThresholdBytes;
|
| }
|
| - DCHECK_GT(interval, 0);
|
| - dump_config.periodic_interval_ms = static_cast<uint32_t>(interval);
|
| - std::string level_of_detail_str;
|
| - trigger->GetString(kModeParam, &level_of_detail_str);
|
| - dump_config.level_of_detail =
|
| - StringToMemoryDumpLevelOfDetail(level_of_detail_str);
|
| - memory_dump_config_.push_back(dump_config);
|
| }
|
| }
|
|
|
| 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 +606,8 @@ 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 MemoryDumpConfig::Trigger& config
|
| + : memory_dump_config_.triggers) {
|
| std::unique_ptr<base::DictionaryValue> trigger_dict(
|
| new base::DictionaryValue());
|
| trigger_dict->SetInteger(kPeriodicIntervalParam,
|
| @@ -582,6 +620,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 !=
|
| + MemoryDumpConfig::HeapProfiler::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));
|
| }
|
| }
|
|
|