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

Side by Side Diff: third_party/WebKit/Source/core/html/shadow/MediaControlTimelineMetrics.h

Issue 2779273003: [Media Controls] Add UMA for timeline scrubber (Closed)
Patch Set: Created 3 years, 8 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MediaControlTimelineMetrics_h
6 #define MediaControlTimelineMetrics_h
7
8 #include "platform/Histogram.h"
9 #include "platform/wtf/Time.h"
10
11 namespace blink {
12
13 // Helpers for tracking and reporting media control timeline metrics to UMA.
14 class MediaControlTimelineMetrics {
15 public:
16 // Start tracking a pointer gesture. |fromThumb| indicates whether the user
17 // started dragging from the thumb, as opposed to pressing down their pointer
18 // on some other part of the timeline track (causing time to jump).
19 void startGesture(bool fromThumb);
20 // Finish tracking and report a pointer gesture.
21 void recordEndGesture(int timelineWidth, double mediaDurationSeconds);
22
23 // Start tracking a keydown. Ok to call multiple times if key repeats.
24 void startKey();
25 // Finish tracking and report a keyup. Call only once even if key repeats.
26 void recordEndKey(int timelineWidth, int keyCode);
27
28 // Track an incremental input event caused by the current pointer gesture or
29 // pressed key. Each sequence of calls to this should usually be sandwiched by
30 // startGesture/Key and recordEndGesture/Key.
31 void onInput(double fromSeconds, double toSeconds);
32
33 // Report width to UMA. Should be called the first time the media is played.
34 void recordWidthOnFirstPlay(bool isFullscreen,
35 bool isPortrait,
36 int timelineWidth);
37
38 private:
39 enum class State {
40 // No active gesture. Progresses to kKeyDown on |startKey|, or
41 // kGestureFromThumb/kGestureFromElsewhere on |startGesture|.
42 kInactive,
mlamouri (slow - plz ping) 2017/03/30 21:43:00 nit: drop the k? :)
johnme 2017/03/31 13:47:23 https://sites.google.com/a/chromium.org/dev/blink/
43
44 // Pointer down on thumb. Progresses to kDragFromThumb in |onInput|.
45 kGestureFromThumb,
46 // Thumb is being dragged (drag started from thumb).
47 kDragFromThumb,
48
49 // Pointer down on track. Progresses to kClick in |onInput|.
50 kGestureFromElsewhere,
51 // Pointer down followed by input. Assumed to be a click, unless additional
52 // |onInput| are received - if so progresses to kDragFromElsewhere.
53 kClick,
54 // Thumb is being dragged (drag started from track).
55 kDragFromElsewhere,
56
57 // A key is currently pressed down.
58 kKeyDown
59 };
60
61 State m_state = State::kInactive;
62
63 // The following are only valid during a pointer gesture.
64 TimeTicks m_dragStartTimeTicks;
65 float m_dragDeltaMediaSeconds = 0;
66 float m_dragSumAbsDeltaMediaSeconds = 0;
67 };
68
69 } // namespace blink
70
71 #endif // MediaControlTimelineMetrics_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698