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..a3d91ba2e35fb706b1ddb096a323b073637a9407 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), |
| + created_time_ms_(MonotonicallyIncreasingTimeMS()) {} |
| AutoplayUmaHelper::~AutoplayUmaHelper() = default; |
| @@ -45,6 +48,10 @@ bool AutoplayUmaHelper::operator==(const EventListener& other) const { |
| } |
| void AutoplayUmaHelper::OnAutoplayInitiated(AutoplaySource source) { |
| + int32_t autoplay_wait_time_ms = static_cast<int32_t>( |
|
Zhiqiang Zhang (Slow)
2017/05/01 23:44:55
Do we need to distinguish the autoplay sources?
hubbe
2017/05/02 00:05:31
That's probably a good idea, done.
|
| + std::min<int64_t>(MonotonicallyIncreasingTimeMS() - created_time_ms_, |
| + std::numeric_limits<int32_t>::max())); |
| + |
| DEFINE_STATIC_LOCAL(EnumerationHistogram, video_histogram, |
| ("Media.Video.Autoplay", |
| static_cast<int>(AutoplaySource::kNumberOfUmaSources))); |
| @@ -58,6 +65,15 @@ void AutoplayUmaHelper::OnAutoplayInitiated(AutoplaySource source) { |
| EnumerationHistogram, blocked_muted_video_histogram, |
| ("Media.Video.Autoplay.Muted.Blocked", kAutoplayBlockedReasonMax)); |
| + DEFINE_STATIC_LOCAL(CustomCountHistogram, wait_time_video_histogram, |
| + ("Media.Video.Autoplay.Video.WaitTimeMS", 1, |
|
Zhiqiang Zhang (Slow)
2017/05/01 23:44:55
You probably forgot to add the new histograms to h
hubbe
2017/05/02 00:05:31
OOps, yes added.
(Should I add you as an additiona
Zhiqiang Zhang (Slow)
2017/05/02 00:12:05
I left chromium recently so no need to add me.
|
| + kMaxWaitTimeUmaMS, kWaitTimeBucketCount)); |
| + DEFINE_STATIC_LOCAL(CustomCountHistogram, wait_time_audio_histogram, |
| + ("Media.Video.Autoplay.Audio.WaitTimeMS", 1, |
| + kMaxWaitTimeUmaMS, kWaitTimeBucketCount)); |
| + |
| + bool first_autoplay = sources_.empty(); |
| + |
| // Autoplay already initiated |
| if (sources_.count(source)) |
| return; |
| @@ -86,6 +102,14 @@ void AutoplayUmaHelper::OnAutoplayInitiated(AutoplaySource source) { |
| } |
| } |
| + if (first_autoplay) { |
| + if (element_->IsHTMLVideoElement()) { |
| + wait_time_video_histogram.Count(autoplay_wait_time_ms); |
| + } else { |
| + wait_time_audio_histogram.Count(autoplay_wait_time_ms); |
| + } |
| + } |
| + |
| // Record the child frame and top-level frame URLs for autoplay muted videos |
| // by attribute. |
| if (element_->IsHTMLVideoElement() && element_->muted()) { |