OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/trace_event/trace_config.h" | 5 #include "base/trace_event/trace_config.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } // namespace | 78 } // namespace |
79 | 79 |
80 | 80 |
81 TraceConfig::MemoryDumpConfig::HeapProfiler::HeapProfiler() : | 81 TraceConfig::MemoryDumpConfig::HeapProfiler::HeapProfiler() : |
82 breakdown_threshold_bytes(kDefaultBreakdownThresholdBytes) {}; | 82 breakdown_threshold_bytes(kDefaultBreakdownThresholdBytes) {}; |
83 | 83 |
84 void TraceConfig::MemoryDumpConfig::HeapProfiler::Clear() { | 84 void TraceConfig::MemoryDumpConfig::HeapProfiler::Clear() { |
85 breakdown_threshold_bytes = kDefaultBreakdownThresholdBytes; | 85 breakdown_threshold_bytes = kDefaultBreakdownThresholdBytes; |
86 } | 86 } |
87 | 87 |
| 88 void TraceConfig::ResetMemoryDumpConfig( |
| 89 const TraceConfig::MemoryDumpConfig& memory_dump_config) { |
| 90 memory_dump_config_.Clear(); |
| 91 memory_dump_config_ = memory_dump_config; |
| 92 } |
| 93 |
88 TraceConfig::MemoryDumpConfig::MemoryDumpConfig() {}; | 94 TraceConfig::MemoryDumpConfig::MemoryDumpConfig() {}; |
89 | 95 |
90 TraceConfig::MemoryDumpConfig::MemoryDumpConfig( | 96 TraceConfig::MemoryDumpConfig::MemoryDumpConfig( |
91 const MemoryDumpConfig& other) = default; | 97 const MemoryDumpConfig& other) = default; |
92 | 98 |
93 TraceConfig::MemoryDumpConfig::~MemoryDumpConfig() {}; | 99 TraceConfig::MemoryDumpConfig::~MemoryDumpConfig() {}; |
94 | 100 |
95 void TraceConfig::MemoryDumpConfig::Clear() { | 101 void TraceConfig::MemoryDumpConfig::Clear() { |
96 triggers.clear(); | 102 triggers.clear(); |
97 heap_profiler_options.Clear(); | 103 heap_profiler_options.Clear(); |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 if (dict.GetList(kExcludedCategoriesParam, &category_list)) | 360 if (dict.GetList(kExcludedCategoriesParam, &category_list)) |
355 SetCategoriesFromExcludedList(*category_list); | 361 SetCategoriesFromExcludedList(*category_list); |
356 if (dict.GetList(kSyntheticDelaysParam, &category_list)) | 362 if (dict.GetList(kSyntheticDelaysParam, &category_list)) |
357 SetSyntheticDelaysFromList(*category_list); | 363 SetSyntheticDelaysFromList(*category_list); |
358 | 364 |
359 if (IsCategoryEnabled(MemoryDumpManager::kTraceCategory)) { | 365 if (IsCategoryEnabled(MemoryDumpManager::kTraceCategory)) { |
360 // If dump triggers not set, the client is using the legacy with just | 366 // If dump triggers not set, the client is using the legacy with just |
361 // category enabled. So, use the default periodic dump config. | 367 // category enabled. So, use the default periodic dump config. |
362 const base::DictionaryValue* memory_dump_config = nullptr; | 368 const base::DictionaryValue* memory_dump_config = nullptr; |
363 if (dict.GetDictionary(kMemoryDumpConfigParam, &memory_dump_config)) | 369 if (dict.GetDictionary(kMemoryDumpConfigParam, &memory_dump_config)) |
364 SetMemoryDumpConfig(*memory_dump_config); | 370 SetMemoryDumpConfigFromConfigDict(*memory_dump_config); |
365 else | 371 else |
366 SetDefaultMemoryDumpConfig(); | 372 SetDefaultMemoryDumpConfig(); |
367 } | 373 } |
368 } | 374 } |
369 | 375 |
370 void TraceConfig::InitializeFromConfigString(const std::string& config_string) { | 376 void TraceConfig::InitializeFromConfigString(const std::string& config_string) { |
371 std::unique_ptr<Value> value(JSONReader::Read(config_string)); | 377 std::unique_ptr<Value> value(JSONReader::Read(config_string)); |
372 if (!value) | 378 if (!value) |
373 return InitializeDefault(); | 379 return InitializeDefault(); |
374 | 380 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 std::unique_ptr<base::ListValue> list(new base::ListValue()); | 508 std::unique_ptr<base::ListValue> list(new base::ListValue()); |
503 for (StringList::const_iterator ci = categories.begin(); | 509 for (StringList::const_iterator ci = categories.begin(); |
504 ci != categories.end(); | 510 ci != categories.end(); |
505 ++ci) { | 511 ++ci) { |
506 list->AppendString(*ci); | 512 list->AppendString(*ci); |
507 } | 513 } |
508 | 514 |
509 dict.Set(param, std::move(list)); | 515 dict.Set(param, std::move(list)); |
510 } | 516 } |
511 | 517 |
512 void TraceConfig::SetMemoryDumpConfig( | 518 void TraceConfig::SetMemoryDumpConfigFromConfigDict( |
513 const base::DictionaryValue& memory_dump_config) { | 519 const base::DictionaryValue& memory_dump_config) { |
514 // Set triggers | 520 // Set triggers |
515 memory_dump_config_.triggers.clear(); | 521 memory_dump_config_.triggers.clear(); |
516 | 522 |
517 const base::ListValue* trigger_list = nullptr; | 523 const base::ListValue* trigger_list = nullptr; |
518 if (memory_dump_config.GetList(kTriggersParam, &trigger_list) && | 524 if (memory_dump_config.GetList(kTriggersParam, &trigger_list) && |
519 trigger_list->GetSize() > 0) { | 525 trigger_list->GetSize() > 0) { |
520 for (size_t i = 0; i < trigger_list->GetSize(); ++i) { | 526 for (size_t i = 0; i < trigger_list->GetSize(); ++i) { |
521 const base::DictionaryValue* trigger = nullptr; | 527 const base::DictionaryValue* trigger = nullptr; |
522 if (!trigger_list->GetDictionary(i, &trigger)) | 528 if (!trigger_list->GetDictionary(i, &trigger)) |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 str.at(0) == ' ' || | 727 str.at(0) == ' ' || |
722 str.at(str.length() - 1) == ' '; | 728 str.at(str.length() - 1) == ' '; |
723 } | 729 } |
724 | 730 |
725 bool TraceConfig::HasIncludedPatterns() const { | 731 bool TraceConfig::HasIncludedPatterns() const { |
726 return !included_categories_.empty(); | 732 return !included_categories_.empty(); |
727 } | 733 } |
728 | 734 |
729 } // namespace trace_event | 735 } // namespace trace_event |
730 } // namespace base | 736 } // namespace base |
OLD | NEW |