| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 static AutoplayUmaHelper* create(HTMLMediaElement*); | 45 static AutoplayUmaHelper* create(HTMLMediaElement*); |
| 46 | 46 |
| 47 ~AutoplayUmaHelper(); | 47 ~AutoplayUmaHelper(); |
| 48 | 48 |
| 49 bool operator==(const EventListener&) const override; | 49 bool operator==(const EventListener&) const override; |
| 50 | 50 |
| 51 void onAutoplayInitiated(AutoplaySource); | 51 void onAutoplayInitiated(AutoplaySource); |
| 52 | 52 |
| 53 void recordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus); | 53 void recordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus); |
| 54 | 54 |
| 55 void onVisibilityChangedForVideoMutedPlayMethod(bool isVisible); | |
| 56 | |
| 57 void didMoveToNewDocument(Document& oldDocument); | 55 void didMoveToNewDocument(Document& oldDocument); |
| 58 | 56 |
| 59 DECLARE_VIRTUAL_TRACE(); | 57 DECLARE_VIRTUAL_TRACE(); |
| 60 | 58 |
| 61 private: | 59 private: |
| 62 explicit AutoplayUmaHelper(HTMLMediaElement*); | 60 explicit AutoplayUmaHelper(HTMLMediaElement*); |
| 63 | 61 |
| 64 void handleEvent(ExecutionContext*, Event*) override; | 62 void handleEvent(ExecutionContext*, Event*) override; |
| 65 | 63 |
| 66 void handlePlayingEvent(); | 64 void handlePlayingEvent(); |
| 65 void handlePauseEvent(); |
| 67 void handleUnloadEvent(); | 66 void handleUnloadEvent(); |
| 68 | 67 |
| 68 void maybeUnregisterUnloadListener(); |
| 69 |
| 70 void maybeStartRecordingMutedVideoPlayMethodBecomeVisible(); |
| 71 void maybeStopRecordingMutedVideoPlayMethodBecomeVisible(bool isVisible); |
| 72 |
| 73 void maybeStartRecordingMutedVideoOffscreenDuration(); |
| 74 void maybeStopRecordingMutedVideoOffscreenDuration(); |
| 75 |
| 76 void onVisibilityChangedForMutedVideoOffscreenDuration(bool isVisibile); |
| 77 void onVisibilityChangedForMutedVideoPlayMethodBecomeVisible(bool isVisible)
; |
| 78 |
| 79 bool shouldListenToUnloadEvent() const; |
| 80 |
| 69 // The autoplay source. Use AutoplaySource::NumberOfSources for invalid sour
ce. | 81 // The autoplay source. Use AutoplaySource::NumberOfSources for invalid sour
ce. |
| 70 AutoplaySource m_source; | 82 AutoplaySource m_source; |
| 71 // The media element this UMA helper is attached to. |m_element| owns |this|
. | 83 // The media element this UMA helper is attached to. |m_element| owns |this|
. |
| 72 WeakMember<HTMLMediaElement> m_element; | 84 WeakMember<HTMLMediaElement> m_element; |
| 73 // The observer is used to observe whether a muted video autoplaying by play
() method become visible at some point. | 85 |
| 74 Member<ElementVisibilityObserver> m_videoMutedPlayMethodVisibilityObserver; | 86 // The observer is used to observe whether a muted video autoplaying by play
() |
| 87 // method become visible at some point. |
| 88 // The UMA is pending for recording as long as this observer is non-null. |
| 89 Member<ElementVisibilityObserver> m_mutedVideoPlayMethodVisibilityObserver; |
| 90 |
| 91 // ----------------------------------------------------------------------- |
| 92 // Variables used for recording the duration of autoplay muted video playing
offscreen. |
| 93 // The variables are valid when |m_autoplayOffscrenVisibilityObserver| is no
n-null. |
| 94 // The recording stops whenever the playback pauses or the page is unloaded. |
| 95 |
| 96 // The starting time of autoplaying muted video. |
| 97 int64_t m_mutedVideoAutoplayOffscreenStartTimeMS; |
| 98 |
| 99 // The duration an autoplaying muted video has been in offscreen. |
| 100 int64_t m_mutedVideoAutoplayOffscreenDurationMS; |
| 101 |
| 102 // Whether an autoplaying muted video is visible. |
| 103 bool m_isVisible; |
| 104 |
| 105 // The observer is used to observer an autoplaying muted video changing it's
visibility, |
| 106 // which is used for offscreen duration UMA. |
| 107 // The UMA is pending for recording as long as this observer is non-null. |
| 108 Member<ElementVisibilityObserver> m_mutedVideoOffscreenDurationVisibilityObs
erver; |
| 75 }; | 109 }; |
| 76 | 110 |
| 77 } // namespace blink | 111 } // namespace blink |
| 78 | 112 |
| 79 #endif // AutoplayUmaHelper_h | 113 #endif // AutoplayUmaHelper_h |
| OLD | NEW |