OLD | NEW |
(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 #include "public/platform/modules/screen_orientation/WebScreenOrientationType.h" |
| 11 |
| 12 namespace blink { |
| 13 |
| 14 // Helpers for tracking and reporting media control timeline metrics to UMA. |
| 15 class MediaControlTimelineMetrics { |
| 16 public: |
| 17 // Start tracking a pointer gesture. |fromThumb| indicates whether the user |
| 18 // started dragging from the thumb, as opposed to pressing down their pointer |
| 19 // on some other part of the timeline track (causing time to jump). |
| 20 void startGesture(bool fromThumb); |
| 21 // Finish tracking and report a pointer gesture. |
| 22 void recordEndGesture(int timelineWidth, double mediaDurationSeconds); |
| 23 |
| 24 // Start tracking a keydown. Ok to call multiple times if key repeats. |
| 25 void startKey(); |
| 26 // Finish tracking and report a keyup. Call only once even if key repeats. |
| 27 void recordEndKey(int timelineWidth, int keyCode); |
| 28 |
| 29 // Track an incremental input event caused by the current pointer gesture or |
| 30 // pressed key. Each sequence of calls to this should usually be sandwiched by |
| 31 // startGesture/Key and recordEndGesture/Key. |
| 32 void onInput(double fromSeconds, double toSeconds); |
| 33 |
| 34 // Reports width to UMA the first time the media starts playing. |
| 35 void recordPlaying(WebScreenOrientationType, |
| 36 bool isFullscreen, |
| 37 int timelineWidth); |
| 38 |
| 39 private: |
| 40 enum class State { |
| 41 // No active gesture. Progresses to kKeyDown on |startKey|, or |
| 42 // kGestureFromThumb/kGestureFromElsewhere on |startGesture|. |
| 43 kInactive, |
| 44 |
| 45 // Pointer down on thumb. Progresses to kDragFromThumb in |onInput|. |
| 46 kGestureFromThumb, |
| 47 // Thumb is being dragged (drag started from thumb). |
| 48 kDragFromThumb, |
| 49 |
| 50 // Pointer down on track. Progresses to kClick in |onInput|. |
| 51 kGestureFromElsewhere, |
| 52 // Pointer down followed by input. Assumed to be a click, unless additional |
| 53 // |onInput| are received - if so progresses to kDragFromElsewhere. |
| 54 kClick, |
| 55 // Thumb is being dragged (drag started from track). |
| 56 kDragFromElsewhere, |
| 57 |
| 58 // A key is currently pressed down. |
| 59 kKeyDown |
| 60 }; |
| 61 |
| 62 bool m_hasNeverBeenPlaying = true; |
| 63 |
| 64 State m_state = State::kInactive; |
| 65 |
| 66 // The following are only valid during a pointer gesture. |
| 67 TimeTicks m_dragStartTimeTicks; |
| 68 float m_dragDeltaMediaSeconds = 0; |
| 69 float m_dragSumAbsDeltaMediaSeconds = 0; |
| 70 }; |
| 71 |
| 72 } // namespace blink |
| 73 |
| 74 #endif // MediaControlTimelineMetrics_h |
OLD | NEW |