diff options
author | kylep@chromium.org <kylep@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-16 00:13:21 +0000 |
---|---|---|
committer | kylep@chromium.org <kylep@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-16 00:13:21 +0000 |
commit | da437a560297855295adb2c30e49c05d20ee95ab (patch) | |
tree | 085e28aea8cea82902f489f82238e91a391f50fb /media/base/data_buffer.h | |
parent | f0109a7d5f18d3fdfb0daf76fd6f9f7270ba85cc (diff) | |
download | chromium_src-da437a560297855295adb2c30e49c05d20ee95ab.zip chromium_src-da437a560297855295adb2c30e49c05d20ee95ab.tar.gz chromium_src-da437a560297855295adb2c30e49c05d20ee95ab.tar.bz2 |
Refactor WritableBuffer interface for more useful ptr management.
BUG=16011
TEST=DataBuffer unittest
Review URL: http://codereview.chromium.org/149573
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20821 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base/data_buffer.h')
-rw-r--r-- | media/base/data_buffer.h | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/media/base/data_buffer.h b/media/base/data_buffer.h index 8099d14..26ecb8a 100644 --- a/media/base/data_buffer.h +++ b/media/base/data_buffer.h @@ -5,32 +5,40 @@ // A simple implementation of WritableBuffer that takes ownership of // the given data pointer. // -// DataBuffer assumes that memory was allocated with new char[]. +// DataBuffer assumes that memory was allocated with new uint8[]. #ifndef MEDIA_BASE_DATA_BUFFER_H_ #define MEDIA_BASE_DATA_BUFFER_H_ +#include "base/scoped_ptr.h" #include "media/base/buffers.h" namespace media { class DataBuffer : public WritableBuffer { public: - DataBuffer(); + // Takes ownership of the passed |buffer|, assumes valid data of size + // |buffer_size|. + DataBuffer(uint8* buffer, size_t buffer_size); + + // Allocates buffer of size |buffer_size|. If |buffer_size| is 0, |data_| is + // set to a NULL ptr. + explicit DataBuffer(size_t buffer_size); // Buffer implementation. virtual const uint8* GetData() const; virtual size_t GetDataSize() const; // WritableBuffer implementation. - virtual uint8* GetWritableData(size_t buffer_size); + virtual uint8* GetWritableData(); virtual void SetDataSize(size_t data_size); + virtual size_t GetBufferSize() const; protected: virtual ~DataBuffer(); private: - uint8* data_; + scoped_array<uint8> data_; size_t buffer_size_; size_t data_size_; }; |