Commit 85a4227e authored by loislo@chromium.org's avatar loislo@chromium.org

Telemetry: make InspectorTimeline backward compatible with upcoming changes in DevTools protocol.

I'm moving events parameter from the results of Timeline.stop command to Timeline.stopped event.

BUG=394780

Review URL: https://codereview.chromium.org/399943002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284035 0039d316-1c4b-4281-b951-d872f2087c98
parent 93b1f7dc
...@@ -37,6 +37,7 @@ class InspectorTimeline(timeline_recorder.TimelineRecorder): ...@@ -37,6 +37,7 @@ class InspectorTimeline(timeline_recorder.TimelineRecorder):
super(InspectorTimeline, self).__init__() super(InspectorTimeline, self).__init__()
self._inspector_backend = inspector_backend self._inspector_backend = inspector_backend
self._is_recording = False self._is_recording = False
self._raw_events = None
@property @property
def is_timeline_recording_running(self): def is_timeline_recording_running(self):
...@@ -45,6 +46,7 @@ class InspectorTimeline(timeline_recorder.TimelineRecorder): ...@@ -45,6 +46,7 @@ class InspectorTimeline(timeline_recorder.TimelineRecorder):
def Start(self): def Start(self):
"""Starts recording.""" """Starts recording."""
assert not self._is_recording, 'Start should only be called once.' assert not self._is_recording, 'Start should only be called once.'
self._raw_events = None
self._is_recording = True self._is_recording = True
self._inspector_backend.RegisterDomain( self._inspector_backend.RegisterDomain(
'Timeline', self._OnNotification, self._OnClose) 'Timeline', self._OnNotification, self._OnClose)
...@@ -66,7 +68,13 @@ class InspectorTimeline(timeline_recorder.TimelineRecorder): ...@@ -66,7 +68,13 @@ class InspectorTimeline(timeline_recorder.TimelineRecorder):
self._inspector_backend.UnregisterDomain('Timeline') self._inspector_backend.UnregisterDomain('Timeline')
self._is_recording = False 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) return inspector_timeline_data.InspectorTimelineData(raw_events)
def _SendSyncRequest(self, request, timeout=60): def _SendSyncRequest(self, request, timeout=60):
...@@ -93,8 +101,9 @@ class InspectorTimeline(timeline_recorder.TimelineRecorder): ...@@ -93,8 +101,9 @@ class InspectorTimeline(timeline_recorder.TimelineRecorder):
def _OnNotification(self, msg): def _OnNotification(self, msg):
"""Handler called when a message is received.""" """Handler called when a message is received."""
# Since 'Timeline.start' was invoked with the 'bufferEvents' parameter, # Since 'Timeline.start' was invoked with the 'bufferEvents' parameter,
# there will be no timeline notifications while recording. # the events will arrive in Timeline.stopped event.
pass if msg['method'] == 'Timeline.stopped' and 'events' in msg['params']:
self._raw_events = msg['params']['events']
def _OnClose(self): def _OnClose(self):
"""Handler called when a domain is unregistered.""" """Handler called when a domain is unregistered."""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment