Chromium Code Reviews| Index: telemetry/telemetry/internal/platform/tracing_agent/chrome_tracing_agent.py |
| diff --git a/telemetry/telemetry/internal/platform/tracing_agent/chrome_tracing_agent.py b/telemetry/telemetry/internal/platform/tracing_agent/chrome_tracing_agent.py |
| index f20e847ab5a40dc1ed6f0fde8afd76cba8cca120..8e8426e902a66cf0bb6ee304d996697a9c1294d2 100644 |
| --- a/telemetry/telemetry/internal/platform/tracing_agent/chrome_tracing_agent.py |
| +++ b/telemetry/telemetry/internal/platform/tracing_agent/chrome_tracing_agent.py |
| @@ -52,6 +52,7 @@ class ChromeTracingAgent(tracing_agent.TracingAgent): |
| super(ChromeTracingAgent, self).__init__(platform_backend) |
| self._trace_config = None |
| self._trace_config_file = None |
| + self._previously_responsive_devtools = [] |
| @property |
| def trace_config(self): |
| @@ -183,12 +184,6 @@ class ChromeTracingAgent(tracing_agent.TracingAgent): |
| sync_id, record_controller_clock_sync_marker_callback) |
| def StopAgentTracing(self): |
| - # TODO: Split collection and stopping. |
| - pass |
| - |
| - def CollectAgentTraceData(self, trace_data_builder, timeout=None): |
| - # TODO: Move stopping to StopAgentTracing. |
| - del timeout # Unused. |
| if not self._trace_config: |
| raise ChromeTracingStoppedError( |
| 'Tracing is not running on platform backend %s.' |
| @@ -205,7 +200,9 @@ class ChromeTracingAgent(tracing_agent.TracingAgent): |
| raised_exception_messages = [] |
| for client in devtools_clients: |
|
Zhen Wang
2016/07/21 19:45:19
Probably assert self._previously_responsive_devtoo
rnephew (Reviews Here)
2016/07/21 19:55:20
Done.
|
| try: |
| - client.StopChromeTracing(trace_data_builder) |
| + client.StopChromeTracing() |
| + self._previously_responsive_devtools.append(client) |
| + |
| except Exception: |
| raised_exception_messages.append( |
| 'Error when trying to stop Chrome tracing on devtools at port %s:\n%s' |
| @@ -222,6 +219,23 @@ class ChromeTracingAgent(tracing_agent.TracingAgent): |
| 'Exceptions raised when trying to stop Chrome devtool tracing:\n' + |
| '\n'.join(raised_exception_messages)) |
| + def CollectAgentTraceData(self, trace_data_builder, timeout=None): |
| + raised_exception_messages = [] |
| + for client in self._previously_responsive_devtools: |
| + try: |
| + client.CollectChromeTracingData(trace_data_builder) |
| + except Exception: |
| + raised_exception_messages.append( |
| + 'Error when collecting Chrome tracing on devtools at port %s:\n%s' |
| + % (client.remote_port, |
| + ''.join(traceback.format_exception(*sys.exc_info())))) |
| + |
| + if raised_exception_messages: |
| + raise ChromeTracingStoppedError( |
| + 'Exceptions raised when trying to collect Chrome devtool tracing:\n' + |
| + '\n'.join(raised_exception_messages)) |
| + self._previously_responsive_devtools = [] |
| + |
| def _CreateTraceConfigFileString(self, config): |
| # See src/components/tracing/trace_config_file.h for the format |
| result = { |