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

Side by Side Diff: tools/telemetry/telemetry/page/actions/action_runner.py

Issue 386023004: Cleanup while reading code: Move GetJavaScriptMarker to be a free function instead of static functi… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix tests. 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 unified diff | Download patch
OLDNEW
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 4
5 import time 5 import time
6 6
7 from telemetry.page.actions.javascript_click import ClickElementAction 7 from telemetry.page.actions.javascript_click import ClickElementAction
8 from telemetry.page.actions.loop import LoopAction 8 from telemetry.page.actions.loop import LoopAction
9 from telemetry.page.actions.navigate import NavigateAction 9 from telemetry.page.actions.navigate import NavigateAction
10 from telemetry.page.actions.pinch import PinchAction 10 from telemetry.page.actions.pinch import PinchAction
11 from telemetry.page.actions.play import PlayAction 11 from telemetry.page.actions.play import PlayAction
12 from telemetry.page.actions.repaint_continuously import ( 12 from telemetry.page.actions.repaint_continuously import (
13 RepaintContinuouslyAction) 13 RepaintContinuouslyAction)
14 from telemetry.page.actions.scroll import ScrollAction 14 from telemetry.page.actions.scroll import ScrollAction
15 from telemetry.page.actions.scroll_bounce import ScrollBounceAction 15 from telemetry.page.actions.scroll_bounce import ScrollBounceAction
16 from telemetry.page.actions.seek import SeekAction 16 from telemetry.page.actions.seek import SeekAction
17 from telemetry.page.actions.swipe import SwipeAction 17 from telemetry.page.actions.swipe import SwipeAction
18 from telemetry.page.actions.tap import TapAction 18 from telemetry.page.actions.tap import TapAction
19 from telemetry.page.actions.wait import WaitForElementAction 19 from telemetry.page.actions.wait import WaitForElementAction
20 from telemetry.web_perf import timeline_interaction_record as tir_module 20 from telemetry.web_perf import timeline_interaction_record
21 21
22 22
23 class ActionRunner(object): 23 class ActionRunner(object):
24 24
25 def __init__(self, tab): 25 def __init__(self, tab):
26 self._tab = tab 26 self._tab = tab
27 27
28 def _RunAction(self, action): 28 def _RunAction(self, action):
29 action.WillRunAction(self._tab) 29 action.WillRunAction(self._tab)
30 action.RunAction(self._tab) 30 action.RunAction(self._tab)
(...skipping 13 matching lines...) Expand all
44 user-defined string, but must not contain '/'. 44 user-defined string, but must not contain '/'.
45 is_smooth: Whether to check for smoothness metrics for this interaction. 45 is_smooth: Whether to check for smoothness metrics for this interaction.
46 is_responsive: Whether to check for responsiveness metrics for 46 is_responsive: Whether to check for responsiveness metrics for
47 this interaction. 47 this interaction.
48 repeatable: Whether other interactions may use the same logical name 48 repeatable: Whether other interactions may use the same logical name
49 as this interaction. All interactions with the same logical name must 49 as this interaction. All interactions with the same logical name must
50 have the same flags. 50 have the same flags.
51 """ 51 """
52 flags = [] 52 flags = []
53 if is_smooth: 53 if is_smooth:
54 flags.append(tir_module.IS_SMOOTH) 54 flags.append(timeline_interaction_record.IS_SMOOTH)
55 if is_responsive: 55 if is_responsive:
56 flags.append(tir_module.IS_RESPONSIVE) 56 flags.append(timeline_interaction_record.IS_RESPONSIVE)
57 if repeatable: 57 if repeatable:
58 flags.append(tir_module.REPEATABLE) 58 flags.append(timeline_interaction_record.REPEATABLE)
59 59
60 interaction = Interaction(self._tab, label, flags) 60 interaction = Interaction(self._tab, label, flags)
61 interaction.Begin() 61 interaction.Begin()
62 return interaction 62 return interaction
63 63
64 def BeginGestureInteraction(self, label, is_smooth=False, is_responsive=False, 64 def BeginGestureInteraction(self, label, is_smooth=False, is_responsive=False,
65 repeatable=False): 65 repeatable=False):
66 """Marks the beginning of a gesture-based interaction record. 66 """Marks the beginning of a gesture-based interaction record.
67 67
68 This is similar to normal interaction record, but it will 68 This is similar to normal interaction record, but it will
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 565
566 self._action_runner = action_runner 566 self._action_runner = action_runner
567 self._label = label 567 self._label = label
568 self._flags = flags 568 self._flags = flags
569 self._started = False 569 self._started = False
570 570
571 def Begin(self): 571 def Begin(self):
572 assert not self._started 572 assert not self._started
573 self._started = True 573 self._started = True
574 self._action_runner.ExecuteJavaScript('console.time("%s");' % 574 self._action_runner.ExecuteJavaScript('console.time("%s");' %
575 tir_module.TimelineInteractionRecord.GetJavaScriptMarker( 575 timeline_interaction_record.GetJavaScriptMarker(
576 self._label, self._flags)) 576 self._label, self._flags))
577 577
578 def End(self): 578 def End(self):
579 assert self._started 579 assert self._started
580 self._started = False 580 self._started = False
581 self._action_runner.ExecuteJavaScript('console.timeEnd("%s");' % 581 self._action_runner.ExecuteJavaScript('console.timeEnd("%s");' %
582 tir_module.TimelineInteractionRecord.GetJavaScriptMarker( 582 timeline_interaction_record.GetJavaScriptMarker(
583 self._label, self._flags)) 583 self._label, self._flags))
OLDNEW
« no previous file with comments | « tools/perf/measurements/timeline_controller.py ('k') | tools/telemetry/telemetry/page/actions/action_runner_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698