diff options
author | nednguyen@google.com <nednguyen@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-04 16:30:52 +0000 |
---|---|---|
committer | nednguyen@google.com <nednguyen@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-04 16:30:52 +0000 |
commit | 4753b9ec770f3f51722fc7df6b0568479c19acaf (patch) | |
tree | e5252f3ba3ae220e3c3c80213dc6d4088fedfe77 /content/browser/devtools/devtools_tracing_handler.cc | |
parent | 99c453b803e326a1ff2a9e60bfc43ccc265401c3 (diff) | |
download | chromium_src-4753b9ec770f3f51722fc7df6b0568479c19acaf.zip chromium_src-4753b9ec770f3f51722fc7df6b0568479c19acaf.tar.gz chromium_src-4753b9ec770f3f51722fc7df6b0568479c19acaf.tar.bz2 |
Refactor tracing to pass around base::debug::TraceOptions to reduce spaghetti
Previously, the options for tracing were passed around with different ad hoc
systems. Strings in some places, base::debug::TraceOptions enum in others,
and a content::TraceOptions in yet another. There were two separate ad-hoc
string formats. Similar messes were present with category filters: sometimes
we passed strings, sometimes the CategoryFilter.
This patch though enormous looking simply consolidates all this ad-hockery
into base::debug::TraceOptions. It may look like the call sites have gotten
more verbose,
but the end result of this is a consistent understanding of TraceOptions.
There is one exception to this consolidation: devtools has to maintain its own
mapping of string->TraceOptions encoding. This is because DevTools makes
guarantees about backward compatibility: if base changes its mind about the
string form of a TraceOption, devtools needs to keep supporting the old form.
BUG=396081
TBR=cevans@chromium.org
Review URL: https://codereview.chromium.org/425593002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287348 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/devtools/devtools_tracing_handler.cc')
-rw-r--r-- | content/browser/devtools/devtools_tracing_handler.cc | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/content/browser/devtools/devtools_tracing_handler.cc b/content/browser/devtools/devtools_tracing_handler.cc index 9b1f8e7..19abb63 100644 --- a/content/browser/devtools/devtools_tracing_handler.cc +++ b/content/browser/devtools/devtools_tracing_handler.cc @@ -8,6 +8,7 @@ #include "base/bind.h" #include "base/callback.h" +#include "base/debug/trace_event_impl.h" #include "base/file_util.h" #include "base/json/json_reader.h" #include "base/json/json_writer.h" @@ -128,23 +129,23 @@ void DevToolsTracingHandler::OnTraceDataCollected( SendRawMessage(message); } -TracingController::Options DevToolsTracingHandler::TraceOptionsFromString( +base::debug::TraceOptions DevToolsTracingHandler::TraceOptionsFromString( const std::string& options) { std::vector<std::string> split; std::vector<std::string>::iterator iter; - int ret = 0; + base::debug::TraceOptions ret; base::SplitString(options, ',', &split); for (iter = split.begin(); iter != split.end(); ++iter) { if (*iter == kRecordUntilFull) { - ret &= ~TracingController::RECORD_CONTINUOUSLY; + ret.record_mode = base::debug::RECORD_UNTIL_FULL; } else if (*iter == kRecordContinuously) { - ret |= TracingController::RECORD_CONTINUOUSLY; + ret.record_mode = base::debug::RECORD_CONTINUOUSLY; } else if (*iter == kEnableSampling) { - ret |= TracingController::ENABLE_SAMPLING; + ret.enable_sampling = true; } } - return static_cast<TracingController::Options>(ret); + return ret; } scoped_refptr<DevToolsProtocol::Response> @@ -153,7 +154,7 @@ DevToolsTracingHandler::OnStart( is_recording_ = true; std::string categories; - TracingController::Options options = TracingController::DEFAULT_OPTIONS; + base::debug::TraceOptions options; double usage_reporting_interval = 0.0; base::DictionaryValue* params = command->params(); @@ -175,12 +176,15 @@ DevToolsTracingHandler::OnStart( // tracing agent in the renderer. if (target_ == Renderer) { TracingController::GetInstance()->EnableRecording( - categories, options, TracingController::EnableRecordingDoneCallback()); + base::debug::CategoryFilter(categories), + options, + TracingController::EnableRecordingDoneCallback()); return NULL; } TracingController::GetInstance()->EnableRecording( - categories, options, + base::debug::CategoryFilter(categories), + options, base::Bind(&DevToolsTracingHandler::OnRecordingEnabled, weak_factory_.GetWeakPtr(), command)); @@ -274,8 +278,8 @@ void DevToolsTracingHandler::OnTracingStarted( SetupTimer(kDefaultReportingInterval); TracingController::GetInstance()->EnableRecording( - kDefaultCategories, - TracingController::DEFAULT_OPTIONS, + base::debug::CategoryFilter(kDefaultCategories), + base::debug::TraceOptions(), TracingController::EnableRecordingDoneCallback()); } |