From c5addfbb9cb0518d8346cc9b827c2a5e8c32957d Mon Sep 17 00:00:00 2001 From: "scherkus@chromium.org" Date: Thu, 29 Jan 2009 03:30:52 +0000 Subject: Moved RefCountedThreadSafe from AssignableBuffer to base type Assignable. Fixed some template naming and whitespace issues as well. Review URL: http://codereview.chromium.org/18854 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8867 0039d316-1c4b-4281-b951-d872f2087c98 --- media/base/buffers.h | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'media/base') diff --git a/media/base/buffers.h b/media/base/buffers.h index 7f0ddb8..7a3d856 100644 --- a/media/base/buffers.h +++ b/media/base/buffers.h @@ -124,31 +124,45 @@ class VideoFrame : public StreamSample { }; +// An interface for receiving the results of an asynchronous read. Downstream +// filters typically implement this interface or use AssignableBuffer and +// provide it to upstream filters as a read request. When the upstream filter +// has completed the read, they call SetBuffer/OnAssignment to notify the +// downstream filter. +// +// TODO(scherkus): rethink the Assignable interface -- it's a bit kludgy. template -class Assignable { +class Assignable : + public base::RefCountedThreadSafe< Assignable > { public: // Assigns a buffer to the owner. virtual void SetBuffer(BufferType* buffer) = 0; // Notifies the owner that an assignment has been completed. virtual void OnAssignment() = 0; + + // TODO(scherkus): figure out a solution to friending a template. + // See http://www.comeaucomputing.com/techtalk/templates/#friendclassT for + // an explanation. + //protected: + // friend class base::RefCountedThreadSafe< Assignable >; + virtual ~Assignable() {} }; // Template for easily creating Assignable buffers. Pass in the pointer of the // object to receive the OnAssignment callback. -template -class AssignableBuffer : public Assignable, - public base::RefCountedThreadSafe< AssignableBuffer > { +template +class AssignableBuffer : public Assignable { public: - explicit AssignableBuffer(TOwner* owner) + explicit AssignableBuffer(BufferType* owner) : owner_(owner), buffer_(NULL) { DCHECK(owner_); } - // AssignableBuffer implementation. - virtual void SetBuffer(TBuffer* buffer) { + // AssignableBuffer implementation. + virtual void SetBuffer(BufferType* buffer) { buffer_ = buffer; } @@ -157,12 +171,12 @@ class AssignableBuffer : public Assignable, } private: - TOwner* owner_; - scoped_refptr buffer_; + OwnerType* owner_; + scoped_refptr buffer_; DISALLOW_COPY_AND_ASSIGN(AssignableBuffer); }; -} // namespace media +} // namespace media -#endif // MEDIA_BASE_BUFFERS_H_ +#endif // MEDIA_BASE_BUFFERS_H_ -- cgit v1.1