Chromium Code Reviews

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

Issue 2813303005: [Blink>Media] Moving autoplay logic to AutoplayPolicy (Closed)
Patch Set: fixed event order for setMuted and added comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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/media/AutoplayUmaHelper.h" 5 #include "core/html/media/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/Settings.h" 10 #include "core/frame/Settings.h"
11 #include "core/html/HTMLMediaElement.h" 11 #include "core/html/HTMLMediaElement.h"
12 #include "core/html/media/AutoplayPolicy.h"
12 #include "platform/Histogram.h" 13 #include "platform/Histogram.h"
13 #include "platform/wtf/CurrentTime.h" 14 #include "platform/wtf/CurrentTime.h"
14 #include "public/platform/Platform.h" 15 #include "public/platform/Platform.h"
15 16
16 namespace blink { 17 namespace blink {
17 18
18 namespace { 19 namespace {
19 20
20 const int32_t kMaxOffscreenDurationUmaMS = 60 * 60 * 1000; 21 const int32_t kMaxOffscreenDurationUmaMS = 60 * 60 * 1000;
21 const int32_t kOffscreenDurationUmaBucketCount = 50; 22 const int32_t kOffscreenDurationUmaBucketCount = 50;
(...skipping 81 matching lines...)
103 element_->GetDocument().Url()); 104 element_->GetDocument().Url());
104 } 105 }
105 } 106 }
106 107
107 // Record if it will be blocked by Data Saver or Autoplay setting. 108 // Record if it will be blocked by Data Saver or Autoplay setting.
108 if (element_->IsHTMLVideoElement() && element_->muted() && 109 if (element_->IsHTMLVideoElement() && element_->muted() &&
109 RuntimeEnabledFeatures::autoplayMutedVideosEnabled()) { 110 RuntimeEnabledFeatures::autoplayMutedVideosEnabled()) {
110 bool data_saver_enabled = 111 bool data_saver_enabled =
111 element_->GetDocument().GetSettings() && 112 element_->GetDocument().GetSettings() &&
112 element_->GetDocument().GetSettings()->GetDataSaverEnabled(); 113 element_->GetDocument().GetSettings()->GetDataSaverEnabled();
113 bool blocked_by_setting = !element_->IsAutoplayAllowedPerSettings(); 114 bool blocked_by_setting =
115 !element_->autoplay_policy().IsAutoplayAllowedPerSettings();
114 116
115 if (data_saver_enabled && blocked_by_setting) { 117 if (data_saver_enabled && blocked_by_setting) {
116 blocked_muted_video_histogram.Count( 118 blocked_muted_video_histogram.Count(
117 kAutoplayBlockedReasonDataSaverAndSetting); 119 kAutoplayBlockedReasonDataSaverAndSetting);
118 } else if (data_saver_enabled) { 120 } else if (data_saver_enabled) {
119 blocked_muted_video_histogram.Count(kAutoplayBlockedReasonDataSaver); 121 blocked_muted_video_histogram.Count(kAutoplayBlockedReasonDataSaver);
120 } else if (blocked_by_setting) { 122 } else if (blocked_by_setting) {
121 blocked_muted_video_histogram.Count(kAutoplayBlockedReasonSetting); 123 blocked_muted_video_histogram.Count(kAutoplayBlockedReasonSetting);
122 } 124 }
123 } 125 }
(...skipping 265 matching lines...)
389 391
390 DEFINE_TRACE(AutoplayUmaHelper) { 392 DEFINE_TRACE(AutoplayUmaHelper) {
391 EventListener::Trace(visitor); 393 EventListener::Trace(visitor);
392 ContextLifecycleObserver::Trace(visitor); 394 ContextLifecycleObserver::Trace(visitor);
393 visitor->Trace(element_); 395 visitor->Trace(element_);
394 visitor->Trace(muted_video_play_method_visibility_observer_); 396 visitor->Trace(muted_video_play_method_visibility_observer_);
395 visitor->Trace(muted_video_offscreen_duration_visibility_observer_); 397 visitor->Trace(muted_video_offscreen_duration_visibility_observer_);
396 } 398 }
397 399
398 } // namespace blink 400 } // namespace blink
OLDNEW

Powered by Google App Engine