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

Side by Side Diff: media/base/data_buffer.h

Issue 149573: Refactor WritableBuffer interface for more useful ptr management. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/base/buffers.h ('k') | media/base/data_buffer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008-2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // A simple implementation of WritableBuffer that takes ownership of 5 // A simple implementation of WritableBuffer that takes ownership of
6 // the given data pointer. 6 // the given data pointer.
7 // 7 //
8 // DataBuffer assumes that memory was allocated with new char[]. 8 // DataBuffer assumes that memory was allocated with new uint8[].
9 9
10 #ifndef MEDIA_BASE_DATA_BUFFER_H_ 10 #ifndef MEDIA_BASE_DATA_BUFFER_H_
11 #define MEDIA_BASE_DATA_BUFFER_H_ 11 #define MEDIA_BASE_DATA_BUFFER_H_
12 12
13 #include "base/scoped_ptr.h"
13 #include "media/base/buffers.h" 14 #include "media/base/buffers.h"
14 15
15 namespace media { 16 namespace media {
16 17
17 class DataBuffer : public WritableBuffer { 18 class DataBuffer : public WritableBuffer {
18 public: 19 public:
19 DataBuffer(); 20 // Takes ownership of the passed |buffer|, assumes valid data of size
21 // |buffer_size|.
22 DataBuffer(uint8* buffer, size_t buffer_size);
23
24 // Allocates buffer of size |buffer_size|. If |buffer_size| is 0, |data_| is
25 // set to a NULL ptr.
26 explicit DataBuffer(size_t buffer_size);
20 27
21 // Buffer implementation. 28 // Buffer implementation.
22 virtual const uint8* GetData() const; 29 virtual const uint8* GetData() const;
23 virtual size_t GetDataSize() const; 30 virtual size_t GetDataSize() const;
24 31
25 // WritableBuffer implementation. 32 // WritableBuffer implementation.
26 virtual uint8* GetWritableData(size_t buffer_size); 33 virtual uint8* GetWritableData();
27 virtual void SetDataSize(size_t data_size); 34 virtual void SetDataSize(size_t data_size);
35 virtual size_t GetBufferSize() const;
28 36
29 protected: 37 protected:
30 virtual ~DataBuffer(); 38 virtual ~DataBuffer();
31 39
32 private: 40 private:
33 uint8* data_; 41 scoped_array<uint8> data_;
34 size_t buffer_size_; 42 size_t buffer_size_;
35 size_t data_size_; 43 size_t data_size_;
36 }; 44 };
37 45
38 } // namespace media 46 } // namespace media
39 47
40 #endif // MEDIA_BASE_DATA_BUFFER_H_ 48 #endif // MEDIA_BASE_DATA_BUFFER_H_
OLDNEW
« no previous file with comments | « media/base/buffers.h ('k') | media/base/data_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698