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

Unified Diff: content/renderer/media/renderer_gpu_video_decoder_factories.cc

Issue 10832264: Fix lifecycle-vs-threads of GpuVDAContext3D. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fwd declare callback class. Created 8 years, 4 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
Index: content/renderer/media/renderer_gpu_video_decoder_factories.cc
diff --git a/content/renderer/media/renderer_gpu_video_decoder_factories.cc b/content/renderer/media/renderer_gpu_video_decoder_factories.cc
index a64ddbdbdc7558af5bee8bdb2cef6a9072a22bb1..9fa05b31cac775495dff1a09c07806da86974f0b 100644
--- a/content/renderer/media/renderer_gpu_video_decoder_factories.cc
+++ b/content/renderer/media/renderer_gpu_video_decoder_factories.cc
@@ -19,14 +19,11 @@ RendererGpuVideoDecoderFactories::~RendererGpuVideoDecoderFactories() {}
RendererGpuVideoDecoderFactories::RendererGpuVideoDecoderFactories(
GpuChannelHost* gpu_channel_host,
const scoped_refptr<base::MessageLoopProxy>& message_loop,
- const base::WeakPtr<WebGraphicsContext3DCommandBufferImpl>& context)
+ WebGraphicsContext3DCommandBufferImpl* context)
: message_loop_(message_loop),
- gpu_channel_host_(gpu_channel_host),
- context_(context) {
- DCHECK(context_);
- context_->DetachFromThread();
+ gpu_channel_host_(gpu_channel_host) {
if (message_loop_->BelongsToCurrentThread()) {
- AsyncGetContext(NULL);
+ AsyncGetContext(context, NULL);
return;
}
// Threaded compositor requires us to wait for the context to be acquired.
@@ -36,12 +33,20 @@ RendererGpuVideoDecoderFactories::RendererGpuVideoDecoderFactories(
// Unretained to avoid ref/deref'ing |*this|, which is not yet stored in a
// scoped_refptr. Safe because the Wait() below keeps us alive until this
// task completes.
- base::Unretained(this), &waiter));
+ base::Unretained(this),
+ // OK to pass raw because the pointee is only deleted on the compositor
+ // thread, and only as the result of a PostTask from the render thread
+ // which can only happen after this function returns, so our PostTask will
+ // run first.
+ context,
+ &waiter));
waiter.Wait();
}
void RendererGpuVideoDecoderFactories::AsyncGetContext(
+ WebGraphicsContext3DCommandBufferImpl* context,
base::WaitableEvent* waiter) {
+ context_ = context->AsWeakPtr();
if (context_)
context_->makeContextCurrent();
if (waiter)
« no previous file with comments | « content/renderer/media/renderer_gpu_video_decoder_factories.h ('k') | content/renderer/render_thread_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698