diff options
author | fgorski <fgorski@chromium.org> | 2016-03-17 13:53:49 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-17 20:54:52 +0000 |
commit | 46d2c0ed24c95bd4cc16e51c88bd9f322795e369 (patch) | |
tree | 560af5d72d696ad22ba7172623a574bdb43e06f8 /base | |
parent | 7a424887acfb34ff97b2e98ea6188f512f609684 (diff) | |
download | chromium_src-46d2c0ed24c95bd4cc16e51c88bd9f322795e369.zip chromium_src-46d2c0ed24c95bd4cc16e51c88bd9f322795e369.tar.gz chromium_src-46d2c0ed24c95bd4cc16e51c88bd9f322795e369.tar.bz2 |
Revert of Update DevTools Tracing.Start to accept trace config as a parameter (patchset #10 id:180001 of https://codereview.chromium.org/1765153002/ )
Reason for revert:
TraceConfigTest.TraceConfigFromDict fialed
https://build.chromium.org/p/chromium.linux/builders/Cast%20Linux/builds/21289/steps/base_unittests/logs/stdio
https://build.chromium.org/p/chromium.linux/builders/Cast%20Linux/builds/21289
Original issue's description:
> Update DevTools Tracing.Start to accept trace config as
> a parameter
>
> This CL updates Tracing.Start to accept trace config as
> a parameter when starting tracing. It is backward compatible
> with the old way.
>
> Design doc: https://goo.gl/GxQ23k
> BUG=579358
>
> Committed: https://crrev.com/c0e3792f832fc454324dbe35d01079b124b072cd
> Cr-Commit-Position: refs/heads/master@{#381783}
TBR=caseq@chromium.org,primiano@chromium.org,nednguyen@google.com,petrcermak@chromium.org,simonhatch@chromium.org,pfeldman@chromium.org,zhenw@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=579358
Review URL: https://codereview.chromium.org/1814043002
Cr-Commit-Position: refs/heads/master@{#381794}
Diffstat (limited to 'base')
-rw-r--r-- | base/trace_event/trace_config.cc | 49 | ||||
-rw-r--r-- | base/trace_event/trace_config.h | 9 | ||||
-rw-r--r-- | base/trace_event/trace_config_unittest.cc | 63 |
3 files changed, 20 insertions, 101 deletions
diff --git a/base/trace_event/trace_config.cc b/base/trace_event/trace_config.cc index c2c7ad7..d60c081 100644 --- a/base/trace_event/trace_config.cc +++ b/base/trace_event/trace_config.cc @@ -105,10 +105,6 @@ 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); @@ -292,10 +288,18 @@ void TraceConfig::InitializeDefault() { 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,57 +312,42 @@ void TraceConfig::InitializeFromConfigDict(const DictionaryValue& dict) { } 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( const std::string& category_filter_string, const std::string& trace_options_string) { diff --git a/base/trace_event/trace_config.h b/base/trace_event/trace_config.h index 75e001b..81b7d51 100644 --- a/base/trace_event/trace_config.h +++ b/base/trace_event/trace_config.h @@ -130,10 +130,6 @@ class BASE_EXPORT TraceConfig { // disabled-by-default-memory-infra category is enabled. explicit TraceConfig(const std::string& config_string); - // Functionally identical to the above, but takes a parsed dictionary as input - // instead of its JSON serialization. - explicit TraceConfig(const DictionaryValue& config); - TraceConfig(const TraceConfig& tc); ~TraceConfig(); @@ -194,10 +190,7 @@ class BASE_EXPORT TraceConfig { // in the suffix 'Debug' or 'Test'. void InitializeDefault(); - // Initialize from a config dictionary. - void InitializeFromConfigDict(const DictionaryValue& dict); - - // Initialize from a config string. + // Initialize from the config string void InitializeFromConfigString(const std::string& config_string); // Initialize from category filter and trace options strings diff --git a/base/trace_event/trace_config_unittest.cc b/base/trace_event/trace_config_unittest.cc index 273adac..bd37880 100644 --- a/base/trace_event/trace_config_unittest.cc +++ b/base/trace_event/trace_config_unittest.cc @@ -4,7 +4,6 @@ #include <stddef.h> -#include "base/json/json_reader.h" #include "base/macros.h" #include "base/trace_event/memory_dump_manager.h" #include "base/trace_event/trace_config.h" @@ -24,27 +23,6 @@ const char kDefaultTraceConfigString[] = "\"excluded_categories\":[\"*Debug\",\"*Test\"]," "\"record_mode\":\"record-until-full\"" "}"; - -const char kCustomTraceConfigString[] = - "{" - "\"enable_argument_filter\":true," - "\"enable_sampling\":true," - "\"enable_systrace\":true," - "\"excluded_categories\":[\"excluded\",\"exc_pattern*\"]," - "\"included_categories\":[\"included\"," - "\"inc_pattern*\"," - "\"disabled-by-default-cc\"," - "\"disabled-by-default-memory-infra\"]," - "\"memory_dump_config\":{" - "\"triggers\":[" - "{\"mode\":\"light\",\"periodic_interval_ms\":50}," - "{\"mode\":\"detailed\",\"periodic_interval_ms\":1000}" - "]" - "}," - "\"record_mode\":\"record-continuously\"," - "\"synthetic_delays\":[\"test.Delay1;16\",\"test.Delay2;32\"]" - "}"; - } // namespace TEST(TraceConfigTest, TraceConfigFromValidLegacyFormat) { @@ -281,47 +259,6 @@ TEST(TraceConfigTest, ConstructDefaultTraceConfig) { EXPECT_FALSE(tc.IsCategoryGroupEnabled("CategoryDebug,CategoryTest")); } -TEST(TraceConfigTest, TraceConfigFromDict) { - // Passing in empty dictionary will not result in default trace config. - DictionaryValue dict; - TraceConfig tc(dict); - EXPECT_STRNE(kDefaultTraceConfigString, tc.ToString().c_str()); - EXPECT_EQ(RECORD_UNTIL_FULL, tc.GetTraceRecordMode()); - EXPECT_FALSE(tc.IsSamplingEnabled()); - EXPECT_FALSE(tc.IsSystraceEnabled()); - EXPECT_FALSE(tc.IsArgumentFilterEnabled()); - EXPECT_STREQ("", tc.ToCategoryFilterString().c_str()); - - scoped_ptr<Value> default_value(JSONReader::Read(kDefaultTraceConfigString)); - DCHECK(default_value); - const DictionaryValue* default_dict = nullptr; - bool is_dict = default_value->GetAsDictionary(&default_dict); - DCHECK(is_dict); - TraceConfig default_tc(*default_dict); - EXPECT_STREQ(kDefaultTraceConfigString, default_tc.ToString().c_str()); - EXPECT_EQ(RECORD_UNTIL_FULL, default_tc.GetTraceRecordMode()); - EXPECT_FALSE(default_tc.IsSamplingEnabled()); - EXPECT_FALSE(default_tc.IsSystraceEnabled()); - EXPECT_FALSE(default_tc.IsArgumentFilterEnabled()); - EXPECT_STREQ("-*Debug,-*Test", default_tc.ToCategoryFilterString().c_str()); - - scoped_ptr<Value> custom_value(JSONReader::Read(kCustomTraceConfigString)); - DCHECK(custom_value); - const DictionaryValue* custom_dict = nullptr; - DCHECK(custom_value->GetAsDictionary(&custom_dict)); - TraceConfig custom_tc(*custom_dict); - EXPECT_STREQ(kCustomTraceConfigString, custom_tc.ToString().c_str()); - EXPECT_EQ(RECORD_CONTINUOUSLY, custom_tc.GetTraceRecordMode()); - EXPECT_TRUE(custom_tc.IsSamplingEnabled()); - EXPECT_TRUE(custom_tc.IsSystraceEnabled()); - EXPECT_TRUE(custom_tc.IsArgumentFilterEnabled()); - EXPECT_STREQ("included,inc_pattern*," - "disabled-by-default-cc,disabled-by-default-memory-infra," - "-excluded,-exc_pattern*," - "DELAY(test.Delay1;16),DELAY(test.Delay2;32)", - custom_tc.ToCategoryFilterString().c_str()); -} - TEST(TraceConfigTest, TraceConfigFromValidString) { // Using some non-empty config string. const char config_string[] = |