Chromium Code Reviews| Index: media/gpu/ipc/client/gpu_video_encode_accelerator_host.cc |
| diff --git a/media/gpu/ipc/client/gpu_video_encode_accelerator_host.cc b/media/gpu/ipc/client/gpu_video_encode_accelerator_host.cc |
| index 5a1f3994e21597282489467867bcd0939bab73dc..4590723702a6509d10903abeadc468114dad7112 100644 |
| --- a/media/gpu/ipc/client/gpu_video_encode_accelerator_host.cc |
| +++ b/media/gpu/ipc/client/gpu_video_encode_accelerator_host.cc |
| @@ -8,6 +8,7 @@ |
| #include "base/logging.h" |
| #include "base/threading/thread_task_runner_handle.h" |
| #include "gpu/ipc/client/gpu_channel_host.h" |
| +#include "media/base/bind_to_current_loop.h" |
| #include "media/base/video_frame.h" |
| #include "media/gpu/gpu_video_accelerator_util.h" |
| #include "media/gpu/ipc/common/media_messages.h" |
| @@ -26,12 +27,17 @@ GpuVideoEncodeAcceleratorHost::GpuVideoEncodeAcceleratorHost( |
| DCHECK(channel_); |
| DCHECK(impl_); |
| impl_->AddDeletionObserver(this); |
| + channel_error_cb_ = media::BindToCurrentLoop( |
|
danakj
2017/01/13 18:27:50
same
emircan
2017/01/13 19:08:14
Done.
|
| + base::Bind(&GpuVideoEncodeAcceleratorHost::OnChannelError, |
| + weak_this_factory_.GetWeakPtr())); |
| } |
| GpuVideoEncodeAcceleratorHost::~GpuVideoEncodeAcceleratorHost() { |
| DCHECK(CalledOnValidThread()); |
| if (channel_ && encoder_route_id_ != MSG_ROUTING_NONE) |
| channel_->RemoveRoute(encoder_route_id_); |
| + |
| + base::AutoLock lock(impl_lock_); |
| if (impl_) |
| impl_->RemoveDeletionObserver(this); |
| } |
| @@ -83,6 +89,8 @@ bool GpuVideoEncodeAcceleratorHost::Initialize( |
| Client* client) { |
| DCHECK(CalledOnValidThread()); |
| client_ = client; |
| + |
| + base::AutoLock lock(impl_lock_); |
| if (!impl_) { |
| DLOG(ERROR) << "impl_ destroyed"; |
| return false; |
| @@ -174,11 +182,11 @@ void GpuVideoEncodeAcceleratorHost::Destroy() { |
| } |
| void GpuVideoEncodeAcceleratorHost::OnWillDeleteImpl() { |
| - DCHECK(CalledOnValidThread()); |
| + base::AutoLock lock(impl_lock_); |
| impl_ = nullptr; |
| // The gpu::CommandBufferProxyImpl is going away; error out this VEA. |
| - OnChannelError(); |
| + channel_error_cb_.Run(); |
| } |
| void GpuVideoEncodeAcceleratorHost::EncodeSharedMemoryFrame( |