diff options
author | dongseong.hwang <dongseong.hwang@intel.com> | 2015-02-10 11:39:59 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-10 19:40:39 +0000 |
commit | ee88f0aaa7399aad0a80aec0161eff383dccf4ac (patch) | |
tree | 99a6f5ea8b17bb8f03d9b0dc942b18ac741f5ace /cc | |
parent | 096728d805d97a3b41aad87ecf861c58a44a20bb (diff) | |
download | chromium_src-ee88f0aaa7399aad0a80aec0161eff383dccf4ac.zip chromium_src-ee88f0aaa7399aad0a80aec0161eff383dccf4ac.tar.gz chromium_src-ee88f0aaa7399aad0a80aec0161eff383dccf4ac.tar.bz2 |
cc: Add thread check in VideoFrameProviderClientImpl
Review URL: https://codereview.chromium.org/903093002
Cr-Commit-Position: refs/heads/master@{#315616}
Diffstat (limited to 'cc')
-rw-r--r-- | cc/layers/video_frame_provider_client_impl.cc | 21 | ||||
-rw-r--r-- | cc/layers/video_frame_provider_client_impl.h | 8 | ||||
-rw-r--r-- | cc/layers/video_layer_impl.cc | 2 |
3 files changed, 26 insertions, 5 deletions
diff --git a/cc/layers/video_frame_provider_client_impl.cc b/cc/layers/video_frame_provider_client_impl.cc index 2b12567..4bbd92f 100644 --- a/cc/layers/video_frame_provider_client_impl.cc +++ b/cc/layers/video_frame_provider_client_impl.cc @@ -39,15 +39,32 @@ VideoFrameProviderClientImpl::VideoFrameProviderClientImpl( 0.0, 0.0, 0.0, 1.0); } +void VideoFrameProviderClientImpl::SetActiveVideoLayer( + VideoLayerImpl* video_layer) { + DCHECK(thread_checker_.CalledOnValidThread()); + DCHECK(video_layer); + active_video_layer_ = video_layer; +} + void VideoFrameProviderClientImpl::Stop() { + // It's called when the main thread is blocked, so lock isn't needed. if (!provider_) return; + DCHECK(thread_checker_.CalledOnValidThread()); provider_->SetVideoFrameProviderClient(nullptr); provider_ = nullptr; } +bool VideoFrameProviderClientImpl::Stopped() { + DCHECK(thread_checker_.CalledOnValidThread()); + // |provider_| is changed while the main thread is blocked, and not changed + // thereafter, so lock isn't needed. + return !provider_; +} + scoped_refptr<media::VideoFrame> VideoFrameProviderClientImpl::AcquireLockAndCurrentFrame() { + DCHECK(thread_checker_.CalledOnValidThread()); provider_lock_.Acquire(); // Balanced by call to ReleaseLock(). if (!provider_) return nullptr; @@ -57,11 +74,13 @@ VideoFrameProviderClientImpl::AcquireLockAndCurrentFrame() { void VideoFrameProviderClientImpl::PutCurrentFrame( const scoped_refptr<media::VideoFrame>& frame) { + DCHECK(thread_checker_.CalledOnValidThread()); provider_lock_.AssertAcquired(); provider_->PutCurrentFrame(frame); } void VideoFrameProviderClientImpl::ReleaseLock() { + DCHECK(thread_checker_.CalledOnValidThread()); provider_lock_.AssertAcquired(); provider_lock_.Release(); } @@ -78,11 +97,13 @@ void VideoFrameProviderClientImpl::DidReceiveFrame() { "VideoFrameProviderClientImpl::DidReceiveFrame", "active_video_layer", !!active_video_layer_); + DCHECK(thread_checker_.CalledOnValidThread()); if (active_video_layer_) active_video_layer_->SetNeedsRedraw(); } void VideoFrameProviderClientImpl::DidUpdateMatrix(const float* matrix) { + DCHECK(thread_checker_.CalledOnValidThread()); stream_texture_matrix_ = gfx::Transform( matrix[0], matrix[4], matrix[8], matrix[12], matrix[1], matrix[5], matrix[9], matrix[13], diff --git a/cc/layers/video_frame_provider_client_impl.h b/cc/layers/video_frame_provider_client_impl.h index b6eb86f..39f66fb 100644 --- a/cc/layers/video_frame_provider_client_impl.h +++ b/cc/layers/video_frame_provider_client_impl.h @@ -7,6 +7,7 @@ #include "base/memory/ref_counted.h" #include "base/synchronization/lock.h" +#include "base/threading/thread_checker.h" #include "cc/layers/video_frame_provider.h" #include "ui/gfx/transform.h" @@ -23,12 +24,10 @@ class VideoFrameProviderClientImpl VideoFrameProvider* provider); VideoLayerImpl* active_video_layer() { return active_video_layer_; } - void set_active_video_layer(VideoLayerImpl* video_layer) { - active_video_layer_ = video_layer; - } + void SetActiveVideoLayer(VideoLayerImpl* video_layer); void Stop(); - bool Stopped() const { return !provider_; } + bool Stopped(); scoped_refptr<media::VideoFrame> AcquireLockAndCurrentFrame(); void PutCurrentFrame(const scoped_refptr<media::VideoFrame>& frame); @@ -53,6 +52,7 @@ class VideoFrameProviderClientImpl // Guards the destruction of provider_ and the frame that it provides base::Lock provider_lock_; VideoFrameProvider* provider_; + base::ThreadChecker thread_checker_; gfx::Transform stream_texture_matrix_; diff --git a/cc/layers/video_layer_impl.cc b/cc/layers/video_layer_impl.cc index 091f2a97..209d10f 100644 --- a/cc/layers/video_layer_impl.cc +++ b/cc/layers/video_layer_impl.cc @@ -72,7 +72,7 @@ void VideoLayerImpl::PushPropertiesTo(LayerImpl* layer) { } void VideoLayerImpl::DidBecomeActive() { - provider_client_impl_->set_active_video_layer(this); + provider_client_impl_->SetActiveVideoLayer(this); } bool VideoLayerImpl::WillDraw(DrawMode draw_mode, |