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

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

Issue 2384273007: reflow comments in core/html/*.{cpp,h},core/html/imports (Closed)
Patch Set: comments Created 4 years, 2 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 #include "core/html/AutoplayUmaHelper.h" 5 #include "core/html/AutoplayUmaHelper.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/dom/ElementVisibilityObserver.h" 8 #include "core/dom/ElementVisibilityObserver.h"
9 #include "core/events/Event.h" 9 #include "core/events/Event.h"
10 #include "core/frame/LocalDOMWindow.h" 10 #include "core/frame/LocalDOMWindow.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 ("Media.Video.Autoplay.Muted", 50 ("Media.Video.Autoplay.Muted",
51 static_cast<int>(AutoplaySource::NumberOfSources))); 51 static_cast<int>(AutoplaySource::NumberOfSources)));
52 DEFINE_STATIC_LOCAL(EnumerationHistogram, audioHistogram, 52 DEFINE_STATIC_LOCAL(EnumerationHistogram, audioHistogram,
53 ("Media.Audio.Autoplay", 53 ("Media.Audio.Autoplay",
54 static_cast<int>(AutoplaySource::NumberOfSources))); 54 static_cast<int>(AutoplaySource::NumberOfSources)));
55 DEFINE_STATIC_LOCAL( 55 DEFINE_STATIC_LOCAL(
56 EnumerationHistogram, blockedMutedVideoHistogram, 56 EnumerationHistogram, blockedMutedVideoHistogram,
57 ("Media.Video.Autoplay.Muted.Blocked", AutoplayBlockedReasonMax)); 57 ("Media.Video.Autoplay.Muted.Blocked", AutoplayBlockedReasonMax));
58 58
59 // Autoplay already initiated 59 // Autoplay already initiated
60 // TODO(zqzhang): how about having autoplay attribute and calling `play()` in the script? 60 // TODO(zqzhang): how about having autoplay attribute and calling `play()` in
61 // the script?
61 if (m_source != AutoplaySource::NumberOfSources) 62 if (m_source != AutoplaySource::NumberOfSources)
62 return; 63 return;
63 64
64 m_source = source; 65 m_source = source;
65 66
66 // Record the source. 67 // Record the source.
67 if (m_element->isHTMLVideoElement()) { 68 if (m_element->isHTMLVideoElement()) {
68 videoHistogram.count(static_cast<int>(m_source)); 69 videoHistogram.count(static_cast<int>(m_source));
69 if (m_element->muted()) 70 if (m_element->muted())
70 mutedVideoHistogram.count(static_cast<int>(m_source)); 71 mutedVideoHistogram.count(static_cast<int>(m_source));
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 221
221 void AutoplayUmaHelper::maybeStopRecordingMutedVideoOffscreenDuration() { 222 void AutoplayUmaHelper::maybeStopRecordingMutedVideoOffscreenDuration() {
222 if (!m_mutedVideoOffscreenDurationVisibilityObserver) 223 if (!m_mutedVideoOffscreenDurationVisibilityObserver)
223 return; 224 return;
224 225
225 if (!m_isVisible) 226 if (!m_isVisible)
226 m_mutedVideoAutoplayOffscreenDurationMS += 227 m_mutedVideoAutoplayOffscreenDurationMS +=
227 static_cast<int64_t>(monotonicallyIncreasingTimeMS()) - 228 static_cast<int64_t>(monotonicallyIncreasingTimeMS()) -
228 m_mutedVideoAutoplayOffscreenStartTimeMS; 229 m_mutedVideoAutoplayOffscreenStartTimeMS;
229 230
230 // Since histograms uses int32_t, the duration needs to be limited to std::num eric_limits<int32_t>::max(). 231 // Since histograms uses int32_t, the duration needs to be limited to
232 // std::numeric_limits<int32_t>::max().
231 int32_t boundedTime = static_cast<int32_t>( 233 int32_t boundedTime = static_cast<int32_t>(
232 std::min<int64_t>(m_mutedVideoAutoplayOffscreenDurationMS, 234 std::min<int64_t>(m_mutedVideoAutoplayOffscreenDurationMS,
233 std::numeric_limits<int32_t>::max())); 235 std::numeric_limits<int32_t>::max()));
234 236
235 if (m_source == AutoplaySource::Attribute) { 237 if (m_source == AutoplaySource::Attribute) {
236 DEFINE_STATIC_LOCAL( 238 DEFINE_STATIC_LOCAL(
237 CustomCountHistogram, durationHistogram, 239 CustomCountHistogram, durationHistogram,
238 ("Media.Video.Autoplay.Muted.Attribute.OffscreenDuration", 1, 240 ("Media.Video.Autoplay.Muted.Attribute.OffscreenDuration", 1,
239 maxOffscreenDurationUmaMS, offscreenDurationUmaBucketCount)); 241 maxOffscreenDurationUmaMS, offscreenDurationUmaBucketCount));
240 durationHistogram.count(boundedTime); 242 durationHistogram.count(boundedTime);
(...skipping 23 matching lines...) Expand all
264 } 266 }
265 267
266 DEFINE_TRACE(AutoplayUmaHelper) { 268 DEFINE_TRACE(AutoplayUmaHelper) {
267 EventListener::trace(visitor); 269 EventListener::trace(visitor);
268 visitor->trace(m_element); 270 visitor->trace(m_element);
269 visitor->trace(m_mutedVideoPlayMethodVisibilityObserver); 271 visitor->trace(m_mutedVideoPlayMethodVisibilityObserver);
270 visitor->trace(m_mutedVideoOffscreenDurationVisibilityObserver); 272 visitor->trace(m_mutedVideoOffscreenDurationVisibilityObserver);
271 } 273 }
272 274
273 } // namespace blink 275 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/AutoplayUmaHelper.h ('k') | third_party/WebKit/Source/core/html/CollectionIndexCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698