Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 Buffer that takes ownership of the given data | 5 // A simple implementation of Buffer that takes ownership of the given data |
| 6 // pointer. | 6 // pointer. |
| 7 // | 7 // |
| 8 // DataBuffer assumes that memory was allocated with new uint8[]. | 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/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "media/base/buffers.h" | 14 #include "media/base/buffers.h" |
| 15 | 15 |
| 16 namespace media { | 16 namespace media { |
| 17 | 17 |
| 18 class DataBuffer : public Buffer { | 18 class DataBuffer : public Buffer { |
| 19 public: | 19 public: |
| 20 // Takes ownership of the passed |buffer|, assumes valid data of size | 20 // Takes ownership of the passed |buffer|, assumes valid data of size |
| 21 // |buffer_size|. | 21 // |buffer_size|. |
| 22 DataBuffer(uint8* buffer, size_t buffer_size); | 22 DataBuffer(uint8* buffer, size_t buffer_size); |
| 23 | 23 |
| 24 // Takes ownership of |buffer| if |copy| is false. If |copy| is true, | |
| 25 // a copy is made of |buffer|. Assumes |buffer_size| is the actual size | |
| 26 // of |buffer|. | |
| 27 DataBuffer(uint8* buffer, size_t buffer_size, bool copy); | |
|
scherkus (not reviewing)
2011/06/23 18:50:18
I don't think we should have this ctor:
a) boole
acolwell GONE FROM CHROMIUM
2011/06/23 22:42:17
Done.
| |
| 28 | |
| 24 // Allocates buffer of size |buffer_size|. If |buffer_size| is 0, |data_| is | 29 // Allocates buffer of size |buffer_size|. If |buffer_size| is 0, |data_| is |
| 25 // set to a NULL ptr. | 30 // set to a NULL ptr. |
| 26 explicit DataBuffer(size_t buffer_size); | 31 explicit DataBuffer(size_t buffer_size); |
| 27 | 32 |
| 28 // Buffer implementation. | 33 // Buffer implementation. |
| 29 virtual const uint8* GetData() const; | 34 virtual const uint8* GetData() const; |
| 30 virtual size_t GetDataSize() const; | 35 virtual size_t GetDataSize() const; |
| 31 | 36 |
| 32 // Returns a read-write pointer to the buffer data. | 37 // Returns a read-write pointer to the buffer data. |
| 33 virtual uint8* GetWritableData(); | 38 virtual uint8* GetWritableData(); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 46 scoped_array<uint8> data_; | 51 scoped_array<uint8> data_; |
| 47 size_t buffer_size_; | 52 size_t buffer_size_; |
| 48 size_t data_size_; | 53 size_t data_size_; |
| 49 | 54 |
| 50 DISALLOW_COPY_AND_ASSIGN(DataBuffer); | 55 DISALLOW_COPY_AND_ASSIGN(DataBuffer); |
| 51 }; | 56 }; |
| 52 | 57 |
| 53 } // namespace media | 58 } // namespace media |
| 54 | 59 |
| 55 #endif // MEDIA_BASE_DATA_BUFFER_H_ | 60 #endif // MEDIA_BASE_DATA_BUFFER_H_ |
| OLD | NEW |