 Chromium Code Reviews
 Chromium Code Reviews Issue 2160963002:
  Add watch time metrics for HTML5 media playback.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 2160963002:
  Add watch time metrics for HTML5 media playback.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| OLD | NEW | 
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "media/blink/webmediaplayer_impl.h" | 5 #include "media/blink/webmediaplayer_impl.h" | 
| 6 | 6 | 
| 7 #include <algorithm> | 7 #include <algorithm> | 
| 8 #include <cmath> | 8 #include <cmath> | 
| 9 #include <limits> | 9 #include <limits> | 
| 10 #include <string> | 10 #include <string> | 
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 #include "media/audio/null_audio_sink.h" | 30 #include "media/audio/null_audio_sink.h" | 
| 31 #include "media/base/bind_to_current_loop.h" | 31 #include "media/base/bind_to_current_loop.h" | 
| 32 #include "media/base/cdm_context.h" | 32 #include "media/base/cdm_context.h" | 
| 33 #include "media/base/limits.h" | 33 #include "media/base/limits.h" | 
| 34 #include "media/base/media_log.h" | 34 #include "media/base/media_log.h" | 
| 35 #include "media/base/media_switches.h" | 35 #include "media/base/media_switches.h" | 
| 36 #include "media/base/text_renderer.h" | 36 #include "media/base/text_renderer.h" | 
| 37 #include "media/base/timestamp_constants.h" | 37 #include "media/base/timestamp_constants.h" | 
| 38 #include "media/base/video_frame.h" | 38 #include "media/base/video_frame.h" | 
| 39 #include "media/blink/texttrack_impl.h" | 39 #include "media/blink/texttrack_impl.h" | 
| 40 #include "media/blink/watch_time_reporter.h" | |
| 40 #include "media/blink/webaudiosourceprovider_impl.h" | 41 #include "media/blink/webaudiosourceprovider_impl.h" | 
| 41 #include "media/blink/webcontentdecryptionmodule_impl.h" | 42 #include "media/blink/webcontentdecryptionmodule_impl.h" | 
| 42 #include "media/blink/webinbandtexttrack_impl.h" | 43 #include "media/blink/webinbandtexttrack_impl.h" | 
| 43 #include "media/blink/webmediaplayer_delegate.h" | 44 #include "media/blink/webmediaplayer_delegate.h" | 
| 44 #include "media/blink/webmediaplayer_util.h" | 45 #include "media/blink/webmediaplayer_util.h" | 
| 45 #include "media/blink/webmediasource_impl.h" | 46 #include "media/blink/webmediasource_impl.h" | 
| 46 #include "media/filters/chunk_demuxer.h" | 47 #include "media/filters/chunk_demuxer.h" | 
| 47 #include "media/filters/ffmpeg_demuxer.h" | 48 #include "media/filters/ffmpeg_demuxer.h" | 
| 48 #include "third_party/WebKit/public/platform/WebEncryptedMediaTypes.h" | 49 #include "third_party/WebKit/public/platform/WebEncryptedMediaTypes.h" | 
| 49 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" | 50 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" | 
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 DCHECK_EQ(state > blink::WebMediaPlayer::NetworkStateLoaded, result); | 123 DCHECK_EQ(state > blink::WebMediaPlayer::NetworkStateLoaded, result); | 
| 123 return result; | 124 return result; | 
| 124 } | 125 } | 
| 125 | 126 | 
| 126 gfx::Size GetRotatedVideoSize(VideoRotation rotation, gfx::Size natural_size) { | 127 gfx::Size GetRotatedVideoSize(VideoRotation rotation, gfx::Size natural_size) { | 
| 127 if (rotation == VIDEO_ROTATION_90 || rotation == VIDEO_ROTATION_270) | 128 if (rotation == VIDEO_ROTATION_90 || rotation == VIDEO_ROTATION_270) | 
| 128 return gfx::Size(natural_size.height(), natural_size.width()); | 129 return gfx::Size(natural_size.height(), natural_size.width()); | 
| 129 return natural_size; | 130 return natural_size; | 
| 130 } | 131 } | 
| 131 | 132 | 
| 133 base::TimeDelta GetCurrentTimeInternal(WebMediaPlayerImpl* p_this) { | |
| 134 // We wrap currentTime() instead of using pipeline_.GetMediaTime() since there | |
| 135 // are a variety of cases in which that time is not accurate. | |
| 
sandersd (OOO until July 31)
2016/08/03 22:45:59
Can you expand on those cases here? (That said, cu
 
DaleCurtis
2016/08/04 19:14:59
Done.
 | |
| 136 return base::TimeDelta::FromSecondsD(p_this->currentTime()); | |
| 137 } | |
| 138 | |
| 132 } // namespace | 139 } // namespace | 
| 133 | 140 | 
| 134 class BufferedDataSourceHostImpl; | 141 class BufferedDataSourceHostImpl; | 
| 135 | 142 | 
| 136 STATIC_ASSERT_ENUM(WebMediaPlayer::CORSModeUnspecified, | 143 STATIC_ASSERT_ENUM(WebMediaPlayer::CORSModeUnspecified, | 
| 137 UrlData::CORS_UNSPECIFIED); | 144 UrlData::CORS_UNSPECIFIED); | 
| 138 STATIC_ASSERT_ENUM(WebMediaPlayer::CORSModeAnonymous, UrlData::CORS_ANONYMOUS); | 145 STATIC_ASSERT_ENUM(WebMediaPlayer::CORSModeAnonymous, UrlData::CORS_ANONYMOUS); | 
| 139 STATIC_ASSERT_ENUM(WebMediaPlayer::CORSModeUseCredentials, | 146 STATIC_ASSERT_ENUM(WebMediaPlayer::CORSModeUseCredentials, | 
| 140 UrlData::CORS_USE_CREDENTIALS); | 147 UrlData::CORS_USE_CREDENTIALS); | 
| 141 | 148 | 
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 is_cdm_attached_(false), | 213 is_cdm_attached_(false), | 
| 207 #if defined(OS_ANDROID) // WMPI_CAST | 214 #if defined(OS_ANDROID) // WMPI_CAST | 
| 208 cast_impl_(this, client_, params.context_3d_cb()), | 215 cast_impl_(this, client_, params.context_3d_cb()), | 
| 209 #endif | 216 #endif | 
| 210 volume_(1.0), | 217 volume_(1.0), | 
| 211 volume_multiplier_(1.0), | 218 volume_multiplier_(1.0), | 
| 212 renderer_factory_(std::move(renderer_factory)), | 219 renderer_factory_(std::move(renderer_factory)), | 
| 213 surface_manager_(params.surface_manager()), | 220 surface_manager_(params.surface_manager()), | 
| 214 overlay_surface_id_(SurfaceManager::kNoSurfaceID), | 221 overlay_surface_id_(SurfaceManager::kNoSurfaceID), | 
| 215 suppress_destruction_errors_(false), | 222 suppress_destruction_errors_(false), | 
| 216 can_suspend_state_(CanSuspendState::UNKNOWN) { | 223 can_suspend_state_(CanSuspendState::UNKNOWN), | 
| 224 is_encrypted_(false) { | |
| 217 DCHECK(!adjust_allocated_memory_cb_.is_null()); | 225 DCHECK(!adjust_allocated_memory_cb_.is_null()); | 
| 218 DCHECK(renderer_factory_); | 226 DCHECK(renderer_factory_); | 
| 219 DCHECK(client_); | 227 DCHECK(client_); | 
| 220 | 228 | 
| 221 force_video_overlays_ = base::CommandLine::ForCurrentProcess()->HasSwitch( | 229 force_video_overlays_ = base::CommandLine::ForCurrentProcess()->HasSwitch( | 
| 222 switches::kForceVideoOverlays); | 230 switches::kForceVideoOverlays); | 
| 223 | 231 | 
| 224 if (delegate_) | 232 if (delegate_) | 
| 225 delegate_id_ = delegate_->AddObserver(this); | 233 delegate_id_ = delegate_->AddObserver(this); | 
| 226 | 234 | 
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 387 } | 395 } | 
| 388 #endif | 396 #endif | 
| 389 | 397 | 
| 390 paused_ = false; | 398 paused_ = false; | 
| 391 is_idle_ = false; | 399 is_idle_ = false; | 
| 392 pipeline_.SetPlaybackRate(playback_rate_); | 400 pipeline_.SetPlaybackRate(playback_rate_); | 
| 393 | 401 | 
| 394 if (data_source_) | 402 if (data_source_) | 
| 395 data_source_->MediaIsPlaying(); | 403 data_source_->MediaIsPlaying(); | 
| 396 | 404 | 
| 405 watch_time_reporter_->OnPlaying(); | |
| 397 media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::PLAY)); | 406 media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::PLAY)); | 
| 398 UpdatePlayState(); | 407 UpdatePlayState(); | 
| 399 } | 408 } | 
| 400 | 409 | 
| 401 void WebMediaPlayerImpl::pause() { | 410 void WebMediaPlayerImpl::pause() { | 
| 402 DVLOG(1) << __func__; | 411 DVLOG(1) << __func__; | 
| 403 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 412 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 
| 404 | 413 | 
| 405 // We update the paused state even when casting, since we expect pause() to be | 414 // We update the paused state even when casting, since we expect pause() to be | 
| 406 // called when casting begins, and when we exit casting we should end up in a | 415 // called when casting begins, and when we exit casting we should end up in a | 
| 407 // paused state. | 416 // paused state. | 
| 408 paused_ = true; | 417 paused_ = true; | 
| 409 | 418 | 
| 410 #if defined(OS_ANDROID) // WMPI_CAST | 419 #if defined(OS_ANDROID) // WMPI_CAST | 
| 411 if (isRemote()) { | 420 if (isRemote()) { | 
| 412 cast_impl_.pause(); | 421 cast_impl_.pause(); | 
| 413 return; | 422 return; | 
| 414 } | 423 } | 
| 415 #endif | 424 #endif | 
| 416 | 425 | 
| 417 pipeline_.SetPlaybackRate(0.0); | 426 pipeline_.SetPlaybackRate(0.0); | 
| 418 | 427 | 
| 419 // pause() may be called after playback has ended and the HTMLMediaElement | 428 // pause() may be called after playback has ended and the HTMLMediaElement | 
| 420 // requires that currentTime() == duration() after ending. We want to ensure | 429 // requires that currentTime() == duration() after ending. We want to ensure | 
| 421 // |paused_time_| matches currentTime() in this case or a future seek() may | 430 // |paused_time_| matches currentTime() in this case or a future seek() may | 
| 422 // incorrectly discard what it thinks is a seek to the existing time. | 431 // incorrectly discard what it thinks is a seek to the existing time. | 
| 423 paused_time_ = | 432 paused_time_ = | 
| 424 ended_ ? pipeline_.GetMediaDuration() : pipeline_.GetMediaTime(); | 433 ended_ ? pipeline_.GetMediaDuration() : pipeline_.GetMediaTime(); | 
| 425 | 434 | 
| 435 watch_time_reporter_->OnPaused(); | |
| 426 media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::PAUSE)); | 436 media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::PAUSE)); | 
| 427 UpdatePlayState(); | 437 UpdatePlayState(); | 
| 428 } | 438 } | 
| 429 | 439 | 
| 430 bool WebMediaPlayerImpl::supportsSave() const { | 440 bool WebMediaPlayerImpl::supportsSave() const { | 
| 431 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 441 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 
| 432 return supports_save_; | 442 return supports_save_; | 
| 433 } | 443 } | 
| 434 | 444 | 
| 435 void WebMediaPlayerImpl::seek(double seconds) { | 445 void WebMediaPlayerImpl::seek(double seconds) { | 
| (...skipping 30 matching lines...) Expand all Loading... | |
| 466 // completed just by restoring it. Otherwise we will just wait for the real | 476 // completed just by restoring it. Otherwise we will just wait for the real | 
| 467 // ready state change to eventually happen. | 477 // ready state change to eventually happen. | 
| 468 if (old_state == ReadyStateHaveEnoughData) { | 478 if (old_state == ReadyStateHaveEnoughData) { | 
| 469 main_task_runner_->PostTask( | 479 main_task_runner_->PostTask( | 
| 470 FROM_HERE, base::Bind(&WebMediaPlayerImpl::OnBufferingStateChange, | 480 FROM_HERE, base::Bind(&WebMediaPlayerImpl::OnBufferingStateChange, | 
| 471 AsWeakPtr(), BUFFERING_HAVE_ENOUGH)); | 481 AsWeakPtr(), BUFFERING_HAVE_ENOUGH)); | 
| 472 } | 482 } | 
| 473 return; | 483 return; | 
| 474 } | 484 } | 
| 475 | 485 | 
| 486 // Call this before setting |seeking_| so that the current media time can be | |
| 487 // recorded by the reporter. | |
| 488 watch_time_reporter_->OnSeeking(time); | |
| 489 | |
| 476 // TODO(sandersd): Ideally we would not clear the idle state if | 490 // TODO(sandersd): Ideally we would not clear the idle state if | 
| 477 // |pipeline_controller_| can elide the seek. | 491 // |pipeline_controller_| can elide the seek. | 
| 478 is_idle_ = false; | 492 is_idle_ = false; | 
| 479 ended_ = false; | 493 ended_ = false; | 
| 480 | 494 | 
| 481 seeking_ = true; | 495 seeking_ = true; | 
| 482 seek_time_ = time; | 496 seek_time_ = time; | 
| 483 if (paused_) | 497 if (paused_) | 
| 484 paused_time_ = time; | 498 paused_time_ = time; | 
| 485 pipeline_controller_.Seek(time, time_updated); | 499 pipeline_controller_.Seek(time, time_updated); | 
| (...skipping 26 matching lines...) Expand all Loading... | |
| 512 if (data_source_) | 526 if (data_source_) | 
| 513 data_source_->MediaPlaybackRateChanged(rate); | 527 data_source_->MediaPlaybackRateChanged(rate); | 
| 514 } | 528 } | 
| 515 } | 529 } | 
| 516 | 530 | 
| 517 void WebMediaPlayerImpl::setVolume(double volume) { | 531 void WebMediaPlayerImpl::setVolume(double volume) { | 
| 518 DVLOG(1) << __func__ << "(" << volume << ")"; | 532 DVLOG(1) << __func__ << "(" << volume << ")"; | 
| 519 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 533 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 
| 520 volume_ = volume; | 534 volume_ = volume; | 
| 521 pipeline_.SetVolume(volume_ * volume_multiplier_); | 535 pipeline_.SetVolume(volume_ * volume_multiplier_); | 
| 536 if (watch_time_reporter_) | |
| 537 watch_time_reporter_->OnVolumeChange(volume); | |
| 522 } | 538 } | 
| 523 | 539 | 
| 524 void WebMediaPlayerImpl::setSinkId( | 540 void WebMediaPlayerImpl::setSinkId( | 
| 525 const blink::WebString& sink_id, | 541 const blink::WebString& sink_id, | 
| 526 const blink::WebSecurityOrigin& security_origin, | 542 const blink::WebSecurityOrigin& security_origin, | 
| 527 blink::WebSetSinkIdCallbacks* web_callback) { | 543 blink::WebSetSinkIdCallbacks* web_callback) { | 
| 528 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 544 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 
| 529 DVLOG(1) << __func__; | 545 DVLOG(1) << __func__; | 
| 530 | 546 | 
| 531 media::OutputDeviceStatusCB callback = | 547 media::OutputDeviceStatusCB callback = | 
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 864 } | 880 } | 
| 865 | 881 | 
| 866 void WebMediaPlayerImpl::OnEncryptedMediaInitData( | 882 void WebMediaPlayerImpl::OnEncryptedMediaInitData( | 
| 867 EmeInitDataType init_data_type, | 883 EmeInitDataType init_data_type, | 
| 868 const std::vector<uint8_t>& init_data) { | 884 const std::vector<uint8_t>& init_data) { | 
| 869 DCHECK(init_data_type != EmeInitDataType::UNKNOWN); | 885 DCHECK(init_data_type != EmeInitDataType::UNKNOWN); | 
| 870 | 886 | 
| 871 // TODO(xhwang): Update this UMA name. https://crbug.com/589251 | 887 // TODO(xhwang): Update this UMA name. https://crbug.com/589251 | 
| 872 UMA_HISTOGRAM_COUNTS("Media.EME.NeedKey", 1); | 888 UMA_HISTOGRAM_COUNTS("Media.EME.NeedKey", 1); | 
| 873 | 889 | 
| 890 is_encrypted_ = true; | |
| 874 encrypted_client_->encrypted( | 891 encrypted_client_->encrypted( | 
| 875 ConvertToWebInitDataType(init_data_type), init_data.data(), | 892 ConvertToWebInitDataType(init_data_type), init_data.data(), | 
| 876 base::saturated_cast<unsigned int>(init_data.size())); | 893 base::saturated_cast<unsigned int>(init_data.size())); | 
| 877 } | 894 } | 
| 878 | 895 | 
| 879 void WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated( | 896 void WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated( | 
| 880 std::unique_ptr<MediaTracks> tracks) { | 897 std::unique_ptr<MediaTracks> tracks) { | 
| 881 // For MSE/chunk_demuxer case the media track updates are handled by | 898 // For MSE/chunk_demuxer case the media track updates are handled by | 
| 882 // WebSourceBufferImpl. | 899 // WebSourceBufferImpl. | 
| 883 DCHECK(demuxer_.get()); | 900 DCHECK(demuxer_.get()); | 
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1016 // expected to be a no-op. | 1033 // expected to be a no-op. | 
| 1017 UpdatePlayState(); | 1034 UpdatePlayState(); | 
| 1018 } | 1035 } | 
| 1019 | 1036 | 
| 1020 void WebMediaPlayerImpl::OnMetadata(PipelineMetadata metadata) { | 1037 void WebMediaPlayerImpl::OnMetadata(PipelineMetadata metadata) { | 
| 1021 DVLOG(1) << __func__; | 1038 DVLOG(1) << __func__; | 
| 1022 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1039 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 
| 1023 | 1040 | 
| 1024 pipeline_metadata_ = metadata; | 1041 pipeline_metadata_ = metadata; | 
| 1025 | 1042 | 
| 1043 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); | |
| 1026 UMA_HISTOGRAM_ENUMERATION("Media.VideoRotation", metadata.video_rotation, | 1044 UMA_HISTOGRAM_ENUMERATION("Media.VideoRotation", metadata.video_rotation, | 
| 1027 VIDEO_ROTATION_MAX + 1); | 1045 VIDEO_ROTATION_MAX + 1); | 
| 1028 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); | |
| 1029 | 1046 | 
| 1030 if (hasVideo()) { | 1047 if (hasVideo()) { | 
| 1031 pipeline_metadata_.natural_size = GetRotatedVideoSize( | 1048 pipeline_metadata_.natural_size = GetRotatedVideoSize( | 
| 1032 pipeline_metadata_.video_rotation, pipeline_metadata_.natural_size); | 1049 pipeline_metadata_.video_rotation, pipeline_metadata_.natural_size); | 
| 1033 | 1050 | 
| 1034 if (overlay_enabled_ && surface_manager_) | 1051 if (overlay_enabled_ && surface_manager_) | 
| 1035 surface_manager_->NaturalSizeChanged(pipeline_metadata_.natural_size); | 1052 surface_manager_->NaturalSizeChanged(pipeline_metadata_.natural_size); | 
| 1036 | 1053 | 
| 1037 DCHECK(!video_weblayer_); | 1054 DCHECK(!video_weblayer_); | 
| 1038 video_weblayer_.reset(new cc_blink::WebLayerImpl(cc::VideoLayer::Create( | 1055 video_weblayer_.reset(new cc_blink::WebLayerImpl(cc::VideoLayer::Create( | 
| 1039 compositor_, pipeline_metadata_.video_rotation))); | 1056 compositor_, pipeline_metadata_.video_rotation))); | 
| 1040 video_weblayer_->layer()->SetContentsOpaque(opaque_); | 1057 video_weblayer_->layer()->SetContentsOpaque(opaque_); | 
| 1041 video_weblayer_->SetContentsOpaqueIsFixed(true); | 1058 video_weblayer_->SetContentsOpaqueIsFixed(true); | 
| 1042 client_->setWebLayer(video_weblayer_.get()); | 1059 client_->setWebLayer(video_weblayer_.get()); | 
| 1043 } | 1060 } | 
| 1044 | 1061 | 
| 1062 // Create the watch time reporter and synchronize its initial state. | |
| 1063 watch_time_reporter_.reset( | |
| 1064 new WatchTimeReporter(hasAudio(), hasVideo(), !!chunk_demuxer_, | |
| 1065 is_encrypted_, pipeline_metadata_.natural_size, | |
| 1066 base::Bind(&GetCurrentTimeInternal, this))); | |
| 
sandersd (OOO until July 31)
2016/08/03 22:45:59
What's the reason to not just directly bind curren
 
