| Index: third_party/WebKit/Source/core/html/AutoplayExperimentHelper.h
|
| diff --git a/third_party/WebKit/Source/core/html/AutoplayExperimentHelper.h b/third_party/WebKit/Source/core/html/AutoplayExperimentHelper.h
|
| index a35406017692312b1c2aab08fc8c726e0ca14326..245d21e6e035cbf651c1adb443a46d83df469984 100644
|
| --- a/third_party/WebKit/Source/core/html/AutoplayExperimentHelper.h
|
| +++ b/third_party/WebKit/Source/core/html/AutoplayExperimentHelper.h
|
| @@ -62,6 +62,32 @@ enum AutoplayMetrics {
|
| AnyPlaybackPaused = 12,
|
| // Some playback, whether user initiated or not, bailed out early.
|
| AnyPlaybackBailout = 13,
|
| + // Some playback, whether user initiated or not, played to completion.
|
| + AnyPlaybackComplete = 14,
|
| +
|
| + // Number of audio elements detected that reach the resource fetch algorithm.
|
| + AnyAudioElement = 15,
|
| + // Numer of video elements detected that reach the resource fetch algorithm.
|
| + AnyVideoElement = 16,
|
| +
|
| + // User gesture was bypassed, and playback started, and media played to
|
| + // completion without a user-initiated pause.
|
| + AutoplayComplete = 17,
|
| +
|
| + // Autoplay started after the gesture requirement was removed by a
|
| + // user gesture load().
|
| + GesturelessPlaybackEnabledByLoad = 18,
|
| +
|
| + // Gestureless playback started after the gesture requirement was removed
|
| + // because src is media stream.
|
| + GesturelessPlaybackEnabledByStream = 19,
|
| +
|
| + // Gestureless playback was started, but it is unknown why a user gesture
|
| + // was not required. This includes the case where none is ever required.
|
| + GesturelessPlaybackUnknownReason = 20,
|
| +
|
| + // Gestureless playback was enabled by a user gesture play() call.
|
| + GesturelessPlaybackEnabledByPlayMethod = 21,
|
|
|
| // This enum value must be last.
|
| NumberOfAutoplayMetrics,
|
| @@ -76,9 +102,16 @@ public:
|
| void becameReadyToPlay();
|
| void playMethodCalled();
|
| void pauseMethodCalled();
|
| + void loadMethodCalled();
|
| void mutedChanged();
|
| void positionChanged(const IntRect&);
|
| void updatePositionNotificationRegistration();
|
| + void recordSandboxFailure();
|
| + void loadingStarted();
|
| + void playbackStarted();
|
| + void playbackEnded();
|
| + void initialPlayWithUserGesture();
|
| + void setGestureRemovalReason(AutoplayMetrics);
|
|
|
| void triggerAutoplayViewportCheckForTesting();
|
|
|
| @@ -137,7 +170,17 @@ private:
|
| // 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 prepareToPlay(AutoplayMetrics);
|
| + void prepareToAutoplay(AutoplayMetrics);
|
| +
|
| + // Record that an attempt to play without a user gesture has happened.
|
| + // If there is not a user gesture requirement, then record why there
|
| + // is no such requirement, with the expectation that playback will start.
|
| + // This method takes no action after it is called once.
|
| + void autoplayMediaEncountered();
|
| +
|
| + // If we are about to enter a paused state, call this to record
|
| + // autoplay metrics.
|
| + void recordMetricsBeforePause();
|
|
|
| // Process a timer for checking visibility.
|
| void viewportTimerFired(Timer<AutoplayExperimentHelper>*);
|
| @@ -147,6 +190,8 @@ private:
|
|
|
| HTMLMediaElement& element() const;
|
|
|
| + bool isUserGestureRequiredForPlay() const;
|
| +
|
| inline bool enabled(Mode mode) const
|
| {
|
| return ((int)m_mode) & ((int)mode);
|
| @@ -154,6 +199,12 @@ private:
|
|
|
| Mode fromString(const String& mode);
|
|
|
| + void recordAutoplayMetric(AutoplayMetrics);
|
| +
|
| + // Could stopping at this point be considered a bailout of playback?
|
| + // (as in, "The user really didn't want to play this").
|
| + bool isBailout() const;
|
| +
|
| RawPtrWillBeMember<HTMLMediaElement> m_element;
|
|
|
| Mode m_mode;
|
| @@ -168,6 +219,15 @@ private:
|
| // According to our last position update, are we in the viewport?
|
| bool m_wasInViewport : 1;
|
|
|
| + // Have we counted this autoplay media in the metrics yet?
|
| + bool m_autoplayMediaCounted : 1;
|
| +
|
| + // Did the first playback of the media occur without a user gesture?
|
| + bool m_initialPlayWithoutUserGesture : 1;
|
| +
|
| + // Did we record that this media element exists in the metrics yet?
|
| + bool m_recordedElement : 1;
|
| +
|
| // According to our last position update, where was our element?
|
| IntRect m_lastLocation;
|
| IntRect m_lastVisibleRect;
|
| @@ -176,6 +236,9 @@ private:
|
| double m_lastLocationUpdateTime;
|
|
|
| Timer<AutoplayExperimentHelper> m_viewportTimer;
|
| +
|
| + // Reason that autoplay would be allowed to proceed without a user gesture.
|
| + AutoplayMetrics m_autoplayDeferredMetric;
|
| };
|
|
|
| inline AutoplayExperimentHelper::Mode& operator|=(AutoplayExperimentHelper::Mode& a,
|
|
|