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

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

Issue 10447035: Introducing DecoderBuffer and general Buffer cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/2011/2012/ Created 8 years, 6 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_unittest.cc ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_
(...skipping 12 matching lines...) Expand all
23 // Allocates buffer of size |buffer_size|. If |buffer_size| is 0, |data_| is 23 // Allocates buffer of size |buffer_size|. If |buffer_size| is 0, |data_| is
24 // set to a NULL ptr. 24 // set to a NULL ptr.
25 explicit DataBuffer(int buffer_size); 25 explicit DataBuffer(int buffer_size);
26 26
27 // Create a DataBuffer whose |data_| is copied from |data|. 27 // Create a DataBuffer whose |data_| is copied from |data|.
28 static scoped_refptr<DataBuffer> CopyFrom(const uint8* data, int size); 28 static scoped_refptr<DataBuffer> CopyFrom(const uint8* data, int size);
29 29
30 // Buffer implementation. 30 // Buffer implementation.
31 virtual const uint8* GetData() const OVERRIDE; 31 virtual const uint8* GetData() const OVERRIDE;
32 virtual int GetDataSize() const OVERRIDE; 32 virtual int GetDataSize() const OVERRIDE;
33 virtual const DecryptConfig* GetDecryptConfig() const OVERRIDE;
34 33
35 // Returns a read-write pointer to the buffer data. 34 // Returns a read-write pointer to the buffer data.
36 virtual uint8* GetWritableData(); 35 virtual uint8* GetWritableData();
37 36
38 // Updates the size of valid data in bytes, which must be less than or equal 37 // Updates the size of valid data in bytes, which must be less than or equal
39 // to GetBufferSize(). 38 // to GetBufferSize().
40 virtual void SetDataSize(int data_size); 39 virtual void SetDataSize(int data_size);
41 40
42 // Returns the size of the underlying buffer. 41 // Returns the size of the underlying buffer.
43 virtual int GetBufferSize() const; 42 virtual int GetBufferSize() const;
44 43
45 virtual void SetDecryptConfig(scoped_ptr<DecryptConfig> decrypt_config);
46
47 protected: 44 protected:
48 // Copies from [data,data+size) to owned array. 45 // Copies from [data,data+size) to owned array.
49 DataBuffer(const uint8* data, int size); 46 DataBuffer(const uint8* data, int size);
50 virtual ~DataBuffer(); 47 virtual ~DataBuffer();
51 48
52 private: 49 private:
53 // Helper method to allocate |data_| with at least |buffer_size| bytes. 50 // Constructor helper method for memory allocations.
54 void AllocateBuffer(int buffer_size); 51 void Initialize();
55 52
56 scoped_array<uint8> data_; 53 scoped_array<uint8> data_;
57 int buffer_size_; 54 int buffer_size_;
58 int data_size_; 55 int data_size_;
59 scoped_ptr<DecryptConfig> decrypt_config_;
60 56
61 DISALLOW_COPY_AND_ASSIGN(DataBuffer); 57 DISALLOW_COPY_AND_ASSIGN(DataBuffer);
62 }; 58 };
63 59
64 } // namespace media 60 } // namespace media
65 61
66 #endif // MEDIA_BASE_DATA_BUFFER_H_ 62 #endif // MEDIA_BASE_DATA_BUFFER_H_
OLDNEW
« no previous file with comments | « media/base/buffers_unittest.cc ('k') | media/base/data_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698