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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 void onAutoplayInitiated(AutoplaySource); | 51 void onAutoplayInitiated(AutoplaySource); |
| 52 | 52 |
| 53 void recordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus); | 53 void recordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus); |
| 54 | 54 |
| 55 void didMoveToNewDocument(Document& oldDocument); | 55 void didMoveToNewDocument(Document& oldDocument); |
| 56 | 56 |
| 57 bool isVisible() const { return m_isVisible; } | 57 bool isVisible() const { return m_isVisible; } |
| 58 | 58 |
| 59 bool hasSource() const { return m_source != AutoplaySource::NumberOfSources; } | 59 bool hasSource() const { return m_source != AutoplaySource::NumberOfSources; } |
| 60 | 60 |
| 61 void visibilityMightChangedforMutedVideo(bool isVisible); | |
|
miu
2016/11/09 22:02:08
naming: s/Might/Maybe/
xjz
2016/11/11 01:07:29
Done.
| |
| 62 | |
| 61 DECLARE_VIRTUAL_TRACE(); | 63 DECLARE_VIRTUAL_TRACE(); |
| 62 | 64 |
| 63 private: | 65 private: |
| 64 explicit AutoplayUmaHelper(HTMLMediaElement*); | 66 explicit AutoplayUmaHelper(HTMLMediaElement*); |
| 65 | 67 |
| 66 void handleEvent(ExecutionContext*, Event*) override; | 68 void handleEvent(ExecutionContext*, Event*) override; |
| 67 | 69 |
| 68 void handlePlayingEvent(); | 70 void handlePlayingEvent(); |
| 69 void handlePauseEvent(); | 71 void handlePauseEvent(); |
| 70 void handleUnloadEvent(); | 72 void handleUnloadEvent(); |
| 71 | 73 |
| 72 void maybeUnregisterUnloadListener(); | 74 void maybeUnregisterUnloadListener(); |
| 73 | 75 |
| 74 void maybeStartRecordingMutedVideoPlayMethodBecomeVisible(); | 76 void maybeStartRecordingMutedVideoPlayMethodBecomeVisible(); |
| 75 void maybeStopRecordingMutedVideoPlayMethodBecomeVisible(bool isVisible); | 77 void maybeStopRecordingMutedVideoPlayMethodBecomeVisible(bool isVisible); |
| 76 | 78 |
| 77 void maybeStartRecordingMutedVideoOffscreenDuration(); | 79 void maybeStartRecordingMutedVideoOffscreenDuration(); |
| 78 void maybeStopRecordingMutedVideoOffscreenDuration(); | 80 void maybeStopRecordingMutedVideoOffscreenDuration(); |
| 79 | 81 |
| 80 void onVisibilityChangedForMutedVideoOffscreenDuration(bool isVisibile); | |
| 81 void onVisibilityChangedForMutedVideoPlayMethodBecomeVisible(bool isVisible); | |
| 82 | |
| 83 bool shouldListenToUnloadEvent() const; | 82 bool shouldListenToUnloadEvent() const; |
| 84 | 83 |
| 85 // The autoplay source. Use AutoplaySource::NumberOfSources for invalid | 84 // The autoplay source. Use AutoplaySource::NumberOfSources for invalid |
| 86 // source. | 85 // source. |
| 87 AutoplaySource m_source; | 86 AutoplaySource m_source; |
| 88 // The media element this UMA helper is attached to. |m_element| owns |this|. | 87 // The media element this UMA helper is attached to. |m_element| owns |this|. |
| 89 Member<HTMLMediaElement> m_element; | 88 Member<HTMLMediaElement> m_element; |
| 90 | 89 |
| 91 // The observer is used to observe whether a muted video autoplaying by play() | 90 // Indicates whether is observing the visibility of a muted video autoplayed |
| 92 // method become visible at some point. | 91 // from 'play()' method. The UMA is pending for recording as long as this is |
| 93 // The UMA is pending for recording as long as this observer is non-null. | 92 // true. |
| 94 Member<ElementVisibilityObserver> m_mutedVideoPlayMethodVisibilityObserver; | 93 bool m_isObservingVisibilityOfMutedAutoplayVideo = false; |
| 95 | 94 |
| 96 // ----------------------------------------------------------------------- | 95 // ----------------------------------------------------------------------- |
| 97 // Variables used for recording the duration of autoplay muted video playing | 96 // Variables used for recording the duration of autoplay muted video playing |
| 98 // offscreen. The variables are valid when | 97 // offscreen. The variables are valid when |
| 99 // |m_autoplayOffscrenVisibilityObserver| is non-null. | 98 // |m_autoplayOffscrenVisibilityObserver| is non-null. |
| 100 // The recording stops whenever the playback pauses or the page is unloaded. | 99 // The recording stops whenever the playback pauses or the page is unloaded. |
| 101 | 100 |
| 102 // The starting time of autoplaying muted video. | 101 // The starting time of autoplaying muted video. |
| 103 int64_t m_mutedVideoAutoplayOffscreenStartTimeMS; | 102 int64_t m_mutedVideoAutoplayOffscreenStartTimeMS; |
| 104 | 103 |
| 105 // The duration an autoplaying muted video has been in offscreen. | 104 // The duration an autoplaying muted video has been in offscreen. |
| 106 int64_t m_mutedVideoAutoplayOffscreenDurationMS; | 105 int64_t m_mutedVideoAutoplayOffscreenDurationMS; |
| 107 | 106 |
| 108 // Whether an autoplaying muted video is visible. | 107 // Whether an autoplaying muted video is visible. |
| 109 bool m_isVisible; | 108 bool m_isVisible; |
| 110 | 109 |
| 111 // The observer is used to observer an autoplaying muted video changing it's | 110 // Indicates whether is observing the visibility of a muted autoplay video for |
| 112 // visibility, which is used for offscreen duration UMA. The UMA is pending | 111 // offscreen duration UMA. The UMA is pending for recording as long as this |
| 113 // for recording as long as this observer is non-null. | 112 // is true. |
| 114 Member<ElementVisibilityObserver> | 113 bool m_isObservingVisibilityOfMutedVideoOffscreenDuration = false; |
| 115 m_mutedVideoOffscreenDurationVisibilityObserver; | |
| 116 }; | 114 }; |
| 117 | 115 |
| 118 } // namespace blink | 116 } // namespace blink |
| 119 | 117 |
| 120 #endif // AutoplayUmaHelper_h | 118 #endif // AutoplayUmaHelper_h |
| OLD | NEW |