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/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "core/dom/ContextLifecycleObserver.h" | 9 #include "core/dom/ContextLifecycleObserver.h" |
10 #include "core/events/EventListener.h" | 10 #include "core/events/EventListener.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 106 |
107 void OnVisibilityChangedForMutedVideoOffscreenDuration(bool is_visibile); | 107 void OnVisibilityChangedForMutedVideoOffscreenDuration(bool is_visibile); |
108 void OnVisibilityChangedForMutedVideoPlayMethodBecomeVisible(bool is_visible); | 108 void OnVisibilityChangedForMutedVideoPlayMethodBecomeVisible(bool is_visible); |
109 | 109 |
110 bool ShouldListenToContextDestroyed() const; | 110 bool ShouldListenToContextDestroyed() const; |
111 bool ShouldRecordUserPausedAutoplayingCrossOriginVideo() const; | 111 bool ShouldRecordUserPausedAutoplayingCrossOriginVideo() const; |
112 | 112 |
113 // The autoplay sources. | 113 // The autoplay sources. |
114 std::set<AutoplaySource> sources_; | 114 std::set<AutoplaySource> sources_; |
115 | 115 |
116 // The media element this UMA helper is attached to. |m_element| owns |this|. | 116 // The media element this UMA helper is attached to. |element| owns |this|. |
117 Member<HTMLMediaElement> element_; | 117 Member<HTMLMediaElement> element_; |
118 | 118 |
119 // The observer is used to observe whether a muted video autoplaying by play() | 119 // The observer is used to observe whether a muted video autoplaying by play() |
120 // method become visible at some point. | 120 // method become visible at some point. |
121 // The UMA is pending for recording as long as this observer is non-null. | 121 // The UMA is pending for recording as long as this observer is non-null. |
122 Member<ElementVisibilityObserver> | 122 Member<ElementVisibilityObserver> |
123 muted_video_play_method_visibility_observer_; | 123 muted_video_play_method_visibility_observer_; |
124 | 124 |
125 // ----------------------------------------------------------------------- | 125 // ----------------------------------------------------------------------- |
126 // Variables used for recording the duration of autoplay muted video playing | 126 // Variables used for recording the duration of autoplay muted video playing |
127 // offscreen. The variables are valid when | 127 // offscreen. The variables are valid when |
128 // |m_autoplayOffscrenVisibilityObserver| is non-null. | 128 // |autoplayOffscrenVisibilityObserver| is non-null. |
129 // The recording stops whenever the playback pauses or the page is unloaded. | 129 // The recording stops whenever the playback pauses or the page is unloaded. |
130 | 130 |
131 // The starting time of autoplaying muted video. | 131 // The starting time of autoplaying muted video. |
132 int64_t muted_video_autoplay_offscreen_start_time_ms_; | 132 int64_t muted_video_autoplay_offscreen_start_time_ms_; |
133 | 133 |
134 // The duration an autoplaying muted video has been in offscreen. | 134 // The duration an autoplaying muted video has been in offscreen. |
135 int64_t muted_video_autoplay_offscreen_duration_ms_; | 135 int64_t muted_video_autoplay_offscreen_duration_ms_; |
136 | 136 |
137 // Whether an autoplaying muted video is visible. | 137 // Whether an autoplaying muted video is visible. |
138 bool is_visible_; | 138 bool is_visible_; |
139 | 139 |
140 std::set<CrossOriginAutoplayResult> recorded_cross_origin_autoplay_results_; | 140 std::set<CrossOriginAutoplayResult> recorded_cross_origin_autoplay_results_; |
141 | 141 |
142 // The observer is used to observer an autoplaying muted video changing it's | 142 // The observer is used to observer an autoplaying muted video changing it's |
143 // visibility, which is used for offscreen duration UMA. The UMA is pending | 143 // visibility, which is used for offscreen duration UMA. The UMA is pending |
144 // for recording as long as this observer is non-null. | 144 // for recording as long as this observer is non-null. |
145 Member<ElementVisibilityObserver> | 145 Member<ElementVisibilityObserver> |
146 muted_video_offscreen_duration_visibility_observer_; | 146 muted_video_offscreen_duration_visibility_observer_; |
| 147 |
| 148 double created_time_ms_; |
147 }; | 149 }; |
148 | 150 |
149 } // namespace blink | 151 } // namespace blink |
150 | 152 |
151 #endif // AutoplayUmaHelper_h | 153 #endif // AutoplayUmaHelper_h |
OLD | NEW |