DaleCurtis
2016/08/04 19:14:59
The detail of currentTime returning a double is sp
 | |
| 1067 watch_time_reporter_->OnVolumeChange(volume_); | |
| 1068 if (delegate_ && delegate_->IsHidden()) | |
| 1069 watch_time_reporter_->OnHidden(); | |
| 1070 else | |
| 1071 watch_time_reporter_->OnShown(); | |
| 1072 | |
| 1045 UpdatePlayState(); | 1073 UpdatePlayState(); | 
| 1046 } | 1074 } | 
| 1047 | 1075 | 
| 1048 void WebMediaPlayerImpl::OnBufferingStateChange(BufferingState state) { | 1076 void WebMediaPlayerImpl::OnBufferingStateChange(BufferingState state) { | 
| 1049 DVLOG(1) << __func__ << "(" << state << ")"; | 1077 DVLOG(1) << __func__ << "(" << state << ")"; | 
| 1050 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1078 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 
| 1051 | 1079 | 
| 1052 // Ignore buffering state changes until we've completed all outstanding | 1080 // Ignore buffering state changes until we've completed all outstanding | 
| 1053 // operations. | 1081 // operations. | 
| 1054 if (!pipeline_controller_.IsStable()) | 1082 if (!pipeline_controller_.IsStable()) | 
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1153 | 1181 | 
| 1154 opaque_ = opaque; | 1182 opaque_ = opaque; | 
| 1155 // Modify content opaqueness of cc::Layer directly so that | 1183 // Modify content opaqueness of cc::Layer directly so that | 
| 1156 // SetContentsOpaqueIsFixed is ignored. | 1184 // SetContentsOpaqueIsFixed is ignored. | 
| 1157 if (video_weblayer_) | 1185 if (video_weblayer_) | 
| 1158 video_weblayer_->layer()->SetContentsOpaque(opaque_); | 1186 video_weblayer_->layer()->SetContentsOpaque(opaque_); | 
| 1159 } | 1187 } | 
| 1160 | 1188 | 
| 1161 void WebMediaPlayerImpl::OnHidden() { | 1189 void WebMediaPlayerImpl::OnHidden() { | 
| 1162 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1190 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 
| 1191 if (watch_time_reporter_) | |
| 1192 watch_time_reporter_->OnHidden(); | |
| 1193 | |
| 1163 UpdatePlayState(); | 1194 UpdatePlayState(); | 
| 1164 | 1195 | 
| 1165 // Schedule suspended playing media to be paused if the user doesn't come back | 1196 // Schedule suspended playing media to be paused if the user doesn't come back | 
| 1166 // to it within some timeout period to avoid any autoplay surprises. | 1197 // to it within some timeout period to avoid any autoplay surprises. | 
| 1167 ScheduleIdlePauseTimer(); | 1198 ScheduleIdlePauseTimer(); | 
| 1168 } | 1199 } | 
| 1169 | 1200 | 
| 1170 void WebMediaPlayerImpl::OnShown() { | 1201 void WebMediaPlayerImpl::OnShown() { | 
| 1171 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1202 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 
| 1203 if (watch_time_reporter_) | |
| 1204 watch_time_reporter_->OnShown(); | |
| 1205 | |
| 1172 must_suspend_ = false; | 1206 must_suspend_ = false; | 
| 1173 background_pause_timer_.Stop(); | 1207 background_pause_timer_.Stop(); | 
| 1174 UpdatePlayState(); | 1208 UpdatePlayState(); | 
| 1175 } | 1209 } | 
| 1176 | 1210 | 
| 1177 void WebMediaPlayerImpl::OnSuspendRequested(bool must_suspend) { | 1211 void WebMediaPlayerImpl::OnSuspendRequested(bool must_suspend) { | 
| 1178 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1212 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 
| 1179 | 1213 | 
| 1180 if (must_suspend) { | 1214 if (must_suspend) { | 
| 1181 must_suspend_ = true; | 1215 must_suspend_ = true; | 
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1726 if (isRemote()) | 1760 if (isRemote()) | 
| 1727 return; | 1761 return; | 
| 1728 #endif | 1762 #endif | 
| 1729 | 1763 | 
| 1730 // Idle timeout chosen arbitrarily. | 1764 // Idle timeout chosen arbitrarily. | 
| 1731 background_pause_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(5), | 1765 background_pause_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(5), | 
| 1732 this, &WebMediaPlayerImpl::OnPause); | 1766 this, &WebMediaPlayerImpl::OnPause); | 
| 1733 } | 1767 } | 
| 1734 | 1768 | 
| 1735 } // namespace media | 1769 } // namespace media | 
| OLD | NEW |