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 Start(self, page, tab): | 24 def SetUp(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): |
39 # Start the smooth marker for all actions. | 41 # Start the smooth marker for all actions. |
40 runner = action_runner.ActionRunner(tab) | 42 runner = action_runner.ActionRunner(tab) |
41 self._interaction = runner.BeginInteraction( | 43 self._interaction = runner.BeginInteraction( |
42 RUN_SMOOTH_ACTIONS, is_smooth=True) | 44 RUN_SMOOTH_ACTIONS, is_smooth=True) |
43 | 45 |
44 def Stop(self, tab): | 46 def Stop(self, tab): |
45 # End the smooth marker for all actions. | 47 # End the smooth marker for all actions. |
46 self._interaction.End() | 48 self._interaction.End() |
47 # Stop tracing. | 49 # Stop tracing. |
48 timeline_data = tab.browser.StopTracing() | 50 timeline_data = tab.browser.StopTracing() |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 def model(self): | 84 def model(self): |
83 return self._model | 85 return self._model |
84 | 86 |
85 @property | 87 @property |
86 def renderer_process(self): | 88 def renderer_process(self): |
87 return self._renderer_process | 89 return self._renderer_process |
88 | 90 |
89 @property | 91 @property |
90 def smooth_records(self): | 92 def smooth_records(self): |
91 return self._smooth_records | 93 return self._smooth_records |
OLD | NEW |