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

Unified Diff: Source/core/inspector/InspectorTracingAgent.cpp

Issue 254613002: DevTools: add Tracing agent on back-end (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: review comments addressed Created 6 years, 8 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
« no previous file with comments | « Source/core/inspector/InspectorTracingAgent.h ('k') | Source/core/inspector/WorkerInspectorController.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/inspector/InspectorTracingAgent.cpp
diff --git a/Source/core/inspector/InspectorTracingAgent.cpp b/Source/core/inspector/InspectorTracingAgent.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b34b798b4ee5219014d751889704cb89be272b57
--- /dev/null
+++ b/Source/core/inspector/InspectorTracingAgent.cpp
@@ -0,0 +1,115 @@
+//
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+#include "config.h"
+
+#include "core/inspector/InspectorTracingAgent.h"
+
+#include "core/inspector/IdentifiersFactory.h"
+#include "core/inspector/InspectorClient.h"
+#include "core/inspector/InspectorState.h"
+#include "platform/TraceEvent.h"
+
+namespace WebCore {
+
+namespace TracingAgentState {
+const char enabled[] = "enabled";
+const char sessionId[] = "sessionId";
+const char tracingCategoryFilter[] = "tracingCategoryFilter";
+}
+
+InspectorTracingAgent::InspectorTracingAgent(InspectorClient* client)
+ : InspectorBaseAgent<InspectorTracingAgent>("Tracing")
+ , m_frontend(0)
+ , m_client(client)
+ , m_shouldStopTracing(false)
+ , m_layerTreeId(0)
+{
+}
+
+void InspectorTracingAgent::setFrontend(InspectorFrontend* frontend)
+{
+ m_frontend = frontend->tracing();
+}
+
+void InspectorTracingAgent::clearFrontend()
+{
+ ErrorString unused;
+ disable(&unused);
+ m_frontend = 0;
+}
+
+void InspectorTracingAgent::restore()
+{
+ emitMetadataEvents();
+}
+
+void InspectorTracingAgent::enable(ErrorString*, const String& categoryFilter)
+{
+ m_state->setBoolean(TracingAgentState::enabled, true);
+ m_state->setString(TracingAgentState::tracingCategoryFilter, categoryFilter);
+}
+
+void InspectorTracingAgent::disable(ErrorString*)
+{
+ m_state->setBoolean(TracingAgentState::enabled, false);
+}
+
+void InspectorTracingAgent::start(ErrorString*, const String&, const String&, const double*, String* outSessionId)
+{
+ innerStart();
+ *outSessionId = sessionId();
+}
+
+void InspectorTracingAgent::startFromBackend()
+{
+ if (!m_state->getBoolean(TracingAgentState::enabled)) {
+ m_shouldStopTracing = false;
+ return;
+ }
+ m_shouldStopTracing = true;
+ String tracingCategoryFilter = m_state->getString(TracingAgentState::tracingCategoryFilter);
+ m_client->enableTracing(tracingCategoryFilter);
+ innerStart();
+}
+
+void InspectorTracingAgent::endFromBackend()
+{
+ if (!m_shouldStopTracing)
+ return;
+ m_shouldStopTracing = true;
+ m_client->disableTracing();
+}
+
+
+void InspectorTracingAgent::innerStart()
+{
+ String sessionId = IdentifiersFactory::createIdentifier();
+ m_state->setString(TracingAgentState::sessionId, sessionId);
+ emitMetadataEvents();
+}
+
+String InspectorTracingAgent::sessionId()
+{
+ return m_state->getString(TracingAgentState::sessionId);
+}
+
+const char devtoolsMetadataEventCategory[] = TRACE_DISABLED_BY_DEFAULT("devtools.timeline");
yurys 2014/04/25 09:13:00 Please move this into anonymous namespace at the t
+
+void InspectorTracingAgent::emitMetadataEvents()
+{
+ TRACE_EVENT_INSTANT1(devtoolsMetadataEventCategory, "TracingStartedInPage", "sessionId", sessionId().utf8());
+ if (m_layerTreeId)
+ setLayerTreeId(m_layerTreeId);
+}
+
+void InspectorTracingAgent::setLayerTreeId(int layerTreeId)
+{
+ m_layerTreeId = layerTreeId;
+ TRACE_EVENT_INSTANT2(devtoolsMetadataEventCategory, "SetLayerTreeId", "sessionId", sessionId().utf8(), "layerTreeId", m_layerTreeId);
+}
+
+}
« no previous file with comments | « Source/core/inspector/InspectorTracingAgent.h ('k') | Source/core/inspector/WorkerInspectorController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698