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

Unified Diff: tools/telemetry/telemetry/core/platform/tracing_controller_backend.py

Issue 414253004: Introduce TracingController and TracingControllerBackend skeleton (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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: tools/telemetry/telemetry/core/platform/tracing_controller_backend.py
diff --git a/tools/telemetry/telemetry/core/platform/tracing_controller_backend.py b/tools/telemetry/telemetry/core/platform/tracing_controller_backend.py
new file mode 100644
index 0000000000000000000000000000000000000000..83ddb7b9724ae49ddb20049ed0558e15ad8e3a2d
--- /dev/null
+++ b/tools/telemetry/telemetry/core/platform/tracing_controller_backend.py
@@ -0,0 +1,71 @@
+# 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.
+
+from telemetry.core.platform import tracing_category_filter
+from telemetry.core.platform import tracing_options
+
+
+class TracingControllerBackend(object):
+ def __init__(self, platform_backend):
+ self._platform_backend = platform_backend
+ self._is_tracing = False
+
+ def Start(self, category_filter, trace_options, timeout):
+ if self._is_tracing:
+ return False
+
+ assert isinstance(category_filter,
+ tracing_category_filter.TracingCategoryFilter)
+ assert isinstance(trace_options,
+ tracing_options.TracingOptions)
+
+ if len(self._running_browser_backends) != 1:
+ # Note: it is possible to implement tracing for both the case of 0 and >1.
+ # For >1, we just need to merge the trace files at StopTracing.
+ #
+ # For 0, we want to modify chrome's trace-startup to support leaving
+ # tracing on indefinitely. Then have the backend notify the platform
+ # and the tracing controller that it is starting a browser, have
+ # the controller add in the trace-startup command, and then when we get
+ # the Stop message or the DidStopBrowser(), issue the stop tracing command
+ # on the right backend.
+ raise NotImplementedError()
+
+ browser_backend = self._running_browser_backends[0]
+ browser_backend.StartTracing(
+ category_filter.filter_string, timeout)
+ self._is_tracing = True
+
+ def Stop(self):
+ if len(self._running_browser_backends) != 1:
+ raise NotImplementedError()
+
+ browser_backend = self._running_browser_backends[0]
+ result = browser_backend.StopTracing()
+ self._is_tracing = False
+ return result
+
+ def AreOptionsSupported(self, trace_options):
+ if len(self._running_browser_backends) != 1:
+ raise NotImplementedError()
+ browser_backend = self._running_browser_backends[0]
+
+ supported = True
+ if trace_options.enable_chrome_trace:
+ supported &= browser_backend.supports_tracing
+ return supported
+
+ @property
+ def is_tracing_running(self):
+ return self._is_tracing
+
+ @property
+ def _running_browser_backends(self):
+ return self._platform_backend.running_browsers_and_backends.values()
nednguyen 2014/08/04 22:12:06 Should we add a DidCreateBrowser(self, browser, br
+
+ def DidStartBrowser(self, browser, browser_backend):
+ pass
+
+ def WillCloseBrowser(self, browser, browser_backend):
+ pass

Powered by Google App Engine
This is Rietveld 408576698