Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(516)

Unified Diff: base/trace_event/trace_config.cc

Issue 2041583003: [tracing] Introduce "allowed_dump_modes" for memory dump config (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@background_config
Patch Set: Fixes and rebase. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/trace_event/trace_config.cc
diff --git a/base/trace_event/trace_config.cc b/base/trace_event/trace_config.cc
index 5e2e00835ab3e7d80325df0bee5c4b5d5e05d691..0c893b5e658552c4ab3fc5d6cd1269234d0319a7 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) +
+ 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();
}
@@ -517,9 +530,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) {
@@ -565,6 +592,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 {
@@ -611,6 +639,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) {

Powered by Google App Engine
This is Rietveld 408576698