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

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

Issue 2000023002: Tidy AutoplayExperimentHelper. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/AutoplayExperimentHelper.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/PageVisibilityState.h"
9 #include "platform/Timer.h" 9 #include "platform/Timer.h"
10 #include "platform/geometry/IntRect.h" 10 #include "platform/geometry/IntRect.h"
11 11
12 namespace blink { 12 namespace blink {
13
13 class Document; 14 class Document;
14 class HTMLMediaElement;
15 class EventListener;
16 class LayoutObject;
17 class AutoplayExperimentTest; 15 class AutoplayExperimentTest;
18 16
19 // These values are used for a histogram. Do not reorder. 17 // These values are used for a histogram. Do not reorder.
20 enum AutoplayMetrics { 18 enum AutoplayMetrics {
21 // Media element with autoplay seen. 19 // Media element with autoplay seen.
22 AutoplayMediaFound = 0, 20 AutoplayMediaFound = 0,
23 // Autoplay enabled and user stopped media play at any point. 21 // Autoplay enabled and user stopped media play at any point.
24 AutoplayPaused = 1, 22 AutoplayPaused = 1,
25 // Autoplay enabled but user bailed out on media play early. 23 // Autoplay enabled but user bailed out on media play early.
26 AutoplayBailout = 2, 24 AutoplayBailout = 2,
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 void recordSandboxFailure(); 152 void recordSandboxFailure();
155 void loadingStarted(); 153 void loadingStarted();
156 void playbackStarted(); 154 void playbackStarted();
157 void playbackStopped(); 155 void playbackStopped();
158 void initialPlayWithUserGesture(); 156 void initialPlayWithUserGesture();
159 157
160 // Returns true if and only if any experiment is enabled (i.e., |m_mode| 158 // Returns true if and only if any experiment is enabled (i.e., |m_mode|
161 // is not ExperimentOff). 159 // is not ExperimentOff).
162 bool isExperimentEnabled(); 160 bool isExperimentEnabled();
163 161
164 // Clean up. For Oilpan, this means "early in HTMLMediaElement's dispose".
165 // For non-Oilpan, just delete the object.
166 void dispose();
167
168 // Remove the user gesture requirement, and record why. If there is no 162 // Remove the user gesture requirement, and record why. If there is no
169 // gesture requirement, then this does nothing. 163 // gesture requirement, then this does nothing.
170 void unlockUserGesture(AutoplayMetrics); 164 void unlockUserGesture(AutoplayMetrics);
171 165
172 // Set the reason that we're overridding the user gesture. If there is no 166 // Set the reason that we're overridding the user gesture. If there is no
173 // gesture requirement, then this does nothing. 167 // gesture requirement, then this does nothing.
174 void setDeferredOverrideReason(AutoplayMetrics); 168 void setDeferredOverrideReason(AutoplayMetrics);
175 169
176 // Return true if and only if the user gesture requirement is currently 170 // Return true if and only if the user gesture requirement is currently
177 // overridden by the experiment, permitting playback. 171 // overridden by the experiment, permitting playback.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 // This method takes no action after it is called once. 261 // This method takes no action after it is called once.
268 void autoplayMediaEncountered(); 262 void autoplayMediaEncountered();
269 263
270 // If we are about to enter a paused state, call this to record 264 // If we are about to enter a paused state, call this to record
271 // autoplay metrics. 265 // autoplay metrics.
272 void recordMetricsBeforePause(); 266 void recordMetricsBeforePause();
273 267
274 // Process a timer for checking visibility. 268 // Process a timer for checking visibility.
275 void viewportTimerFired(Timer<AutoplayExperimentHelper>*); 269 void viewportTimerFired(Timer<AutoplayExperimentHelper>*);
276 270
277 // Return our media element's document. 271 Client& client() const { return *m_client; }
278 Document& document() const;
279
280 Client& client() const;
281 272
282 bool isLockedPendingUserGesture() const; 273 bool isLockedPendingUserGesture() const;
283 274
284 inline bool enabled(Mode mode) const 275 inline bool enabled(Mode mode) const
285 { 276 {
286 return ((int)m_mode) & ((int)mode); 277 return static_cast<int>(m_mode) & static_cast<int>(mode);
287 } 278 }
288 279
289 Mode fromString(const String& mode); 280 Mode fromString(const String& mode);
290 281
291 void recordAutoplayMetric(AutoplayMetrics); 282 void recordAutoplayMetric(AutoplayMetrics);
292 283
293 // Could stopping at this point be considered a bailout of playback? 284 // Could stopping at this point be considered a bailout of playback?
294 // (as in, "The user really didn't want to play this"). 285 // (as in, "The user really didn't want to play this").
295 bool isBailout() const; 286 bool isBailout() const;
296 287
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 inline AutoplayExperimentHelper::Mode& operator|=(AutoplayExperimentHelper::Mode & a, 337 inline AutoplayExperimentHelper::Mode& operator|=(AutoplayExperimentHelper::Mode & a,
347 const AutoplayExperimentHelper::Mode& b) 338 const AutoplayExperimentHelper::Mode& b)
348 { 339 {
349 a = static_cast<AutoplayExperimentHelper::Mode>(static_cast<int>(a) | static _cast<int>(b)); 340 a = static_cast<AutoplayExperimentHelper::Mode>(static_cast<int>(a) | static _cast<int>(b));
350 return a; 341 return a;
351 } 342 }
352 343
353 } // namespace blink 344 } // namespace blink
354 345
355 #endif // AutoplayExperimentHelper_h 346 #endif // AutoplayExperimentHelper_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/AutoplayExperimentHelper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698