| 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 |
| 11 | 11 |
| 12 RUN_SMOOTH_ACTIONS = 'RunSmoothAllActions' | 12 RUN_SMOOTH_ACTIONS = 'RunSmoothAllActions' |
| 13 | 13 |
| 14 | 14 |
| 15 class TimelineController(object): | 15 class TimelineController(object): |
| 16 def __init__(self): | 16 def __init__(self): |
| 17 super(TimelineController, self).__init__() | 17 super(TimelineController, self).__init__() |
| 18 self.trace_categories = tracing_backend.DEFAULT_TRACE_CATEGORIES | 18 self.trace_categories = tracing_backend.DEFAULT_TRACE_CATEGORIES |
| 19 self._model = None | 19 self._model = None |
| 20 self._renderer_process = None | 20 self._renderer_process = None |
| 21 self._smooth_records = [] | 21 self._smooth_records = [] |
| 22 self._interaction = None | 22 self._interaction = None |
| 23 | 23 |
| 24 def SetUp(self, page, tab): | 24 def Start(self, page, tab): |
| 25 """Starts gathering timeline data. | 25 """Starts gathering timeline data. |
| 26 | 26 |
| 27 """ | 27 """ |
| 28 # Resets these member variables incase this object is reused. | 28 # Resets these member variables incase this object is reused. |
| 29 self._model = None | 29 self._model = None |
| 30 self._renderer_process = None | 30 self._renderer_process = None |
| 31 if not tab.browser.supports_tracing: | 31 if not tab.browser.supports_tracing: |
| 32 raise Exception('Not supported') | 32 raise Exception('Not supported') |
| 33 if self.trace_categories: | 33 if self.trace_categories: |
| 34 categories = [self.trace_categories] + \ | 34 categories = [self.trace_categories] + \ |
| 35 page.GetSyntheticDelayCategories() | 35 page.GetSyntheticDelayCategories() |
| 36 else: | 36 else: |
| 37 categories = page.GetSyntheticDelayCategories() | 37 categories = page.GetSyntheticDelayCategories() |
| 38 tab.browser.StartTracing(','.join(categories)) | 38 tab.browser.StartTracing(','.join(categories)) |
| 39 | |
| 40 def Start(self, tab): | |
| 41 # Start the smooth marker for all actions. | 39 # Start the smooth marker for all actions. |
| 42 runner = action_runner.ActionRunner(tab) | 40 runner = action_runner.ActionRunner(tab) |
| 43 self._interaction = runner.BeginInteraction( | 41 self._interaction = runner.BeginInteraction( |
| 44 RUN_SMOOTH_ACTIONS, is_smooth=True) | 42 RUN_SMOOTH_ACTIONS, is_smooth=True) |
| 45 | 43 |
| 46 def Stop(self, tab): | 44 def Stop(self, tab): |
| 47 # End the smooth marker for all actions. | 45 # End the smooth marker for all actions. |
| 48 self._interaction.End() | 46 self._interaction.End() |
| 49 # Stop tracing. | 47 # Stop tracing. |
| 50 timeline_data = tab.browser.StopTracing() | 48 timeline_data = tab.browser.StopTracing() |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 def model(self): | 82 def model(self): |
| 85 return self._model | 83 return self._model |
| 86 | 84 |
| 87 @property | 85 @property |
| 88 def renderer_process(self): | 86 def renderer_process(self): |
| 89 return self._renderer_process | 87 return self._renderer_process |
| 90 | 88 |
| 91 @property | 89 @property |
| 92 def smooth_records(self): | 90 def smooth_records(self): |
| 93 return self._smooth_records | 91 return self._smooth_records |
| OLD | NEW |