| 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 from_thumb); | |
| 21 // Finish tracking and report a pointer gesture. | |
| 22 void RecordEndGesture(int timeline_width, double media_duration_seconds); | |
| 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 timeline_width, int key_code); | |
| 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 from_seconds, double to_seconds); | |
| 33 | |
| 34 // Reports width to UMA the first time the media starts playing. | |
| 35 void RecordPlaying(WebScreenOrientationType, | |
| 36 bool is_fullscreen, | |
| 37 int timeline_width); | |
| 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 has_never_been_playing_ = true; | |
| 63 | |
| 64 State state_ = State::kInactive; | |
| 65 | |
| 66 // The following are only valid during a pointer gesture. | |
| 67 TimeTicks drag_start_time_ticks_; | |
| 68 float drag_delta_media_seconds_ = 0; | |
| 69 float drag_sum_abs_delta_media_seconds_ = 0; | |
| 70 }; | |
| 71 | |
| 72 } // namespace blink | |
| 73 | |
| 74 #endif // MediaControlTimelineMetrics_h | |
| OLD | NEW |