Index: Source/core/html/HTMLMediaElement.h |
diff --git a/Source/core/html/HTMLMediaElement.h b/Source/core/html/HTMLMediaElement.h |
index 7dccef802e17f16bc8e584a50b825246a6d9c776..898962dc2cab4acfef7b8ec5d6d0174c0d515aec 100644 |
--- a/Source/core/html/HTMLMediaElement.h |
+++ b/Source/core/html/HTMLMediaElement.h |
@@ -300,6 +300,35 @@ protected: |
void setControllerInternal(MediaController*); |
private: |
+ // These values are used for a histogram. Do not reorder. |
+ enum AutoplayMetrics { |
+ // Media element with autoplay seen. |
+ AutoplayMediaFound = 0, |
+ // Autoplay enabled and user stopped media play at any point. |
+ AutoplayStopped = 1, |
+ // Autoplay enabled but user bailed out on media play early. |
+ AutoplayBailout = 2, |
+ // Autoplay disabled but user manually started media. |
+ AutoplayManualStart = 3, |
+ // Autoplay was (re)enabled through a user-gesture triggered load() |
+ AutoplayEnabledThroughLoad = 4, |
+ // Autoplay disabled by sandbox flags. |
+ AutoplayDisabledBySandbox = 5, |
+ // AutoplayStopped for a media play that was started by the experiment. |
+ AutoplayExperimentStopped = 6, |
+ // AutoplayBailout for media a play that was started by the experiment. |
+ AutoplayExperimentBailout = 7, |
+ // Autoplay started by experiment when media scrolled into view. We don't |
+ // record whether it was a javascript or attribute autoplay request. |
+ AutoplayExperimentStartedByScroll = 8, |
+ // Autoplay started by experiment during initial load. |
+ AutoplayExperimentStartedByLoad = 9, |
+ // Autoplay started by experiment in play() call. |
+ AutoplayExperimentStartedByPlay = 10, |
+ // This enum value must be last. |
+ NumberOfAutoplayMetrics, |
+ }; |
+ |
void createMediaPlayer(); |
bool alwaysCreateUserAgentShadowRoot() const final { return true; } |
@@ -429,6 +458,41 @@ private: |
bool isBlockedOnMediaController() const; |
bool isAutoplaying() const { return m_autoplaying; } |
+ void recordAutoplayMetric(AutoplayMetrics); |
+ |
+ // vvvv Helpers for clank autoplay investigation vvvv |
+ |
+ // Install a scroll listener to check for changes in visibility. If a |
+ // listener is already installed, then this does nothing. |
+ void autoplayExperimentInstallScrollListenerIfNeeded(); |
+ |
+ // Remove any scroll listener. It's okay to call this if one isn't |
+ // installed already. |
+ void autoplayExperimentClearScrollListenerIfNeeded(); |
+ |
+ // Return true if any only if this player meets (most) of the eligibility |
+ // requirements for the experiment to override the need for a user |
+ // gesture. This includes everything except the visibility test. |
+ bool autoplayExperimentIsEligible() const; |
+ |
+ // Return true if and only if the player is visible. |
+ bool autoplayExperimentIsVisible(); |
+ |
+ // Set the mute flag on the media if we're in an experiment mode that |
+ // requires it, else do nothing. |
+ void autoplayExperimentMuteIfNeeded(); |
+ |
+ // In response to a scroll event, maybe start playing. Returns true if |
+ // only if it starts playback. |
+ bool autoplayExperimentMaybeStartPlaying(); |
+ |
+ // Configure internal state to record that the autoplay experiment is |
+ // going to start playback. This doesn't actually start playback, since |
+ // there are several different cases. |
+ void autoplayExperimentPrepareToPlay(AutoplayMetrics); |
+ |
+ // ^^^^ Helpers for clank autoplay investigation ^^^^ |
+ |
WebMediaPlayer::CORSMode corsMode() const; |
// Returns the "direction of playback" value as specified in the HTML5 spec. |
@@ -552,6 +616,29 @@ private: |
bool m_initialPlayWithoutUserGestures : 1; |
bool m_autoplayMediaCounted : 1; |
+ // Autoplay experiment state. |
+ // True if we've received a play() without a pause(). |
+ bool m_autoplayExperimentPlayPending : 1; |
+ |
+ // Autoplay experiment state. |
+ // True if and only if we initiated playback because of the autoplay |
+ // experiment. Once set, this is never unset. |
+ bool m_autoplayExperimentStartedByExperiment : 1; |
+ |
+ // Autoplay experiment state. |
+ // Scroll listener for the autoplay experiment. |
+ class AutoplayExperimentScrollListener; |
+ friend class AutoplayExperimentScrollListener; |
+ RefPtrWillBeMember<EventListener> m_autoplayExperimentScrollListener; |
+ |
+ enum AutoplayExperimentMode { |
+ ExperimentOff, |
+ ExperimentAlways, |
+ ExperimentIfMuted, |
+ ExperimentPlayMuted |
+ }; |
+ AutoplayExperimentMode m_autoplayExperimentMode; |
+ |
RefPtrWillBeMember<AudioTrackList> m_audioTracks; |
RefPtrWillBeMember<VideoTrackList> m_videoTracks; |
RefPtrWillBeMember<TextTrackList> m_textTracks; |
@@ -568,6 +655,7 @@ private: |
friend class MediaController; |
PersistentWillBeMember<MediaController> m_mediaController; |
+ friend class MyScrollListener; |
philipj_slow
2015/07/21 12:51:29
MyScrollListener is nowhere to be found?
liberato (no reviews please)
2015/07/27 06:03:09
that was sloppy of me. thanks.
|
friend class Internals; |
friend class TrackDisplayUpdateScope; |