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

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

Issue 441873007: Move timeline and importers to use telemetry.value.TraceValue (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/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 5b285151eecb8ef4f772540080ac470931f53b3f..7998954b0161310cdee93a176bd467c03379eb77 100644
--- a/tools/telemetry/telemetry/core/backends/chrome/tracing_backend.py
+++ b/tools/telemetry/telemetry/core/backends/chrome/tracing_backend.py
@@ -26,7 +26,7 @@ class TracingBackend(object):
'ws://127.0.0.1:%i/devtools/browser' % devtools_port)
self._category_filter = None
self._nesting = 0
- self._tracing_data = []
+ self._trace_events = []
self._is_tracing_running = False
@property
@@ -57,10 +57,11 @@ class TracingBackend(object):
self._is_tracing_running = True
return True
- def StopTracing(self, timeout=30):
- """ Stops tracing on the innermost (!) nested call, because we cannot get
- results otherwise. Resets _tracing_data on the outermost nested call.
- Returns the result of the trace, as TracingTimelineData object.
+ def StopTracing(self, trace_value_builder, timeout=30):
+ """ Stops tracing and pushes reults to the provided TraceValueBuilder.
+
+ Tracing is stopped on the innermost (!) nested call, because we cannot get
+ results otherwise. Resets _trace_events on the outermost nested call.
"""
self._nesting -= 1
assert self._nesting >= 0
@@ -80,21 +81,13 @@ 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
- if self._nesting == 0:
- self._category_filter = None
- return self._GetTraceResultAndReset()
- else:
- return self._GetTraceResult()
- def _GetTraceResult(self):
- assert not self.is_tracing_running
- return self._tracing_data
+ trace_value_builder.AddEventsTo(
+ trace_value_module.CHROME_TRACE_PART, self._trace_events)
- def _GetTraceResultAndReset(self):
- result = self._GetTraceResult()
-
- self._tracing_data = []
- return result
+ if self._nesting == 0:
+ self._category_filter = None
+ self._trace_events = []
def _ErrorHandler(self, elapsed):
logging.error('Unrecoverable error after %ds reading tracing response.',
@@ -105,9 +98,9 @@ class TracingBackend(object):
if 'Tracing.dataCollected' == res.get('method'):
value = res.get('params', {}).get('value')
if type(value) in [str, unicode]:
- self._tracing_data.append(value)
+ self._trace_events.append(value)
elif type(value) is list:
- self._tracing_data.extend(value)
+ self._trace_events.extend(value)
else:
logging.warning('Unexpected type in tracing data')
elif 'Tracing.tracingComplete' == res.get('method'):

Powered by Google App Engine
This is Rietveld 408576698