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..f39e54af8feb702b79caf6990953e7b9ca7940e0 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" |
|
danakj
2017/01/13 19:32:04
same
emircan
2017/01/13 19:41:09
Done.
|
| #include "media/base/video_frame.h" |
| #include "media/gpu/gpu_video_accelerator_util.h" |
| #include "media/gpu/ipc/common/media_messages.h" |
| @@ -22,6 +23,7 @@ GpuVideoEncodeAcceleratorHost::GpuVideoEncodeAcceleratorHost( |
| client_(nullptr), |
| impl_(impl), |
| next_frame_id_(0), |
| + task_runner_(base::ThreadTaskRunnerHandle::Get()), |
|
danakj
2017/01/13 19:32:04
can you give these task runners a name that descri
emircan
2017/01/13 19:41:09
Done.
|
| weak_this_factory_(this) { |
| DCHECK(channel_); |
| DCHECK(impl_); |
| @@ -32,6 +34,8 @@ 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 +87,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 +180,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( |
| @@ -220,7 +226,7 @@ void GpuVideoEncodeAcceleratorHost::PostNotifyError( |
| << location.file_name() << ":" << location.line_number() << ") " |
| << message << " (error = " << error << ")"; |
| // Post the error notification back to this thread, to avoid re-entrancy. |
| - base::ThreadTaskRunnerHandle::Get()->PostTask( |
| + task_runner_->PostTask( |
| FROM_HERE, base::Bind(&GpuVideoEncodeAcceleratorHost::OnNotifyError, |
| weak_this_factory_.GetWeakPtr(), error)); |
| } |