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

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

Issue 1470153004: Autoplay experiment metric fixes and additions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cl feedback. Created 5 years 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef AutoplayExperimentHelper_h 5 #ifndef AutoplayExperimentHelper_h
6 #define AutoplayExperimentHelper_h 6 #define AutoplayExperimentHelper_h
7 7
8 #include "core/page/Page.h" 8 #include "core/page/Page.h"
9 #include "platform/Timer.h" 9 #include "platform/Timer.h"
10 #include "platform/geometry/IntRect.h" 10 #include "platform/geometry/IntRect.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 // play() failed to play due to gesture requirement. 56 // play() failed to play due to gesture requirement.
57 PlayMethodFailed = 10, 57 PlayMethodFailed = 10,
58 58
59 // Some play, whether user initiated or not, started. 59 // Some play, whether user initiated or not, started.
60 AnyPlaybackStarted = 11, 60 AnyPlaybackStarted = 11,
61 // Some play, whether user initiated or not, paused. 61 // Some play, whether user initiated or not, paused.
62 AnyPlaybackPaused = 12, 62 AnyPlaybackPaused = 12,
63 // Some playback, whether user initiated or not, bailed out early. 63 // Some playback, whether user initiated or not, bailed out early.
64 AnyPlaybackBailout = 13, 64 AnyPlaybackBailout = 13,
65 // Some playback, whether user initiated or not, played to completion.
66 AnyPlaybackComplete = 14,
67
68 // Number of audio elements detected.
philipj_slow 2015/11/26 15:30:56 Clarify that this is only elements that reached th
liberato (no reviews please) 2015/12/02 00:58:08 Done.
69 AnyAudioElement = 15,
70 // Numer of video elements detected.
71 AnyVideoElement = 16,
72
73 // User gesture was bypassed, and playback started, and media played to
74 // completion without a user-initiated pause.
75 AutoplayComplete = 17,
76
77 // Autoplay started after the gesture requirement was removed by a
78 // user gesture load().
79 GesturelessPlaybackEnabledByLoad = 18,
80
81 // Gestureless playback started after the gesture requirement was removed
82 // because src is media stream.
83 GesturelessPlaybackEnabledByStream = 19,
84
85 // Gestureless playback was started, but it is unknown why a user gesture
86 // was not required. This includes the case where none is ever required.
87 GesturelessPlaybackUnknownReason = 20,
65 88
66 // This enum value must be last. 89 // This enum value must be last.
67 NumberOfAutoplayMetrics, 90 NumberOfAutoplayMetrics,
68 }; 91 };
69 92
70 class AutoplayExperimentHelper final { 93 class AutoplayExperimentHelper final {
71 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); 94 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
72 public: 95 public:
73 explicit AutoplayExperimentHelper(HTMLMediaElement&); 96 explicit AutoplayExperimentHelper(HTMLMediaElement&);
74 ~AutoplayExperimentHelper(); 97 ~AutoplayExperimentHelper();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 // requires it, else do nothing. 153 // requires it, else do nothing.
131 void muteIfNeeded(); 154 void muteIfNeeded();
132 155
133 // Maybe override the requirement for a user gesture, and start playing 156 // Maybe override the requirement for a user gesture, and start playing
134 // autoplay media. Returns true if only if it starts playback. 157 // autoplay media. Returns true if only if it starts playback.
135 bool maybeStartPlaying(); 158 bool maybeStartPlaying();
136 159
137 // Configure internal state to record that the autoplay experiment is 160 // Configure internal state to record that the autoplay experiment is
138 // going to start playback. This doesn't actually start playback, since 161 // going to start playback. This doesn't actually start playback, since
139 // there are several different cases. 162 // there are several different cases.
140 void prepareToPlay(AutoplayMetrics); 163 void prepareToAutoplay(AutoplayMetrics);
141 164
142 // Process a timer for checking visibility. 165 // Process a timer for checking visibility.
143 void viewportTimerFired(Timer<AutoplayExperimentHelper>*); 166 void viewportTimerFired(Timer<AutoplayExperimentHelper>*);
144 167
145 // Return our media element's document. 168 // Return our media element's document.
146 Document& document() const; 169 Document& document() const;
147 170
148 HTMLMediaElement& element() const; 171 HTMLMediaElement& element() const;
149 172
150 inline bool enabled(Mode mode) const 173 inline bool enabled(Mode mode) const
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 const AutoplayExperimentHelper::Mode& b) 205 const AutoplayExperimentHelper::Mode& b)
183 { 206 {
184 a = static_cast<AutoplayExperimentHelper::Mode>(static_cast<int>(a) | static _cast<int>(b)); 207 a = static_cast<AutoplayExperimentHelper::Mode>(static_cast<int>(a) | static _cast<int>(b));
185 return a; 208 return a;
186 } 209 }
187 210
188 211
189 } // namespace blink 212 } // namespace blink
190 213
191 #endif // AutoplayExperimentHelper_h 214 #endif // AutoplayExperimentHelper_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698