OLD | NEW |
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 #ifndef BASE_MEMORY_REF_COUNTED_MEMORY_H_ | 5 #ifndef BASE_MEMORY_REF_COUNTED_MEMORY_H_ |
6 #define BASE_MEMORY_REF_COUNTED_MEMORY_H_ | 6 #define BASE_MEMORY_REF_COUNTED_MEMORY_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 std::string& data() { return data_; } | 117 std::string& data() { return data_; } |
118 | 118 |
119 private: | 119 private: |
120 ~RefCountedString() override; | 120 ~RefCountedString() override; |
121 | 121 |
122 std::string data_; | 122 std::string data_; |
123 | 123 |
124 DISALLOW_COPY_AND_ASSIGN(RefCountedString); | 124 DISALLOW_COPY_AND_ASSIGN(RefCountedString); |
125 }; | 125 }; |
126 | 126 |
127 // An implementation of RefCountedMemory that holds a chunk of memory | |
128 // previously allocated with malloc or calloc, and that therefore must be freed | |
129 // using free(). | |
130 class BASE_EXPORT RefCountedMallocedMemory : public base::RefCountedMemory { | |
131 public: | |
132 RefCountedMallocedMemory(void* data, size_t length); | |
133 | |
134 // Overridden from RefCountedMemory: | |
135 const unsigned char* front() const override; | |
136 size_t size() const override; | |
137 | |
138 private: | |
139 ~RefCountedMallocedMemory() override; | |
140 | |
141 unsigned char* data_; | |
142 size_t length_; | |
143 | |
144 DISALLOW_COPY_AND_ASSIGN(RefCountedMallocedMemory); | |
145 }; | |
146 | |
147 } // namespace base | 127 } // namespace base |
148 | 128 |
149 #endif // BASE_MEMORY_REF_COUNTED_MEMORY_H_ | 129 #endif // BASE_MEMORY_REF_COUNTED_MEMORY_H_ |
OLD | NEW |