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

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

Issue 399943002: Telemetry: make InspectorTimeline backward compatible with upcoming changes in DevTools protocol. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments addressed Created 6 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
« 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/inspector_timeline.py
diff --git a/tools/telemetry/telemetry/core/backends/chrome/inspector_timeline.py b/tools/telemetry/telemetry/core/backends/chrome/inspector_timeline.py
index da362633554b4c85f46f4e264978402c1a54c768..c4a240a06a7d02210a1cd6ca47e223c51b33281c 100644
--- a/tools/telemetry/telemetry/core/backends/chrome/inspector_timeline.py
+++ b/tools/telemetry/telemetry/core/backends/chrome/inspector_timeline.py
@@ -37,6 +37,7 @@ class InspectorTimeline(timeline_recorder.TimelineRecorder):
super(InspectorTimeline, self).__init__()
self._inspector_backend = inspector_backend
self._is_recording = False
+ self._raw_events = None
@property
def is_timeline_recording_running(self):
@@ -45,6 +46,7 @@ class InspectorTimeline(timeline_recorder.TimelineRecorder):
def Start(self):
"""Starts recording."""
assert not self._is_recording, 'Start should only be called once.'
+ self._raw_events = None
self._is_recording = True
self._inspector_backend.RegisterDomain(
'Timeline', self._OnNotification, self._OnClose)
@@ -66,7 +68,13 @@ class InspectorTimeline(timeline_recorder.TimelineRecorder):
self._inspector_backend.UnregisterDomain('Timeline')
self._is_recording = False
- raw_events = result['events']
+ # TODO: Backward compatibility. Needs to be removed when
+ # M38 becomes stable.
+ if 'events' in result:
+ raw_events = result['events']
+ else: # In M38 events will arrive via Timeline.stopped event.
+ raw_events = self._raw_events
+ self._raw_events = None
return inspector_timeline_data.InspectorTimelineData(raw_events)
def _SendSyncRequest(self, request, timeout=60):
@@ -93,8 +101,9 @@ class InspectorTimeline(timeline_recorder.TimelineRecorder):
def _OnNotification(self, msg):
"""Handler called when a message is received."""
# Since 'Timeline.start' was invoked with the 'bufferEvents' parameter,
- # there will be no timeline notifications while recording.
- pass
+ # the events will arrive in Timeline.stopped event.
+ if msg['method'] == 'Timeline.stopped' and 'events' in msg['params']:
+ self._raw_events = msg['params']['events']
def _OnClose(self):
"""Handler called when a domain is unregistered."""
« 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