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 30 matching lines...) Expand all Loading... | |
41 const char kExcludedCategoriesParam[] = "excluded_categories"; | 41 const char kExcludedCategoriesParam[] = "excluded_categories"; |
42 const char kSyntheticDelaysParam[] = "synthetic_delays"; | 42 const char kSyntheticDelaysParam[] = "synthetic_delays"; |
43 | 43 |
44 const char kSyntheticDelayCategoryFilterPrefix[] = "DELAY("; | 44 const char kSyntheticDelayCategoryFilterPrefix[] = "DELAY("; |
45 | 45 |
46 // String parameters that is used to parse memory dump config in trace config | 46 // String parameters that is used to parse memory dump config in trace config |
47 // string. | 47 // string. |
48 const char kMemoryDumpConfigParam[] = "memory_dump_config"; | 48 const char kMemoryDumpConfigParam[] = "memory_dump_config"; |
49 const char kAllowedDumpModesParam[] = "allowed_dump_modes"; | 49 const char kAllowedDumpModesParam[] = "allowed_dump_modes"; |
50 const char kTriggersParam[] = "triggers"; | 50 const char kTriggersParam[] = "triggers"; |
51 const char kPeriodicIntervalParam[] = "periodic_interval_ms"; | 51 const char kTriggerModeParam[] = "mode"; |
52 const char kModeParam[] = "mode"; | 52 const char kMinTimeBetweenDumps[] = "min_time_between_dumps_ms"; |
53 const char kTriggerTypeParam[] = "type"; | |
54 const char kPeriodicIntervalParam[] = "periodic_interval_ms"; // legacy config | |
Primiano Tucci (use gerrit)
2016/12/15 15:40:43
maybe add Legacy to the name (kPeriodicIntervalLeg
ssid
2016/12/15 19:48:07
Done.
| |
53 const char kHeapProfilerOptions[] = "heap_profiler_options"; | 55 const char kHeapProfilerOptions[] = "heap_profiler_options"; |
54 const char kBreakdownThresholdBytes[] = "breakdown_threshold_bytes"; | 56 const char kBreakdownThresholdBytes[] = "breakdown_threshold_bytes"; |
55 | 57 |
56 // String parameters used to parse category event filters. | 58 // String parameters used to parse category event filters. |
57 const char kEventFiltersParam[] = "event_filters"; | 59 const char kEventFiltersParam[] = "event_filters"; |
58 const char kFilterPredicateParam[] = "filter_predicate"; | 60 const char kFilterPredicateParam[] = "filter_predicate"; |
59 const char kFilterArgsParam[] = "filter_args"; | 61 const char kFilterArgsParam[] = "filter_args"; |
60 | 62 |
61 // Default configuration of memory dumps. | 63 // Default configuration of memory dumps. |
62 const TraceConfig::MemoryDumpConfig::Trigger kDefaultHeavyMemoryDumpTrigger = { | 64 const TraceConfig::MemoryDumpConfig::Trigger kDefaultHeavyMemoryDumpTrigger = { |
63 2000, // periodic_interval_ms | 65 2000, // min_time_between_dumps_ms |
64 MemoryDumpLevelOfDetail::DETAILED}; | 66 MemoryDumpLevelOfDetail::DETAILED, MemoryDumpType::PERIODIC_INTERVAL}; |
65 const TraceConfig::MemoryDumpConfig::Trigger kDefaultLightMemoryDumpTrigger = { | 67 const TraceConfig::MemoryDumpConfig::Trigger kDefaultLightMemoryDumpTrigger = { |
66 250, // periodic_interval_ms | 68 250, // min_time_between_dumps_ms |
67 MemoryDumpLevelOfDetail::LIGHT}; | 69 MemoryDumpLevelOfDetail::LIGHT, MemoryDumpType::PERIODIC_INTERVAL}; |
68 | 70 |
69 class ConvertableTraceConfigToTraceFormat | 71 class ConvertableTraceConfigToTraceFormat |
70 : public base::trace_event::ConvertableToTraceFormat { | 72 : public base::trace_event::ConvertableToTraceFormat { |
71 public: | 73 public: |
72 explicit ConvertableTraceConfigToTraceFormat(const TraceConfig& trace_config) | 74 explicit ConvertableTraceConfigToTraceFormat(const TraceConfig& trace_config) |
73 : trace_config_(trace_config) {} | 75 : trace_config_(trace_config) {} |
74 | 76 |
75 ~ConvertableTraceConfigToTraceFormat() override {} | 77 ~ConvertableTraceConfigToTraceFormat() override {} |
76 | 78 |
77 void AppendAsTraceFormat(std::string* out) const override { | 79 void AppendAsTraceFormat(std::string* out) const override { |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
585 // Set triggers | 587 // Set triggers |
586 memory_dump_config_.triggers.clear(); | 588 memory_dump_config_.triggers.clear(); |
587 const ListValue* trigger_list = nullptr; | 589 const ListValue* trigger_list = nullptr; |
588 if (memory_dump_config.GetList(kTriggersParam, &trigger_list) && | 590 if (memory_dump_config.GetList(kTriggersParam, &trigger_list) && |
589 trigger_list->GetSize() > 0) { | 591 trigger_list->GetSize() > 0) { |
590 for (size_t i = 0; i < trigger_list->GetSize(); ++i) { | 592 for (size_t i = 0; i < trigger_list->GetSize(); ++i) { |
591 const DictionaryValue* trigger = nullptr; | 593 const DictionaryValue* trigger = nullptr; |
592 if (!trigger_list->GetDictionary(i, &trigger)) | 594 if (!trigger_list->GetDictionary(i, &trigger)) |
593 continue; | 595 continue; |
594 | 596 |
597 MemoryDumpConfig::Trigger dump_config; | |
595 int interval = 0; | 598 int interval = 0; |
596 if (!trigger->GetInteger(kPeriodicIntervalParam, &interval)) | 599 if (!trigger->GetInteger(kMinTimeBetweenDumps, &interval)) { |
597 continue; | 600 // If "min_time_between_dumps_ms" param was not given, then the trace |
601 // config uses old format where only periodic dumps are supported. | |
602 trigger->GetInteger(kPeriodicIntervalParam, &interval); | |
Primiano Tucci (use gerrit)
2016/12/15 15:40:43
don't you have to keep the path where you skip if
ssid
2016/12/15 19:48:07
um, this will happen if someone writes:
memory_dum
Primiano Tucci (use gerrit)
2016/12/16 12:13:55
Yeah I just didn't see the "!", sorry ignore my pr
| |
603 dump_config.trigger_type = MemoryDumpType::PERIODIC_INTERVAL; | |
604 } else { | |
605 std::string trigger_type_str; | |
606 trigger->GetString(kTriggerTypeParam, &trigger_type_str); | |
607 dump_config.trigger_type = StringToMemoryDumpType(trigger_type_str); | |
608 } | |
609 DCHECK_GT(interval, 0); | |
610 dump_config.min_time_between_dumps_ms = static_cast<uint32_t>(interval); | |
598 | 611 |
599 DCHECK_GT(interval, 0); | |
600 MemoryDumpConfig::Trigger dump_config; | |
601 dump_config.periodic_interval_ms = static_cast<uint32_t>(interval); | |
602 std::string level_of_detail_str; | 612 std::string level_of_detail_str; |
603 trigger->GetString(kModeParam, &level_of_detail_str); | 613 trigger->GetString(kTriggerModeParam, &level_of_detail_str); |
604 dump_config.level_of_detail = | 614 dump_config.level_of_detail = |
605 StringToMemoryDumpLevelOfDetail(level_of_detail_str); | 615 StringToMemoryDumpLevelOfDetail(level_of_detail_str); |
616 | |
606 memory_dump_config_.triggers.push_back(dump_config); | 617 memory_dump_config_.triggers.push_back(dump_config); |
607 } | 618 } |
608 } | 619 } |
609 | 620 |
610 // Set heap profiler options | 621 // Set heap profiler options |
611 const DictionaryValue* heap_profiler_options = nullptr; | 622 const DictionaryValue* heap_profiler_options = nullptr; |
612 if (memory_dump_config.GetDictionary(kHeapProfilerOptions, | 623 if (memory_dump_config.GetDictionary(kHeapProfilerOptions, |
613 &heap_profiler_options)) { | 624 &heap_profiler_options)) { |
614 int min_size_bytes = 0; | 625 int min_size_bytes = 0; |
615 if (heap_profiler_options->GetInteger(kBreakdownThresholdBytes, | 626 if (heap_profiler_options->GetInteger(kBreakdownThresholdBytes, |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
744 auto allowed_modes = MakeUnique<ListValue>(); | 755 auto allowed_modes = MakeUnique<ListValue>(); |
745 for (auto dump_mode : memory_dump_config_.allowed_dump_modes) | 756 for (auto dump_mode : memory_dump_config_.allowed_dump_modes) |
746 allowed_modes->AppendString(MemoryDumpLevelOfDetailToString(dump_mode)); | 757 allowed_modes->AppendString(MemoryDumpLevelOfDetailToString(dump_mode)); |
747 | 758 |
748 auto memory_dump_config = MakeUnique<DictionaryValue>(); | 759 auto memory_dump_config = MakeUnique<DictionaryValue>(); |
749 memory_dump_config->Set(kAllowedDumpModesParam, std::move(allowed_modes)); | 760 memory_dump_config->Set(kAllowedDumpModesParam, std::move(allowed_modes)); |
750 | 761 |
751 auto triggers_list = MakeUnique<ListValue>(); | 762 auto triggers_list = MakeUnique<ListValue>(); |
752 for (const auto& config : memory_dump_config_.triggers) { | 763 for (const auto& config : memory_dump_config_.triggers) { |
753 auto trigger_dict = MakeUnique<DictionaryValue>(); | 764 auto trigger_dict = MakeUnique<DictionaryValue>(); |
754 trigger_dict->SetInteger(kPeriodicIntervalParam, | 765 trigger_dict->SetString(kTriggerTypeParam, |
755 static_cast<int>(config.periodic_interval_ms)); | 766 MemoryDumpTypeToString(config.trigger_type)); |
767 trigger_dict->SetInteger( | |
768 kMinTimeBetweenDumps, | |
769 static_cast<int>(config.min_time_between_dumps_ms)); | |
756 trigger_dict->SetString( | 770 trigger_dict->SetString( |
757 kModeParam, MemoryDumpLevelOfDetailToString(config.level_of_detail)); | 771 kTriggerModeParam, |
772 MemoryDumpLevelOfDetailToString(config.level_of_detail)); | |
758 triggers_list->Append(std::move(trigger_dict)); | 773 triggers_list->Append(std::move(trigger_dict)); |
759 } | 774 } |
760 | 775 |
761 // Empty triggers will still be specified explicitly since it means that | 776 // Empty triggers will still be specified explicitly since it means that |
762 // the periodic dumps are not enabled. | 777 // the periodic dumps are not enabled. |
763 memory_dump_config->Set(kTriggersParam, std::move(triggers_list)); | 778 memory_dump_config->Set(kTriggersParam, std::move(triggers_list)); |
764 | 779 |
765 if (memory_dump_config_.heap_profiler_options.breakdown_threshold_bytes != | 780 if (memory_dump_config_.heap_profiler_options.breakdown_threshold_bytes != |
766 MemoryDumpConfig::HeapProfiler::kDefaultBreakdownThresholdBytes) { | 781 MemoryDumpConfig::HeapProfiler::kDefaultBreakdownThresholdBytes) { |
767 auto options = MakeUnique<DictionaryValue>(); | 782 auto options = MakeUnique<DictionaryValue>(); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
849 StringPiece str) { | 864 StringPiece str) { |
850 return str.empty() || str.front() == ' ' || str.back() == ' '; | 865 return str.empty() || str.front() == ' ' || str.back() == ' '; |
851 } | 866 } |
852 | 867 |
853 bool TraceConfig::HasIncludedPatterns() const { | 868 bool TraceConfig::HasIncludedPatterns() const { |
854 return !included_categories_.empty(); | 869 return !included_categories_.empty(); |
855 } | 870 } |
856 | 871 |
857 } // namespace trace_event | 872 } // namespace trace_event |
858 } // namespace base | 873 } // namespace base |
OLD | NEW |