| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 from measurements import smooth_gesture_util | 4 from measurements import smooth_gesture_util |
| 5 | 5 |
| 6 from telemetry.core.backends.chrome import tracing_backend | 6 from telemetry.core.backends.chrome import tracing_backend |
| 7 from telemetry.timeline.model import TimelineModel | 7 from telemetry.timeline.model import TimelineModel |
| 8 from telemetry.page.actions import action_runner | 8 from telemetry.page.actions import action_runner |
| 9 from telemetry.web_perf import timeline_interaction_record as tir_module | 9 from telemetry.web_perf import timeline_interaction_record as tir_module |
| 10 | 10 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 runner = action_runner.ActionRunner(tab) | 42 runner = action_runner.ActionRunner(tab) |
| 43 self._interaction = runner.BeginInteraction( | 43 self._interaction = runner.BeginInteraction( |
| 44 RUN_SMOOTH_ACTIONS, is_smooth=True) | 44 RUN_SMOOTH_ACTIONS, is_smooth=True) |
| 45 | 45 |
| 46 def Stop(self, tab): | 46 def Stop(self, tab): |
| 47 # End the smooth marker for all actions. | 47 # End the smooth marker for all actions. |
| 48 self._interaction.End() | 48 self._interaction.End() |
| 49 # Stop tracing. | 49 # Stop tracing. |
| 50 timeline_data = tab.browser.StopTracing() | 50 timeline_data = tab.browser.StopTracing() |
| 51 self._model = TimelineModel(timeline_data) | 51 self._model = TimelineModel(timeline_data) |
| 52 self._renderer_process = self._model.GetRendererProcessFromTabId(tab.id) | 52 threads_to_records_map = ( |
| 53 renderer_thread = self.model.GetRendererThreadFromTabId(tab.id) | 53 tir_module.GetThreadToInteractionRecordsMapsFromModel( |
| 54 | 54 self._model)) |
| 55 assert len(threads_to_records_map) == 1, ( |
| 56 'timeline metrics only support interaction records issued from' |
| 57 'a single thread.') |
| 58 renderer_thread = threads_to_records_map.keys()[0] |
| 59 interaction_records = threads_to_records_map.values()[0] |
| 60 self._renderer_process = renderer_thread.parent |
| 55 run_smooth_actions_record = None | 61 run_smooth_actions_record = None |
| 56 self._smooth_records = [] | 62 self._smooth_records = [] |
| 57 for event in renderer_thread.async_slices: | 63 for r in interaction_records: |
| 58 if not tir_module.IsTimelineInteractionRecord(event.name): | |
| 59 continue | |
| 60 r = tir_module.TimelineInteractionRecord.FromAsyncEvent(event) | |
| 61 if r.label == RUN_SMOOTH_ACTIONS: | 64 if r.label == RUN_SMOOTH_ACTIONS: |
| 62 assert run_smooth_actions_record is None, ( | 65 assert run_smooth_actions_record is None, ( |
| 63 'TimelineController cannot issue more than 1 %s record' % | 66 'TimelineController cannot issue more than 1 %s record' % |
| 64 RUN_SMOOTH_ACTIONS) | 67 RUN_SMOOTH_ACTIONS) |
| 65 run_smooth_actions_record = r | 68 run_smooth_actions_record = r |
| 66 elif r.is_smooth: | 69 elif r.is_smooth: |
| 67 self._smooth_records.append( | 70 self._smooth_records.append( |
| 68 smooth_gesture_util.GetAdjustedInteractionIfContainGesture( | 71 smooth_gesture_util.GetAdjustedInteractionIfContainGesture( |
| 69 self.model, r)) | 72 self.model, r)) |
| 70 | 73 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 84 def model(self): | 87 def model(self): |
| 85 return self._model | 88 return self._model |
| 86 | 89 |
| 87 @property | 90 @property |
| 88 def renderer_process(self): | 91 def renderer_process(self): |
| 89 return self._renderer_process | 92 return self._renderer_process |
| 90 | 93 |
| 91 @property | 94 @property |
| 92 def smooth_records(self): | 95 def smooth_records(self): |
| 93 return self._smooth_records | 96 return self._smooth_records |
| OLD | NEW |