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

Unified Diff: telemetry/telemetry/internal/backends/chrome_inspector/tracing_backend.py

Issue 2160953003: [Telemetry][Tracing] Split StopTracing and CollectTraceData for Chrome Tracing Agent. (Closed) Base URL: git@github.com:catapult-project/catapult@master
Patch Set: fix failing tests and zhenw comments Created 4 years, 5 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: telemetry/telemetry/internal/backends/chrome_inspector/tracing_backend.py
diff --git a/telemetry/telemetry/internal/backends/chrome_inspector/tracing_backend.py b/telemetry/telemetry/internal/backends/chrome_inspector/tracing_backend.py
index 9da3e707307fd4b38f4fa2c5184102cf672daa2d..7b18fadd7396231abf7274767c1786014521937b 100644
--- a/telemetry/telemetry/internal/backends/chrome_inspector/tracing_backend.py
+++ b/telemetry/telemetry/internal/backends/chrome_inspector/tracing_backend.py
@@ -96,6 +96,8 @@ class TracingBackend(object):
self._has_received_all_tracing_data = False
self._support_modern_devtools_tracing_start_api = (
support_modern_devtools_tracing_start_api)
+ self._is_collecting = False
+ self._can_collect = False
Zhen Wang 2016/07/21 19:45:19 Can we combine those two? We should not allow new
rnephew (Reviews Here) 2016/07/21 19:55:20 Done.
@property
def is_tracing_running(self):
@@ -106,7 +108,7 @@ class TracingBackend(object):
If called during tracing, tracing is unchanged, and it returns False.
"""
- if self.is_tracing_running:
+ if self.is_tracing_running or self._is_collecting:
return False
# Reset collected tracing data from previous tracing calls.
self._trace_events = []
@@ -151,7 +153,7 @@ class TracingBackend(object):
if 'error' in rc:
raise ClockSyncResponseException(rc['error']['message'])
- def StopTracing(self, trace_data_builder, timeout=30):
+ def StopTracing(self):
"""Stops tracing and pushes results to the supplied TraceDataBuilder.
If this is called after tracing has been stopped, trace data from the last
@@ -163,13 +165,9 @@ class TracingBackend(object):
else:
req = {'method': 'Tracing.end'}
self._inspector_websocket.SendAndIgnoreResponse(req)
- # After Tracing.end, chrome browser will send asynchronous notifications
- # containing trace data. This is until Tracing.tracingComplete is sent,
- # which means there is no trace buffers pending flush.
- self._CollectTracingData(timeout)
+
self._is_tracing_running = False
- trace_data_builder.AddEventsTo(
- trace_data_module.CHROME_TRACE_PART, self._trace_events)
+ self._can_collect = True
def DumpMemory(self, timeout=30):
"""Dumps memory.
@@ -211,6 +209,16 @@ class TracingBackend(object):
result = response['result']
return result['dumpGuid'] if result['success'] else None
+ def CollectTraceData(self, trace_data_builder, timeout=30):
+ if not self._can_collect:
+ raise Exception('Cannot collect before tracing is finished.')
+ self._can_collect = False
+ self._is_collecting = True
+ self._CollectTracingData(timeout)
+ self._is_collecting = False
+ trace_data_builder.AddEventsTo(
+ trace_data_module.CHROME_TRACE_PART, self._trace_events)
+
def _CollectTracingData(self, timeout):
"""Collects tracing data. Assumes that Tracing.end has already been sent.

Powered by Google App Engine
This is Rietveld 408576698