| OLD | NEW |
| 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 Loading... |
| 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 |
| 46 void didMoveToNewDocument(Document& oldDocument); | 48 void didMoveToNewDocument(Document& oldDocument); |
| 47 | 49 |
| 48 DECLARE_VIRTUAL_TRACE(); | 50 DECLARE_VIRTUAL_TRACE(); |
| 49 | 51 |
| 50 private: | 52 private: |
| 51 explicit AutoplayUmaHelper(HTMLMediaElement*); | 53 explicit AutoplayUmaHelper(HTMLMediaElement*); |
| 52 | 54 |
| 53 void handleEvent(ExecutionContext*, Event*) override; | 55 void handleEvent(ExecutionContext*, Event*) override; |
| 54 | 56 |
| 55 void handlePlayingEvent(); | 57 void handlePlayingEvent(); |
| 56 void handlePauseEvent(); | |
| 57 void handleUnloadEvent(); | 58 void handleUnloadEvent(); |
| 58 | 59 |
| 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 | |
| 72 // The autoplay source. Use AutoplaySource::NumberOfSources for invalid sour
ce. | 60 // The autoplay source. Use AutoplaySource::NumberOfSources for invalid sour
ce. |
| 73 AutoplaySource m_source; | 61 AutoplaySource m_source; |
| 74 // The media element this UMA helper is attached to. |m_element| owns |this|
. | 62 // The media element this UMA helper is attached to. |m_element| owns |this|
. |
| 75 WeakMember<HTMLMediaElement> m_element; | 63 WeakMember<HTMLMediaElement> m_element; |
| 76 | 64 // The observer is used to observe whether a muted video autoplaying by play
() method become visible at some point. |
| 77 // The observer is used to observe whether a muted video autoplaying by play
() | 65 Member<ElementVisibilityObserver> m_videoMutedPlayMethodVisibilityObserver; |
| 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; | |
| 100 }; | 66 }; |
| 101 | 67 |
| 102 } // namespace blink | 68 } // namespace blink |
| 103 | 69 |
| 104 #endif // AutoplayUmaHelper_h | 70 #endif // AutoplayUmaHelper_h |
| OLD | NEW |