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

Unified Diff: tools/telemetry/telemetry/core/backends/chrome/tracing_backend.py

Issue 642453004: [Telemetry] Change TracingBackend.Stop to return the trace data from last tracing run. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/core/backends/chrome/tracing_backend.py
diff --git a/tools/telemetry/telemetry/core/backends/chrome/tracing_backend.py b/tools/telemetry/telemetry/core/backends/chrome/tracing_backend.py
index 14f39c473a4742dfca255f609a951dcdb3f96a1a..ad63ef309b139e45bba2af867e9f0e95c0169290 100644
--- a/tools/telemetry/telemetry/core/backends/chrome/tracing_backend.py
+++ b/tools/telemetry/telemetry/core/backends/chrome/tracing_backend.py
@@ -15,7 +15,7 @@ class TracingUnsupportedException(Exception):
class TracingTimeoutException(Exception):
pass
-class TracingNotRunningException(Exception):
+class TracingHasNotRunException(Exception):
pass
@@ -41,6 +41,8 @@ class TracingBackend(object):
"""
if self.is_tracing_running:
return False
+ # Reset collected tracing data from previous tracing calls.
+ self._tracing_data = []
self._CheckNotificationSupported()
#TODO(nednguyen): remove this when the stable branch pass 2118.
if (trace_options.record_mode == tracing_options.RECORD_AS_MUCH_AS_POSSIBLE
@@ -67,10 +69,14 @@ class TracingBackend(object):
def StopTracing(self, timeout=30):
""" Stops tracing and returns the raw json trace result. It this is called
- after tracing has been stopped, empty trace data is returned.
+ after tracing has been stopped, trace data from the last tracing run is
+ returned.
"""
if not self.is_tracing_running:
- raise TracingNotRunningException()
+ if not self._tracing_data:
+ raise TracingHasNotRunException()
+ else:
+ return self._tracing_data
req = {'method': 'Tracing.end'}
self._inspector_websocket.SendAndIgnoreResponse(req)
# After Tracing.end, chrome browser will send asynchronous notifications
@@ -86,12 +92,7 @@ class TracingBackend(object):
'seconds. If the trace data is big, you may want to increase the '
'time out amount.' % err.elapsed_time)
self._is_tracing_running = False
- return self._GetTraceResultAndReset()
-
- def _GetTraceResultAndReset(self):
- result = self._tracing_data
- self._tracing_data = []
- return result
+ return self._tracing_data
def _ErrorHandler(self, elapsed):
logging.error('Unrecoverable error after %ds reading tracing response.',
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698