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

Unified Diff: content/common/gpu/media/omx_video_decode_accelerator.h

Issue 10749019: VideoDecodeAccelerator now SupportsWeakPtr instead of being RefCountedThreadSafe. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 5 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/common/gpu/media/omx_video_decode_accelerator.h
diff --git a/content/common/gpu/media/omx_video_decode_accelerator.h b/content/common/gpu/media/omx_video_decode_accelerator.h
index b42a39bb04655f63699702611b62c60694da31b0..1c186a2921ef803cd1d1d1fa2c8d324419a69221 100644
--- a/content/common/gpu/media/omx_video_decode_accelerator.h
+++ b/content/common/gpu/media/omx_video_decode_accelerator.h
@@ -15,7 +15,6 @@
#include "base/compiler_specific.h"
#include "base/logging.h"
-#include "base/memory/ref_counted.h"
#include "base/message_loop.h"
#include "base/shared_memory.h"
#include "content/common/content_export.h"
@@ -32,16 +31,15 @@ class Gles2TextureToEglImageTranslator;
// The implementation assumes an OpenMAX IL 1.1.2 implementation conforming to
// http://www.khronos.org/registry/omxil/specs/OpenMAX_IL_1_1_2_Specification.pdf
//
-// This class lives on a single thread and DCHECKs that it is never accessed
-// from any other. OMX callbacks are trampolined from the OMX component's
-// thread to maintain this invariant. The only exception to thread-unsafety is
-// that references can be added from any thread (practically used only by the
-// OMX thread).
+// This class lives on a single thread (the GPU process ChildThread) and DCHECKs
+// that it is never accessed from any other. OMX callbacks are trampolined from
+// the OMX component's thread to maintain this invariant, using |weak_this()|.
class CONTENT_EXPORT OmxVideoDecodeAccelerator :
public media::VideoDecodeAccelerator {
public:
// Does not take ownership of |client| which must outlive |*this|.
OmxVideoDecodeAccelerator(media::VideoDecodeAccelerator::Client* client);
+ virtual ~OmxVideoDecodeAccelerator();
// media::VideoDecodeAccelerator implementation.
bool Initialize(media::VideoCodecProfile profile) OVERRIDE;
@@ -55,9 +53,9 @@ class CONTENT_EXPORT OmxVideoDecodeAccelerator :
void SetEglState(EGLDisplay egl_display, EGLContext egl_context);
- private:
- virtual ~OmxVideoDecodeAccelerator();
+ base::WeakPtr<OmxVideoDecodeAccelerator> weak_this() { return weak_this_; }
+ private:
// Because OMX state-transitions are described solely by the "state reached"
// (3.1.2.9.1, table 3-7 of the spec), we track what transition was requested
// using this enum. Note that it is an error to request a transition while
@@ -114,7 +112,7 @@ class CONTENT_EXPORT OmxVideoDecodeAccelerator :
void OnReachedEOSInFlushing();
void OnReachedInvalidInErroring();
void ShutdownComponent();
- void BusyLoopInDestroying();
+ void BusyLoopInDestroying(scoped_ptr<OmxVideoDecodeAccelerator> self);
// Port-flushing helpers.
void FlushIOPorts();
@@ -138,6 +136,11 @@ class CONTENT_EXPORT OmxVideoDecodeAccelerator :
// Decode bitstream buffers that were queued (see queued_bitstream_buffers_).
void DecodeQueuedBitstreamBuffers();
+ // Weak pointer to |this|; used to safely trampoline calls from the OMX thread
+ // to the ChildThread. Since |this| is kept alive until OMX is fully shut
+ // down, only the OMX->Child thread direction needs to be guarded this way.
+ base::WeakPtr<OmxVideoDecodeAccelerator> weak_this_;
+
// True once Initialize() has returned true; before this point there's never a
// point in calling client_->NotifyError().
bool init_begun_;
« no previous file with comments | « content/common/gpu/media/mac_video_decode_accelerator.mm ('k') | content/common/gpu/media/omx_video_decode_accelerator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698