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

Unified Diff: base/trace_event/trace_config.cc

Issue 1814043002: Revert of Update DevTools Tracing.Start to accept trace config as a parameter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 c2c7ad792278ba34040f1c8d74720651e3d88309..d60c08124d29be4e5e65395eabec108da00cade8 100644
--- a/base/trace_event/trace_config.cc
+++ b/base/trace_event/trace_config.cc
@@ -103,10 +103,6 @@
NOTREACHED();
}
InitializeFromStrings(category_filter_string, trace_options_string);
-}
-
-TraceConfig::TraceConfig(const DictionaryValue& config) {
- InitializeFromConfigDict(config);
}
TraceConfig::TraceConfig(const std::string& config_string) {
@@ -292,10 +288,18 @@
excluded_categories_.push_back("*Test");
}
-void TraceConfig::InitializeFromConfigDict(const DictionaryValue& dict) {
+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()));
+
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) {
@@ -308,55 +312,40 @@
}
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;
- const base::ListValue* category_list = nullptr;
- if (dict.GetList(kIncludedCategoriesParam, &category_list))
+ 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.
- const base::DictionaryValue* memory_dump_config = nullptr;
- if (dict.GetDictionary(kMemoryDumpConfigParam, &memory_dump_config))
+ 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(
« 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