Chromium Code Reviews| 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 | |
| 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(bool isInfinite); | |
| 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 // Variables used for recording the duration of autoplay muted video playing offscreen. | |
| 83 // The variables are valid when |m_autoplayOffscrenVisibilityObserver| is no n-null. | |
| 84 // The recording stops whenever the playback pauses or the page is unloaded. | |
| 85 | |
| 86 // The starting time of autoplaying muted video. | |
| 87 double m_mutedVideoAutoplayOffscreenStartTimeMS; | |
| 88 // The duration an autoplaying muted video has been in offscreen. | |
| 89 double m_mutedVideoAutoplayOffscreenDurationMS; | |
| 90 // Whether an autoplaying muted video is visible. | |
| 91 bool m_isVisible; | |
| 92 // The observer is used to observer an autoplaying muted video changing it's visibility, | |
|
mlamouri (slow - plz ping)
2016/08/19 10:00:08
style: I think it would be better to leave an empt
Zhiqiang Zhang (Slow)
2016/08/19 10:50:49
Done.
| |
| 93 // which is used for offscreen duration UMA. | |
| 94 // The UMA is pending for recording as long as this observer is non-null. | |
| 95 Member<ElementVisibilityObserver> m_mutedVideoOffscreenDurationVisibilityObs erver; | |
| 66 }; | 96 }; |
| 67 | 97 |
| 68 } // namespace blink | 98 } // namespace blink |
| 69 | 99 |
| 70 #endif // AutoplayUmaHelper_h | 100 #endif // AutoplayUmaHelper_h |
| OLD | NEW |