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

Unified Diff: content/browser/devtools/protocol/tracing_handler.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: Created 4 years, 10 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
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(

Powered by Google App Engine
This is Rietveld 408576698