Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1780)

Unified Diff: media/gpu/ipc/client/gpu_video_encode_accelerator_host.cc

Issue 2627173002: Adds locks for CommandBufferProxyImpl invalidation (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/gpu/ipc/client/gpu_video_encode_accelerator_host.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..df9f14225d96fec9aa504bc1051ec248612bcae5 100644
--- a/media/gpu/ipc/client/gpu_video_encode_accelerator_host.cc
+++ b/media/gpu/ipc/client/gpu_video_encode_accelerator_host.cc
@@ -22,6 +22,7 @@ GpuVideoEncodeAcceleratorHost::GpuVideoEncodeAcceleratorHost(
client_(nullptr),
impl_(impl),
next_frame_id_(0),
+ media_task_runner_(base::ThreadTaskRunnerHandle::Get()),
weak_this_factory_(this) {
DCHECK(channel_);
DCHECK(impl_);
@@ -32,6 +33,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 +86,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 +179,13 @@ 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();
+ media_task_runner_->PostTask(
+ FROM_HERE, base::Bind(&GpuVideoEncodeAcceleratorHost::OnChannelError,
+ weak_this_factory_.GetWeakPtr()));
}
void GpuVideoEncodeAcceleratorHost::EncodeSharedMemoryFrame(
@@ -220,7 +227,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(
+ media_task_runner_->PostTask(
FROM_HERE, base::Bind(&GpuVideoEncodeAcceleratorHost::OnNotifyError,
weak_this_factory_.GetWeakPtr(), error));
}
« no previous file with comments | « media/gpu/ipc/client/gpu_video_encode_accelerator_host.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698