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

Unified Diff: base/trace_event/trace_config.cc

Issue 1765153002: Update DevTools Tracing.Start to accept trace config as a parameter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: inline enum Created 4 years, 9 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
« no previous file with comments | « base/trace_event/trace_config.h ('k') | base/trace_event/trace_config_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/trace_event/trace_config.cc
diff --git a/base/trace_event/trace_config.cc b/base/trace_event/trace_config.cc
index d60c08124d29be4e5e65395eabec108da00cade8..c2c7ad792278ba34040f1c8d74720651e3d88309 100644
--- a/base/trace_event/trace_config.cc
+++ b/base/trace_event/trace_config.cc
@@ -105,6 +105,10 @@ TraceConfig::TraceConfig(const std::string& category_filter_string,
InitializeFromStrings(category_filter_string, trace_options_string);
}
+TraceConfig::TraceConfig(const DictionaryValue& config) {
+ InitializeFromConfigDict(config);
+}
+
TraceConfig::TraceConfig(const std::string& config_string) {
if (!config_string.empty())
InitializeFromConfigString(config_string);
@@ -288,18 +292,10 @@ void TraceConfig::InitializeDefault() {
excluded_categories_.push_back("*Test");
}
-void TraceConfig::InitializeFromConfigString(const std::string& config_string) {
- scoped_ptr<base::Value> value(base::JSONReader::Read(config_string));
- if (!value || !value->IsType(base::Value::TYPE_DICTIONARY)) {
- InitializeDefault();
- return;
- }
- scoped_ptr<base::DictionaryValue> dict(
- static_cast<base::DictionaryValue*>(value.release()));
-
+void TraceConfig::InitializeFromConfigDict(const DictionaryValue& dict) {
record_mode_ = RECORD_UNTIL_FULL;
std::string record_mode;
- if (dict->GetString(kRecordModeParam, &record_mode)) {
+ if (dict.GetString(kRecordModeParam, &record_mode)) {
if (record_mode == kRecordUntilFull) {
record_mode_ = RECORD_UNTIL_FULL;
} else if (record_mode == kRecordContinuously) {
@@ -312,42 +308,57 @@ void TraceConfig::InitializeFromConfigString(const std::string& config_string) {
}
bool enable_sampling;
- if (!dict->GetBoolean(kEnableSamplingParam, &enable_sampling))
+ if (!dict.GetBoolean(kEnableSamplingParam, &enable_sampling))
enable_sampling_ = false;
else
enable_sampling_ = enable_sampling;
bool enable_systrace;
- if (!dict->GetBoolean(kEnableSystraceParam, &enable_systrace))
+ if (!dict.GetBoolean(kEnableSystraceParam, &enable_systrace))
enable_systrace_ = false;
else
enable_systrace_ = enable_systrace;
bool enable_argument_filter;
- if (!dict->GetBoolean(kEnableArgumentFilterParam, &enable_argument_filter))
+ if (!dict.GetBoolean(kEnableArgumentFilterParam, &enable_argument_filter))
enable_argument_filter_ = false;
else
enable_argument_filter_ = enable_argument_filter;
- base::ListValue* category_list = nullptr;
- if (dict->GetList(kIncludedCategoriesParam, &category_list))
+ const base::ListValue* category_list = nullptr;
+ if (dict.GetList(kIncludedCategoriesParam, &category_list))
SetCategoriesFromIncludedList(*category_list);
- if (dict->GetList(kExcludedCategoriesParam, &category_list))
+ if (dict.GetList(kExcludedCategoriesParam, &category_list))
SetCategoriesFromExcludedList(*category_list);
- if (dict->GetList(kSyntheticDelaysParam, &category_list))
+ if (dict.GetList(kSyntheticDelaysParam, &category_list))
SetSyntheticDelaysFromList(*category_list);
if (IsCategoryEnabled(MemoryDumpManager::kTraceCategory)) {
// If dump triggers not set, the client is using the legacy with just
// category enabled. So, use the default periodic dump config.
- base::DictionaryValue* memory_dump_config = nullptr;
- if (dict->GetDictionary(kMemoryDumpConfigParam, &memory_dump_config))
+ const base::DictionaryValue* memory_dump_config = nullptr;
+ if (dict.GetDictionary(kMemoryDumpConfigParam, &memory_dump_config))
SetMemoryDumpConfig(*memory_dump_config);
else
SetDefaultMemoryDumpConfig();
}
}
+void TraceConfig::InitializeFromConfigString(const std::string& config_string) {
+ scoped_ptr<Value> value(JSONReader::Read(config_string));
+ if (!value)
+ return InitializeDefault();
+
+ const DictionaryValue* dict = nullptr;
+ bool is_dict = value->GetAsDictionary(&dict);
+
+ if (!is_dict)
+ return InitializeDefault();
+
+ DCHECK(dict);
+ InitializeFromConfigDict(*dict);
+}
+
void TraceConfig::InitializeFromStrings(
const std::string& category_filter_string,
const std::string& trace_options_string) {
« no previous file with comments | « base/trace_event/trace_config.h ('k') | base/trace_event/trace_config_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698