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

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

Issue 2856783002: Autoplay time metric (Closed)
Patch Set: added OnLoadStarted() 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"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 public: 64 public:
65 static AutoplayUmaHelper* Create(HTMLMediaElement*); 65 static AutoplayUmaHelper* Create(HTMLMediaElement*);
66 66
67 ~AutoplayUmaHelper(); 67 ~AutoplayUmaHelper();
68 68
69 bool operator==(const EventListener&) const override; 69 bool operator==(const EventListener&) const override;
70 70
71 void ContextDestroyed(ExecutionContext*) override; 71 void ContextDestroyed(ExecutionContext*) override;
72 72
73 // Called when source is initialized and loading starts.
74 void OnLoadStarted();
75
73 void OnAutoplayInitiated(AutoplaySource); 76 void OnAutoplayInitiated(AutoplaySource);
74 77
75 void RecordCrossOriginAutoplayResult(CrossOriginAutoplayResult); 78 void RecordCrossOriginAutoplayResult(CrossOriginAutoplayResult);
76 void RecordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus); 79 void RecordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus);
77 80
78 void VideoWillBeDrawnToCanvas(); 81 void VideoWillBeDrawnToCanvas();
79 void DidMoveToNewDocument(Document& old_document); 82 void DidMoveToNewDocument(Document& old_document);
80 83
81 bool IsVisible() const { return is_visible_; } 84 bool IsVisible() const { return is_visible_; }
82 85
(...skipping 23 matching lines...) Expand all
106 109
107 void OnVisibilityChangedForMutedVideoOffscreenDuration(bool is_visibile); 110 void OnVisibilityChangedForMutedVideoOffscreenDuration(bool is_visibile);
108 void OnVisibilityChangedForMutedVideoPlayMethodBecomeVisible(bool is_visible); 111 void OnVisibilityChangedForMutedVideoPlayMethodBecomeVisible(bool is_visible);
109 112
110 bool ShouldListenToContextDestroyed() const; 113 bool ShouldListenToContextDestroyed() const;
111 bool ShouldRecordUserPausedAutoplayingCrossOriginVideo() const; 114 bool ShouldRecordUserPausedAutoplayingCrossOriginVideo() const;
112 115
113 // The autoplay sources. 116 // The autoplay sources.
114 std::set<AutoplaySource> sources_; 117 std::set<AutoplaySource> sources_;
115 118
116 // The media element this UMA helper is attached to. |m_element| owns |this|. 119 // The media element this UMA helper is attached to. |element| owns |this|.
117 Member<HTMLMediaElement> element_; 120 Member<HTMLMediaElement> element_;
118 121
119 // The observer is used to observe whether a muted video autoplaying by play() 122 // The observer is used to observe whether a muted video autoplaying by play()
120 // method become visible at some point. 123 // method become visible at some point.
121 // The UMA is pending for recording as long as this observer is non-null. 124 // The UMA is pending for recording as long as this observer is non-null.
122 Member<ElementVisibilityObserver> 125 Member<ElementVisibilityObserver>
123 muted_video_play_method_visibility_observer_; 126 muted_video_play_method_visibility_observer_;
124 127
125 // ----------------------------------------------------------------------- 128 // -----------------------------------------------------------------------
126 // Variables used for recording the duration of autoplay muted video playing 129 // Variables used for recording the duration of autoplay muted video playing
127 // offscreen. The variables are valid when 130 // offscreen. The variables are valid when
128 // |m_autoplayOffscrenVisibilityObserver| is non-null. 131 // |autoplayOffscrenVisibilityObserver| is non-null.
129 // The recording stops whenever the playback pauses or the page is unloaded. 132 // The recording stops whenever the playback pauses or the page is unloaded.
130 133
131 // The starting time of autoplaying muted video. 134 // The starting time of autoplaying muted video.
132 int64_t muted_video_autoplay_offscreen_start_time_ms_; 135 int64_t muted_video_autoplay_offscreen_start_time_ms_;
133 136
134 // The duration an autoplaying muted video has been in offscreen. 137 // The duration an autoplaying muted video has been in offscreen.
135 int64_t muted_video_autoplay_offscreen_duration_ms_; 138 int64_t muted_video_autoplay_offscreen_duration_ms_;
136 139
137 // Whether an autoplaying muted video is visible. 140 // Whether an autoplaying muted video is visible.
138 bool is_visible_; 141 bool is_visible_;
139 142
140 std::set<CrossOriginAutoplayResult> recorded_cross_origin_autoplay_results_; 143 std::set<CrossOriginAutoplayResult> recorded_cross_origin_autoplay_results_;
141 144
142 // The observer is used to observer an autoplaying muted video changing it's 145 // 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 146 // visibility, which is used for offscreen duration UMA. The UMA is pending
144 // for recording as long as this observer is non-null. 147 // for recording as long as this observer is non-null.
145 Member<ElementVisibilityObserver> 148 Member<ElementVisibilityObserver>
146 muted_video_offscreen_duration_visibility_observer_; 149 muted_video_offscreen_duration_visibility_observer_;
150
151 double load_start_time_ms_;
147 }; 152 };
148 153
149 } // namespace blink 154 } // namespace blink
150 155
151 #endif // AutoplayUmaHelper_h 156 #endif // AutoplayUmaHelper_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698