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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 AutoplayUmaHelper_h 5 #ifndef AutoplayUmaHelper_h
6 #define AutoplayUmaHelper_h 6 #define AutoplayUmaHelper_h
7 7
8 #include "core/events/EventListener.h" 8 #include "core/events/EventListener.h"
9 #include "platform/heap/Handle.h" 9 #include "platform/heap/Handle.h"
10 10
(...skipping 25 matching lines...) Expand all
36 static AutoplayUmaHelper* create(HTMLMediaElement*); 36 static AutoplayUmaHelper* create(HTMLMediaElement*);
37 37
38 ~AutoplayUmaHelper(); 38 ~AutoplayUmaHelper();
39 39
40 bool operator==(const EventListener&) const override; 40 bool operator==(const EventListener&) const override;
41 41
42 void onAutoplayInitiated(AutoplaySource); 42 void onAutoplayInitiated(AutoplaySource);
43 43
44 void recordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus); 44 void recordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus);
45 45
46 void onVisibilityChangedForVideoMutedPlayMethod(bool isVisible);
47
48 void didMoveToNewDocument(Document& oldDocument); 46 void didMoveToNewDocument(Document& oldDocument);
49 47
50 DECLARE_VIRTUAL_TRACE(); 48 DECLARE_VIRTUAL_TRACE();
51 49
52 private: 50 private:
53 explicit AutoplayUmaHelper(HTMLMediaElement*); 51 explicit AutoplayUmaHelper(HTMLMediaElement*);
54 52
55 void handleEvent(ExecutionContext*, Event*) override; 53 void handleEvent(ExecutionContext*, Event*) override;
56 54
57 void handlePlayingEvent(); 55 void handlePlayingEvent();
56 void handlePauseEvent();
58 void handleUnloadEvent(); 57 void handleUnloadEvent();
59 58
59 void maybeUnregisterUnloadListener();
60
61 void maybeStartRecordingMutedVideoPlayMethodBecomeVisible();
62 void maybeStopRecordingMutedVideoPlayMethodBecomeVisible(bool isVisible);
63
64 void maybeStartRecordingMutedVideoOffscreenDuration();
65 void maybeStopRecordingMutedVideoOffscreenDuration();
66
67 void onVisibilityChangedForMutedVideoOffscreenDuration(bool isVisibile);
68 void onVisibilityChangedForMutedVideoPlayMethodBecomeVisible(bool isVisible) ;
69
70 bool shouldListenToUnloadEvent() const;
71
60 // The autoplay source. Use AutoplaySource::NumberOfSources for invalid sour ce. 72 // The autoplay source. Use AutoplaySource::NumberOfSources for invalid sour ce.
61 AutoplaySource m_source; 73 AutoplaySource m_source;
62 // The media element this UMA helper is attached to. |m_element| owns |this| . 74 // The media element this UMA helper is attached to. |m_element| owns |this| .
63 WeakMember<HTMLMediaElement> m_element; 75 WeakMember<HTMLMediaElement> m_element;
64 // The observer is used to observe whether a muted video autoplaying by play () method become visible at some point. 76
65 Member<ElementVisibilityObserver> m_videoMutedPlayMethodVisibilityObserver; 77 // The observer is used to observe whether a muted video autoplaying by play ()
78 // method become visible at some point.
79 // The UMA is pending for recording as long as this observer is non-null.
80 Member<ElementVisibilityObserver> m_mutedVideoPlayMethodVisibilityObserver;
81
82 // -----------------------------------------------------------------------
83 // Variables used for recording the duration of autoplay muted video playing offscreen.
84 // The variables are valid when |m_autoplayOffscrenVisibilityObserver| is no n-null.
85 // The recording stops whenever the playback pauses or the page is unloaded.
86
87 // The starting time of autoplaying muted video.
88 int64_t m_mutedVideoAutoplayOffscreenStartTimeMS;
89
90 // The duration an autoplaying muted video has been in offscreen.
91 int64_t m_mutedVideoAutoplayOffscreenDurationMS;
92
93 // Whether an autoplaying muted video is visible.
94 bool m_isVisible;
95
96 // The observer is used to observer an autoplaying muted video changing it's visibility,
97 // which is used for offscreen duration UMA.
98 // The UMA is pending for recording as long as this observer is non-null.
99 Member<ElementVisibilityObserver> m_mutedVideoOffscreenDurationVisibilityObs erver;
66 }; 100 };
67 101
68 } // namespace blink 102 } // namespace blink
69 103
70 #endif // AutoplayUmaHelper_h 104 #endif // AutoplayUmaHelper_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698