Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: third_party/WebKit/Source/core/html/media/AutoplayUmaHelper.h

Issue 2856783002: Autoplay time metric (Closed)
Patch Set: comments addressed Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "platform/heap/Handle.h" 11 #include "platform/heap/Handle.h"
12 #include "public/platform/WebMediaPlayerClient.h"
12 13
13 #include <set> 14 #include <set>
14 15
15 namespace blink { 16 namespace blink {
16 17
17 // These values are used for histograms. Do not reorder. 18 // These values are used for histograms. Do not reorder.
18 enum class AutoplaySource { 19 enum class AutoplaySource {
19 // Autoplay comes from HTMLMediaElement `autoplay` attribute. 20 // Autoplay comes from HTMLMediaElement `autoplay` attribute.
20 kAttribute = 0, 21 kAttribute = 0,
21 // Autoplay comes from `play()` method. 22 // Autoplay comes from `play()` method.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 64
64 public: 65 public:
65 static AutoplayUmaHelper* Create(HTMLMediaElement*); 66 static AutoplayUmaHelper* Create(HTMLMediaElement*);
66 67
67 ~AutoplayUmaHelper(); 68 ~AutoplayUmaHelper();
68 69
69 bool operator==(const EventListener&) const override; 70 bool operator==(const EventListener&) const override;
70 71
71 void ContextDestroyed(ExecutionContext*) override; 72 void ContextDestroyed(ExecutionContext*) override;
72 73
74 // Called when source is initialized and loading starts.
75 void OnLoadStarted(WebMediaPlayer::LoadType);
76
73 void OnAutoplayInitiated(AutoplaySource); 77 void OnAutoplayInitiated(AutoplaySource);
74 78
75 void RecordCrossOriginAutoplayResult(CrossOriginAutoplayResult); 79 void RecordCrossOriginAutoplayResult(CrossOriginAutoplayResult);
76 void RecordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus); 80 void RecordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus);
77 81
78 void VideoWillBeDrawnToCanvas(); 82 void VideoWillBeDrawnToCanvas();
79 void DidMoveToNewDocument(Document& old_document); 83 void DidMoveToNewDocument(Document& old_document);
80 84
81 bool IsVisible() const { return is_visible_; } 85 bool IsVisible() const { return is_visible_; }
82 86
(...skipping 23 matching lines...) Expand all
106 110
107 void OnVisibilityChangedForMutedVideoOffscreenDuration(bool is_visibile); 111 void OnVisibilityChangedForMutedVideoOffscreenDuration(bool is_visibile);
108 void OnVisibilityChangedForMutedVideoPlayMethodBecomeVisible(bool is_visible); 112 void OnVisibilityChangedForMutedVideoPlayMethodBecomeVisible(bool is_visible);
109 113
110 bool ShouldListenToContextDestroyed() const; 114 bool ShouldListenToContextDestroyed() const;
111 bool ShouldRecordUserPausedAutoplayingCrossOriginVideo() const; 115 bool ShouldRecordUserPausedAutoplayingCrossOriginVideo() const;
112 116
113 // The autoplay sources. 117 // The autoplay sources.
114 std::set<AutoplaySource> sources_; 118 std::set<AutoplaySource> sources_;
115 119
116 // The media element this UMA helper is attached to. |m_element| owns |this|. 120 // The media element this UMA helper is attached to. |element| owns |this|.
117 Member<HTMLMediaElement> element_; 121 Member<HTMLMediaElement> element_;
118 122
119 // The observer is used to observe whether a muted video autoplaying by play() 123 // The observer is used to observe whether a muted video autoplaying by play()
120 // method become visible at some point. 124 // method become visible at some point.
121 // The UMA is pending for recording as long as this observer is non-null. 125 // The UMA is pending for recording as long as this observer is non-null.
122 Member<ElementVisibilityObserver> 126 Member<ElementVisibilityObserver>
123 muted_video_play_method_visibility_observer_; 127 muted_video_play_method_visibility_observer_;
124 128
125 // ----------------------------------------------------------------------- 129 // -----------------------------------------------------------------------
126 // Variables used for recording the duration of autoplay muted video playing 130 // Variables used for recording the duration of autoplay muted video playing
127 // offscreen. The variables are valid when 131 // offscreen. The variables are valid when
128 // |m_autoplayOffscrenVisibilityObserver| is non-null. 132 // |autoplayOffscrenVisibilityObserver| is non-null.
129 // The recording stops whenever the playback pauses or the page is unloaded. 133 // The recording stops whenever the playback pauses or the page is unloaded.
130 134
131 // The starting time of autoplaying muted video. 135 // The starting time of autoplaying muted video.
132 int64_t muted_video_autoplay_offscreen_start_time_ms_; 136 int64_t muted_video_autoplay_offscreen_start_time_ms_;
133 137
134 // The duration an autoplaying muted video has been in offscreen. 138 // The duration an autoplaying muted video has been in offscreen.
135 int64_t muted_video_autoplay_offscreen_duration_ms_; 139 int64_t muted_video_autoplay_offscreen_duration_ms_;
136 140
137 // Whether an autoplaying muted video is visible. 141 // Whether an autoplaying muted video is visible.
138 bool is_visible_; 142 bool is_visible_;
139 143
140 std::set<CrossOriginAutoplayResult> recorded_cross_origin_autoplay_results_; 144 std::set<CrossOriginAutoplayResult> recorded_cross_origin_autoplay_results_;
141 145
142 // The observer is used to observer an autoplaying muted video changing it's 146 // 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 147 // visibility, which is used for offscreen duration UMA. The UMA is pending
144 // for recording as long as this observer is non-null. 148 // for recording as long as this observer is non-null.
145 Member<ElementVisibilityObserver> 149 Member<ElementVisibilityObserver>
146 muted_video_offscreen_duration_visibility_observer_; 150 muted_video_offscreen_duration_visibility_observer_;
151
152 double load_start_time_ms_;
147 }; 153 };
148 154
149 } // namespace blink 155 } // namespace blink
150 156
151 #endif // AutoplayUmaHelper_h 157 #endif // AutoplayUmaHelper_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698