Chromium Code Reviews| Index: media/gpu/ipc/client/gpu_video_decode_accelerator_host.cc |
| diff --git a/media/gpu/ipc/client/gpu_video_decode_accelerator_host.cc b/media/gpu/ipc/client/gpu_video_decode_accelerator_host.cc |
| index 94d53179e207707debf6a7cd2b11cbc96dab5ddd..3be0fd2c9d13f14df751ce340e4293f0b866efc2 100644 |
| --- a/media/gpu/ipc/client/gpu_video_decode_accelerator_host.cc |
| +++ b/media/gpu/ipc/client/gpu_video_decode_accelerator_host.cc |
| @@ -12,6 +12,7 @@ |
| #include "gpu/ipc/client/gpu_channel_host.h" |
| #include "ipc/ipc_message_macros.h" |
| #include "ipc/ipc_message_utils.h" |
| +#include "media/base/bind_to_current_loop.h" |
|
danakj
2017/01/13 19:32:04
unused then
emircan
2017/01/13 19:41:09
Sorry i missed out. Removing.
|
| #include "media/gpu/ipc/common/media_messages.h" |
| namespace media { |
| @@ -20,8 +21,9 @@ GpuVideoDecodeAcceleratorHost::GpuVideoDecodeAcceleratorHost( |
| gpu::CommandBufferProxyImpl* impl) |
| : channel_(impl->channel()), |
| decoder_route_id_(MSG_ROUTING_NONE), |
| - client_(NULL), |
| + client_(nullptr), |
| impl_(impl), |
| + task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| weak_this_factory_(this) { |
| DCHECK(channel_); |
| DCHECK(impl_); |
| @@ -33,6 +35,8 @@ GpuVideoDecodeAcceleratorHost::~GpuVideoDecodeAcceleratorHost() { |
| if (channel_ && decoder_route_id_ != MSG_ROUTING_NONE) |
| channel_->RemoveRoute(decoder_route_id_); |
| + |
| + base::AutoLock lock(impl_lock_); |
| if (impl_) |
| impl_->RemoveDeletionObserver(this); |
| } |
| @@ -68,7 +72,7 @@ void GpuVideoDecodeAcceleratorHost::OnChannelError() { |
| if (channel_) { |
| if (decoder_route_id_ != MSG_ROUTING_NONE) |
| channel_->RemoveRoute(decoder_route_id_); |
| - channel_ = NULL; |
| + channel_ = nullptr; |
| } |
| DLOG(ERROR) << "OnChannelError()"; |
| PostNotifyError(PLATFORM_FAILURE); |
| @@ -79,6 +83,7 @@ bool GpuVideoDecodeAcceleratorHost::Initialize(const Config& config, |
| DCHECK(CalledOnValidThread()); |
| client_ = client; |
| + base::AutoLock lock(impl_lock_); |
| if (!impl_) |
| return false; |
| @@ -175,22 +180,24 @@ void GpuVideoDecodeAcceleratorHost::Destroy() { |
| DCHECK(CalledOnValidThread()); |
| if (channel_) |
| Send(new AcceleratedVideoDecoderMsg_Destroy(decoder_route_id_)); |
| - client_ = NULL; |
| + client_ = nullptr; |
| delete this; |
| } |
| void GpuVideoDecodeAcceleratorHost::OnWillDeleteImpl() { |
| - DCHECK(CalledOnValidThread()); |
| - impl_ = NULL; |
| + base::AutoLock lock(impl_lock_); |
| + impl_ = nullptr; |
| // The gpu::CommandBufferProxyImpl is going away; error out this VDA. |
| - OnChannelError(); |
| + task_runner_->PostTask( |
| + FROM_HERE, base::Bind(&GpuVideoDecodeAcceleratorHost::OnChannelError, |
| + weak_this_factory_.GetWeakPtr())); |
| } |
| void GpuVideoDecodeAcceleratorHost::PostNotifyError(Error error) { |
| DCHECK(CalledOnValidThread()); |
| DVLOG(2) << "PostNotifyError(): error=" << error; |
| - base::ThreadTaskRunnerHandle::Get()->PostTask( |
| + task_runner_->PostTask( |
| FROM_HERE, base::Bind(&GpuVideoDecodeAcceleratorHost::OnNotifyError, |
| weak_this_factory_.GetWeakPtr(), error)); |
| } |
| @@ -280,7 +287,7 @@ void GpuVideoDecodeAcceleratorHost::OnNotifyError(uint32_t error) { |
| // Client::NotifyError() may Destroy() |this|, so calling it needs to be the |
| // last thing done on this stack! |
| - VideoDecodeAccelerator::Client* client = NULL; |
| + VideoDecodeAccelerator::Client* client = nullptr; |
| std::swap(client, client_); |
| client->NotifyError(static_cast<VideoDecodeAccelerator::Error>(error)); |
| } |