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

Unified Diff: third_party/WebKit/Source/core/html/AutoplayUmaHelper.h

Issue 2101613002: Record the offscreen playing duration of autoplaying muted videos (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix layout test expectation Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/html/AutoplayUmaHelper.h
diff --git a/third_party/WebKit/Source/core/html/AutoplayUmaHelper.h b/third_party/WebKit/Source/core/html/AutoplayUmaHelper.h
index edfca0b8d490f2fa15796a60997b9947d360f61d..05451433270e8d7cc3372be60a62bce694697199 100644
--- a/third_party/WebKit/Source/core/html/AutoplayUmaHelper.h
+++ b/third_party/WebKit/Source/core/html/AutoplayUmaHelper.h
@@ -43,8 +43,6 @@ public:
void recordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus);
- void onVisibilityChangedForVideoMutedPlayMethod(bool isVisible);
-
void didMoveToNewDocument(Document& oldDocument);
DECLARE_VIRTUAL_TRACE();
@@ -55,14 +53,50 @@ private:
void handleEvent(ExecutionContext*, Event*) override;
void handlePlayingEvent();
+ void handlePauseEvent();
void handleUnloadEvent();
+ void maybeUnregisterUnloadListener();
+
+ void maybeStartRecordingMutedVideoPlayMethodBecomeVisible();
+ void maybeStopRecordingMutedVideoPlayMethodBecomeVisible(bool isVisible);
+
+ void maybeStartRecordingMutedVideoOffscreenDuration();
+ void maybeStopRecordingMutedVideoOffscreenDuration();
+
+ void onVisibilityChangedForMutedVideoOffscreenDuration(bool isVisibile);
+ void onVisibilityChangedForMutedVideoPlayMethodBecomeVisible(bool isVisible);
+
+ bool shouldListenToUnloadEvent() const;
+
// The autoplay source. Use AutoplaySource::NumberOfSources for invalid source.
AutoplaySource m_source;
// The media element this UMA helper is attached to. |m_element| owns |this|.
WeakMember<HTMLMediaElement> m_element;
- // The observer is used to observe whether a muted video autoplaying by play() method become visible at some point.
- Member<ElementVisibilityObserver> m_videoMutedPlayMethodVisibilityObserver;
+
+ // The observer is used to observe whether a muted video autoplaying by play()
+ // method become visible at some point.
+ // The UMA is pending for recording as long as this observer is non-null.
+ Member<ElementVisibilityObserver> m_mutedVideoPlayMethodVisibilityObserver;
+
+ // -----------------------------------------------------------------------
+ // Variables used for recording the duration of autoplay muted video playing offscreen.
+ // The variables are valid when |m_autoplayOffscrenVisibilityObserver| is non-null.
+ // The recording stops whenever the playback pauses or the page is unloaded.
+
+ // The starting time of autoplaying muted video.
+ int64_t m_mutedVideoAutoplayOffscreenStartTimeMS;
+
+ // The duration an autoplaying muted video has been in offscreen.
+ int64_t m_mutedVideoAutoplayOffscreenDurationMS;
+
+ // Whether an autoplaying muted video is visible.
+ bool m_isVisible;
+
+ // The observer is used to observer an autoplaying muted video changing it's visibility,
+ // which is used for offscreen duration UMA.
+ // The UMA is pending for recording as long as this observer is non-null.
+ Member<ElementVisibilityObserver> m_mutedVideoOffscreenDurationVisibilityObserver;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698