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

Unified Diff: content/browser/devtools/devtools_tracing_handler.cc

Issue 569153004: DevTools: disallow to start stop tracing using console.timeline/timelineEnd (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 6 years, 3 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/devtools_tracing_handler.cc
diff --git a/content/browser/devtools/devtools_tracing_handler.cc b/content/browser/devtools/devtools_tracing_handler.cc
index d5cd8597cdd2fd7a4a31a950df3ba4a2d43ba8a2..30f13d160027b65478b0083b35b8789765c30e65 100644
--- a/content/browser/devtools/devtools_tracing_handler.cc
+++ b/content/browser/devtools/devtools_tracing_handler.cc
@@ -113,11 +113,9 @@ base::debug::TraceOptions DevToolsTracingHandler::TraceOptionsFromString(
scoped_refptr<DevToolsProtocol::Response>
DevToolsTracingHandler::OnStart(
scoped_refptr<DevToolsProtocol::Command> command) {
- // If inspected target is a render process Tracing.start will be handled by
- // tracing agent in the renderer.
- if (target_ == Renderer)
- return NULL;
-
+ if (is_recording_) {
+ return command->InternalErrorResponse("Tracing is already started");
+ }
is_recording_ = true;
std::string categories;
@@ -139,6 +137,16 @@ DevToolsTracingHandler::OnStart(
SetupTimer(usage_reporting_interval);
+ // If inspected target is a render process Tracing.start will be handled by
+ // tracing agent in the renderer.
+ if (target_ == Renderer) {
+ TracingController::GetInstance()->EnableRecording(
+ base::debug::CategoryFilter(categories),
+ options,
+ TracingController::EnableRecordingDoneCallback());
+ return NULL;
+ }
+
TracingController::GetInstance()->EnableRecording(
base::debug::CategoryFilter(categories),
options,
@@ -182,11 +190,14 @@ void DevToolsTracingHandler::OnBufferUsage(float usage) {
scoped_refptr<DevToolsProtocol::Response>
DevToolsTracingHandler::OnEnd(
scoped_refptr<DevToolsProtocol::Command> command) {
+ if (!is_recording_) {
+ return command->InternalErrorResponse("Tracing is not started");
+ }
+ DisableRecording(false);
// If inspected target is a render process Tracing.end will be handled by
// tracing agent in the renderer.
if (target_ == Renderer)
return NULL;
- DisableRecording(false);
return command->SuccessResponse(NULL);
}
@@ -227,26 +238,4 @@ void DevToolsTracingHandler::OnCategoriesReceived(
SendAsyncResponse(command->SuccessResponse(response));
}
-void DevToolsTracingHandler::EnableTracing(const std::string& category_filter) {
- if (is_recording_)
- return;
- is_recording_ = true;
-
- SetupTimer(kDefaultReportingInterval);
-
- TracingController::GetInstance()->EnableRecording(
- base::debug::CategoryFilter(category_filter),
- base::debug::TraceOptions(),
- TracingController::EnableRecordingDoneCallback());
- SendNotification(devtools::Tracing::started::kName, NULL);
-}
-
-void DevToolsTracingHandler::DisableTracing() {
- if (!is_recording_)
- return;
- is_recording_ = false;
- DisableRecording(false);
-}
-
-
} // namespace content
« no previous file with comments | « content/browser/devtools/devtools_tracing_handler.h ('k') | content/browser/devtools/render_view_devtools_agent_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698