| 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 4d0c68a8a3edb617314407f60d0a8624407e4a14..b367e96504406907fac53d84c8366364c5ad949b 100644
|
| --- a/tools/telemetry/telemetry/core/backends/chrome/tracing_backend.py
|
| +++ b/tools/telemetry/telemetry/core/backends/chrome/tracing_backend.py
|
| @@ -72,6 +72,9 @@ class TracingBackend(object):
|
| self._thread = None
|
| self._tracing_data = []
|
|
|
| + def _IsTracing(self):
|
| + return self._thread != None
|
| +
|
| def BeginTracing(self, custom_categories=None, timeout=10):
|
| self._CheckNotificationSupported()
|
| req = {'method': 'Tracing.start'}
|
| @@ -84,20 +87,26 @@ class TracingBackend(object):
|
| self._thread.start()
|
|
|
| def EndTracing(self):
|
| + if not self._IsTracing():
|
| + return
|
| req = {'method': 'Tracing.end'}
|
| self._conn.SendRequest(req)
|
| self._thread.join()
|
| self._thread = None
|
|
|
| - def GetTraceResultAndReset(self):
|
| + def GetTraceResult(self):
|
| assert not self._thread
|
| if self._tracing_data and type(self._tracing_data[0]) in [str, unicode]:
|
| result_impl = TraceResultImpl(self._tracing_data)
|
| else:
|
| result_impl = RawTraceResultImpl(self._tracing_data)
|
| - self._tracing_data = []
|
| return trace_result.TraceResult(result_impl)
|
|
|
| + def GetTraceResultAndReset(self):
|
| + result = self.GetTraceResult()
|
| + self._tracing_data = []
|
| + return result
|
| +
|
| def _TracingReader(self):
|
| while self._conn.socket:
|
| try:
|
|
|