Chromium Code Reviews| Index: content/browser/devtools/protocol/tracing_handler.cc |
| diff --git a/content/browser/devtools/protocol/tracing_handler.cc b/content/browser/devtools/protocol/tracing_handler.cc |
| index d85695731cd3410809e28c56421b338f7b71dd0d..7eb837b388a3d46997123b48b6d403fbdcb1b886 100644 |
| --- a/content/browser/devtools/protocol/tracing_handler.cc |
| +++ b/content/browser/devtools/protocol/tracing_handler.cc |
| @@ -8,6 +8,7 @@ |
| #include "base/bind.h" |
| #include "base/format_macros.h" |
| +#include "base/json/json_writer.h" |
| #include "base/memory/ref_counted_memory.h" |
| #include "base/strings/string_split.h" |
| #include "base/strings/stringprintf.h" |
| @@ -130,23 +131,41 @@ void TracingHandler::OnTraceToStreamComplete(const std::string& stream_handle) { |
| TracingCompleteParams::Create()->set_stream(stream_handle)); |
| } |
| -Response TracingHandler::Start(DevToolsCommandId command_id, |
| - const std::string* categories, |
| - const std::string* options, |
| - const double* buffer_usage_reporting_interval, |
| - const std::string* transfer_mode) { |
| +Response TracingHandler::Start( |
| + DevToolsCommandId command_id, |
| + const std::string* categories, |
| + const std::string* options, |
| + const double* buffer_usage_reporting_interval, |
| + const std::string* transfer_mode, |
| + const scoped_ptr<base::DictionaryValue>& config) { |
| if (IsTracing()) |
| return Response::InternalError("Tracing is already started"); |
| + if (config && (categories || options)) { |
| + return Response::InternalError( |
| + "Both trace config and categories/options are specified. Only one way " |
| + "should be used; and using trace config is preferred."); |
| + } |
| + |
| did_initiate_recording_ = true; |
| return_as_stream_ = |
| transfer_mode && *transfer_mode == start::kTransferModeReturnAsStream; |
| - base::trace_event::TraceConfig trace_config( |
| - categories ? *categories : std::string(), |
| - options ? *options : std::string()); |
| if (buffer_usage_reporting_interval) |
| SetupTimer(*buffer_usage_reporting_interval); |
| + base::trace_event::TraceConfig trace_config; |
| + if (config) { |
| + scoped_ptr<base::DictionaryValue> tracing_style_dict = |
| + base::trace_event::TraceConfig::DevToolsToTracingStyle(config); |
| + std::string trace_config_str; |
| + base::JSONWriter::Write(*tracing_style_dict, &trace_config_str); |
|
caseq
2016/03/05 02:25:24
Why do we have to do an extra roundtrip of writing
Primiano Tucci (use gerrit)
2016/03/06 01:24:37
I think a good layering would be:
- move your di
|
| + trace_config = base::trace_event::TraceConfig(trace_config_str); |
| + } else if (categories || options) { |
| + trace_config = base::trace_event::TraceConfig( |
| + categories ? *categories : std::string(), |
| + options ? *options : std::string()); |
| + } |
| + |
| // If inspected target is a render process Tracing.start will be handled by |
| // tracing agent in the renderer. |
| TracingController::GetInstance()->StartTracing( |