| Index: media/blink/webmediaplayer_impl.cc
|
| diff --git a/media/blink/webmediaplayer_impl.cc b/media/blink/webmediaplayer_impl.cc
|
| index 1402ec4b22c09ee687ca344c391edac52cd2b4f5..6e4e376653908cfe641f4528e507bd54618c1d43 100644
|
| --- a/media/blink/webmediaplayer_impl.cc
|
| +++ b/media/blink/webmediaplayer_impl.cc
|
| @@ -241,7 +241,6 @@ WebMediaPlayerImpl::WebMediaPlayerImpl(
|
| can_suspend_state_(CanSuspendState::UNKNOWN),
|
| use_fallback_path_(false),
|
| is_encrypted_(false),
|
| - underflow_count_(0),
|
| preroll_attempt_pending_(false),
|
| observer_(params.media_observer()) {
|
| DCHECK(!adjust_allocated_memory_cb_.is_null());
|
| @@ -1116,9 +1115,9 @@ void WebMediaPlayerImpl::OnPipelineSeeked(bool time_updated) {
|
| if (time_updated)
|
| should_notify_time_changed_ = true;
|
|
|
| - // Reset underflow count upon seek; this prevents looping videos and user
|
| - // actions from artificially inflating the underflow count.
|
| - underflow_count_ = 0;
|
| + // Reset underflow duration upon seek; this prevents looping videos and user
|
| + // actions from artificially inflating the duration.
|
| + underflow_timer_.reset();
|
|
|
| // Background video optimizations are delayed when shown/hidden if pipeline
|
| // is seeking.
|
| @@ -1259,13 +1258,10 @@ void WebMediaPlayerImpl::OnBufferingStateChange(BufferingState state) {
|
| "pipeline_buffering_state", state));
|
|
|
| if (state == BUFFERING_HAVE_ENOUGH) {
|
| - if (data_source_ &&
|
| - highest_ready_state_ < WebMediaPlayer::ReadyStateHaveEnoughData) {
|
| - DCHECK_EQ(underflow_count_, 0);
|
| - // Record a zero value for underflow histograms so that the histogram
|
| + if (highest_ready_state_ < WebMediaPlayer::ReadyStateHaveEnoughData) {
|
| + // Record a zero value for underflow histogram so that the histogram
|
| // includes playbacks which never encounter an underflow event.
|
| - UMA_HISTOGRAM_COUNTS_100("Media.UnderflowCount", 0);
|
| - UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", base::TimeDelta());
|
| + RecordUnderflowDuration(base::TimeDelta());
|
| }
|
|
|
| // TODO(chcunningham): Monitor playback position vs buffered. Potentially
|
| @@ -1287,11 +1283,9 @@ void WebMediaPlayerImpl::OnBufferingStateChange(BufferingState state) {
|
| // report once playback starts.
|
| ReportMemoryUsage();
|
|
|
| - // Report the amount of time it took to leave the underflow state. Don't
|
| - // bother to report this for MSE playbacks since it's out of our control.
|
| - if (underflow_timer_ && data_source_) {
|
| - UMA_HISTOGRAM_TIMES("Media.UnderflowDuration",
|
| - underflow_timer_->Elapsed());
|
| + // Report the amount of time it took to leave the underflow state.
|
| + if (underflow_timer_) {
|
| + RecordUnderflowDuration(underflow_timer_->Elapsed());
|
| underflow_timer_.reset();
|
| }
|
| } else {
|
| @@ -1303,7 +1297,6 @@ void WebMediaPlayerImpl::OnBufferingStateChange(BufferingState state) {
|
| // report the value when transitioning from HAVE_ENOUGH to HAVE_NOTHING.
|
| if (data_source_ &&
|
| ready_state_ == WebMediaPlayer::ReadyStateHaveEnoughData) {
|
| - UMA_HISTOGRAM_COUNTS_100("Media.UnderflowCount", ++underflow_count_);
|
| underflow_timer_.reset(new base::ElapsedTimer());
|
| }
|
|
|
| @@ -2273,4 +2266,12 @@ void WebMediaPlayerImpl::ReportTimeFromForegroundToFirstFrame(
|
| }
|
| }
|
|
|
| +void WebMediaPlayerImpl::RecordUnderflowDuration(base::TimeDelta duration) {
|
| + DCHECK(data_source_ || chunk_demuxer_);
|
| + if (data_source_)
|
| + UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", duration);
|
| + else
|
| + UMA_HISTOGRAM_TIMES("Media.UnderflowDuration.MSE", duration);
|
| +}
|
| +
|
| } // namespace media
|
|
|