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

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

Issue 842303002: Remove Telemetry's Chrome tracing dependency on having a BrowserBackend. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add doc. Created 5 years, 11 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 | « tools/telemetry/telemetry/core/backends/chrome_inspector/devtools_client_backend_unittest.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
index d566320db5cc47ec9ae509350c79e5bbc5182165..f8aa1024753292c1386777842d8ce8caa0834266 100644
--- a/tools/telemetry/telemetry/core/platform/tracing_controller_backend.py
+++ b/tools/telemetry/telemetry/core/platform/tracing_controller_backend.py
@@ -12,6 +12,10 @@ class TracingControllerBackend(object):
self._platform_backend = platform_backend
self._current_trace_options = None
self._current_category_filter = None
+ # A map from uniquely-identifying remote port (which may be the
+ # same as local port) to DevToolsClientBackend. There is no
+ # guarantee that the devtools agent is still alive.
+ self._devtools_clients_map = {}
def Start(self, trace_options, category_filter, timeout):
if self.is_tracing_running:
@@ -22,27 +26,36 @@ class TracingControllerBackend(object):
assert isinstance(trace_options,
tracing_options.TracingOptions)
- self._AssertOneBrowserBackend()
-
self._current_trace_options = trace_options
self._current_category_filter = category_filter
if trace_options.enable_chrome_trace:
- browser_backend = self.running_browser_backends[0]
- browser_backend.StartTracing(
- trace_options, category_filter.filter_string, timeout)
+ self._RemoveStaleDevToolsClient()
+ for _, devtools_client in self._devtools_clients_map.iteritems():
+ devtools_client.StartChromeTracing(
+ trace_options, category_filter.filter_string, timeout)
if trace_options.enable_platform_display_trace:
self._platform_backend.StartDisplayTracing()
+ def _RemoveStaleDevToolsClient(self):
+ """Removes DevTools clients that are no longer connectable."""
+ self._devtools_clients_map = {
+ port: client
+ for port, client in self._devtools_clients_map.iteritems()
+ if client.IsAlive()
+ }
+
def Stop(self):
assert self.is_tracing_running, 'Can only stop tracing when tracing.'
- self._AssertOneBrowserBackend()
trace_data_builder = trace_data_module.TraceDataBuilder()
if self._current_trace_options.enable_chrome_trace:
- browser_backend = self.running_browser_backends[0]
- browser_backend.StopTracing(trace_data_builder)
+ for _, devtools_client in self._devtools_clients_map.iteritems():
+ # We do not check for stale DevTools client, so that we get an
+ # exception if there is a stale client. This is because we
+ # will potentially lose data if there is a stale client.
+ devtools_client.StopChromeTracing(trace_data_builder)
if self._current_trace_options.enable_platform_display_trace:
surface_flinger_trace_data = self._platform_backend.StopDisplayTracing()
@@ -53,24 +66,18 @@ class TracingControllerBackend(object):
self._current_category_filter = None
return trace_data_builder.AsData()
- def _AssertOneBrowserBackend(self):
- # 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.
- num_instances = len(self.running_browser_backends)
- assert num_instances == 1, (
- 'Tracing only supports one browser instance (not %i).' % num_instances)
+ def RegisterDevToolsClient(self, devtools_client_backend):
+ assert not self.is_tracing_running, (
+ 'Cannot add new DevTools client when tracing is running.')
+ remote_port = str(devtools_client_backend.remote_port)
+ self._devtools_clients_map[remote_port] = devtools_client_backend
def IsChromeTracingSupported(self):
- self._AssertOneBrowserBackend()
- browser_backend = self.running_browser_backends[0]
- return browser_backend.devtools_client.IsChromeTracingSupported()
+ self._RemoveStaleDevToolsClient()
+ for _, devtools_client in self._devtools_clients_map.iteritems():
+ if devtools_client.IsChromeTracingSupported():
+ return True
+ return False
def IsDisplayTracingSupported(self):
return self._platform_backend.IsDisplayTracingSupported()
@@ -79,10 +86,6 @@ class TracingControllerBackend(object):
def is_tracing_running(self):
return self._current_trace_options != None
- @property
- def running_browser_backends(self):
- return self._platform_backend.running_browser_backends
-
def DidStartBrowser(self, browser, browser_backend):
nednguyen 2015/01/13 16:12:00 Kill these methods?
pass
« no previous file with comments | « tools/telemetry/telemetry/core/backends/chrome_inspector/devtools_client_backend_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698