Chromium Code Reviews| Index: third_party/WebKit/Source/core/html/media/AutoplayUmaHelper.cpp |
| diff --git a/third_party/WebKit/Source/core/html/media/AutoplayUmaHelper.cpp b/third_party/WebKit/Source/core/html/media/AutoplayUmaHelper.cpp |
| index 410dcc50e41ceff3d8ab904d199a1d7c02fe58e0..09d38142f9466741908e09b95778c2acd508dffd 100644 |
| --- a/third_party/WebKit/Source/core/html/media/AutoplayUmaHelper.cpp |
| +++ b/third_party/WebKit/Source/core/html/media/AutoplayUmaHelper.cpp |
| @@ -21,6 +21,8 @@ namespace { |
| const int32_t kMaxOffscreenDurationUmaMS = 60 * 60 * 1000; |
| const int32_t kOffscreenDurationUmaBucketCount = 50; |
| +const int32_t kMaxWaitTimeUmaMS = 30 * 1000; |
| +const int32_t kWaitTimeBucketCount = 50; |
| } // namespace |
| @@ -36,7 +38,8 @@ AutoplayUmaHelper::AutoplayUmaHelper(HTMLMediaElement* element) |
| muted_video_autoplay_offscreen_start_time_ms_(0), |
| muted_video_autoplay_offscreen_duration_ms_(0), |
| is_visible_(false), |
| - muted_video_offscreen_duration_visibility_observer_(nullptr) {} |
| + muted_video_offscreen_duration_visibility_observer_(nullptr), |
| + load_start_time_ms_(0.0) {} |
| AutoplayUmaHelper::~AutoplayUmaHelper() = default; |
| @@ -44,7 +47,19 @@ bool AutoplayUmaHelper::operator==(const EventListener& other) const { |
| return this == &other; |
| } |
| +void AutoplayUmaHelper::OnLoadStarted(WebMediaPlayer::LoadType load_type) { |
| + if (load_type == WebMediaPlayer::kLoadTypeURL) { |
| + load_start_time_ms_ = MonotonicallyIncreasingTimeMS(); |
| + } |
|
mlamouri (slow - plz ping)
2017/05/15 14:31:21
style: should drop the { }
hubbe
2017/05/15 22:32:00
Done.
|
| +} |
| + |
| void AutoplayUmaHelper::OnAutoplayInitiated(AutoplaySource source) { |
| + int32_t autoplay_wait_time_ms = -1; |
|
mlamouri (slow - plz ping)
2017/05/15 14:31:20
You could use optional here instead of setting to
hubbe
2017/05/15 22:32:00
Acknowledged.
|
| + if (load_start_time_ms_ != 0.0) { |
| + autoplay_wait_time_ms = static_cast<int32_t>( |
| + std::min<int64_t>(MonotonicallyIncreasingTimeMS() - load_start_time_ms_, |
| + std::numeric_limits<int32_t>::max())); |
| + } |
| DEFINE_STATIC_LOCAL(EnumerationHistogram, video_histogram, |
| ("Media.Video.Autoplay", |
| static_cast<int>(AutoplaySource::kNumberOfUmaSources))); |
| @@ -58,6 +73,19 @@ void AutoplayUmaHelper::OnAutoplayInitiated(AutoplaySource source) { |
| EnumerationHistogram, blocked_muted_video_histogram, |
| ("Media.Video.Autoplay.Muted.Blocked", kAutoplayBlockedReasonMax)); |
| + DEFINE_STATIC_LOCAL(CustomCountHistogram, wait_time_video_attrib_histogram, |
| + ("Media.Video.Autoplay.Video.Attribute.WaitTime", 1, |
| + kMaxWaitTimeUmaMS, kWaitTimeBucketCount)); |
| + DEFINE_STATIC_LOCAL(CustomCountHistogram, wait_time_audio_attrib_histogram, |
| + ("Media.Video.Autoplay.Audio.Attribute.WaitTime", 1, |
| + kMaxWaitTimeUmaMS, kWaitTimeBucketCount)); |
| + DEFINE_STATIC_LOCAL(CustomCountHistogram, wait_time_video_play_histogram, |
| + ("Media.Video.Autoplay.Video.PlayMethod.WaitTime", 1, |
| + kMaxWaitTimeUmaMS, kWaitTimeBucketCount)); |
| + DEFINE_STATIC_LOCAL(CustomCountHistogram, wait_time_audio_play_histogram, |
| + ("Media.Video.Autoplay.Audio.PlayMethod.WaitTime", 1, |
| + kMaxWaitTimeUmaMS, kWaitTimeBucketCount)); |
|
mlamouri (slow - plz ping)
2017/05/15 14:31:21
Shouldn't this be Media.Audio.Autoplay instead of
hubbe
2017/05/15 22:32:00
Done.
|
| + |
| // Autoplay already initiated |
| if (sources_.count(source)) |
| return; |
| @@ -69,8 +97,22 @@ void AutoplayUmaHelper::OnAutoplayInitiated(AutoplaySource source) { |
| video_histogram.Count(static_cast<int>(source)); |
| if (element_->muted()) |
| muted_video_histogram.Count(static_cast<int>(source)); |
| + if (autoplay_wait_time_ms >= 0) { |
| + if (source == AutoplaySource::kAttribute) { |
| + wait_time_video_attrib_histogram.Count(autoplay_wait_time_ms); |
| + } else if (source == AutoplaySource::kMethod) { |
| + wait_time_video_play_histogram.Count(autoplay_wait_time_ms); |
|
mlamouri (slow - plz ping)
2017/05/15 14:31:20
Will your change have an effect on `play()`? Autop
hubbe
2017/05/15 22:32:00
It shouldn't affect code that calls play() immedia
|
| + } |
| + } |
| } else { |
| audio_histogram.Count(static_cast<int>(source)); |
| + if (autoplay_wait_time_ms >= 0) { |
| + if (source == AutoplaySource::kAttribute) { |
| + wait_time_audio_attrib_histogram.Count(autoplay_wait_time_ms); |
| + } else if (source == AutoplaySource::kMethod) { |
| + wait_time_audio_play_histogram.Count(autoplay_wait_time_ms); |
| + } |
| + } |
| } |
| // Record dual source. |