Chromium Code Reviews| Index: media/remoting/remoting_renderer_controller.cc |
| diff --git a/media/remoting/remoting_renderer_controller.cc b/media/remoting/remoting_renderer_controller.cc |
| index 5f0d37eacdbc7a5939d49d5b0941e7077d07da8f..503005d2880a4c726959e97c6f65ca45fefb55f8 100644 |
| --- a/media/remoting/remoting_renderer_controller.cc |
| +++ b/media/remoting/remoting_renderer_controller.cc |
| @@ -73,6 +73,26 @@ void RemotingRendererController::OnSetCdm(CdmContext* cdm_context) { |
| UpdateAndMaybeSwitch(); |
| } |
| +void RemotingRendererController::OnSetPoster(const GURL& poster_url) { |
| + DCHECK(thread_checker_.CalledOnValidThread()); |
| + |
| + const GURL old_url = poster_url_; |
| + poster_url_ = poster_url; |
| + |
| + // TODO(xjz): Only download the image when we need to draw/update remoting |
|
miu
2016/12/20 23:34:22
I'm not sure this is what we would want. It could
xjz
2016/12/21 01:28:40
hmm, I think we don't want to download and keep a
|
| + // interstitial. Early return if the show interstitial callback is not set. |
| + // https://codereview.chromium.org/2566223005/. |
| + if (download_poster_cb_.is_null()) |
| + return; |
| + |
| + if (old_url != poster_url_) { |
| + download_poster_cb_.Run( |
| + poster_url_, |
| + base::Bind(&RemotingRendererController::OnPosterImageDownloaded, |
| + weak_factory_.GetWeakPtr(), poster_url_)); |
| + } |
| +} |
| + |
| void RemotingRendererController::SetSwitchRendererCallback( |
| const base::Closure& cb) { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| @@ -243,4 +263,30 @@ void RemotingRendererController::UpdateAndMaybeSwitch() { |
| } |
| } |
| +void RemotingRendererController::SetDownloadPosterCallback( |
| + const DownloadPosterCallback& cb) { |
| + DCHECK(thread_checker_.CalledOnValidThread()); |
| + DCHECK(download_poster_cb_.is_null()); |
| + download_poster_cb_ = cb; |
|
miu
2016/12/20 23:34:22
This just occurred to me: What if the poster URL i
xjz
2016/12/21 01:28:40
Done. I didn't realize this. Thanks for pointing t
|
| +} |
| + |
| +void RemotingRendererController::UpdateInterstitial(const SkBitmap& image) { |
| + DCHECK(thread_checker_.CalledOnValidThread()); |
| + if (pipeline_metadata_.natural_size.IsEmpty() || !remote_rendering_started_) |
| + return; |
| + |
| + // TODO(xjz): Update interstitial. |
| + // https://codereview.chromium.org/2566223005/ |
| +} |
| + |
| +void RemotingRendererController::OnPosterImageDownloaded( |
| + const GURL& download_url, |
| + const SkBitmap& image) { |
| + DCHECK(thread_checker_.CalledOnValidThread()); |
| + |
| + if (download_url != poster_url_) |
| + return; // The poster image URL has changed during the download. |
| + UpdateInterstitial(image); |
| +} |
| + |
| } // namespace media |