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 #ifndef BASE_REF_COUNTED_MEMORY_H_ | 5 #ifndef BASE_MEMORY_REF_COUNTED_MEMORY_H_ |
6 #define BASE_REF_COUNTED_MEMORY_H_ | 6 #define BASE_MEMORY_REF_COUNTED_MEMORY_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 | 12 |
13 // TODO(erg): The contents of this file should be in a namespace. This would | 13 // TODO(erg): The contents of this file should be in a namespace. This would |
14 // require touching >100 files in chrome/ though. | 14 // require touching >100 files in chrome/ though. |
15 | 15 |
16 // A generic interface to memory. This object is reference counted because one | 16 // A generic interface to memory. This object is reference counted because one |
17 // of its two subclasses own the data they carry, and we need to have | 17 // of its two subclasses own the data they carry, and we need to have |
18 // heterogeneous containers of these two types of memory. | 18 // heterogeneous containers of these two types of memory. |
19 class RefCountedMemory : public base::RefCountedThreadSafe<RefCountedMemory> { | 19 class RefCountedMemory |
| 20 : public base::RefCountedThreadSafe<RefCountedMemory> { |
20 public: | 21 public: |
21 // Retrieves a pointer to the beginning of the data we point to. If the data | 22 // Retrieves a pointer to the beginning of the data we point to. If the data |
22 // is empty, this will return NULL. | 23 // is empty, this will return NULL. |
23 virtual const unsigned char* front() const = 0; | 24 virtual const unsigned char* front() const = 0; |
24 | 25 |
25 // Size of the memory pointed to. | 26 // Size of the memory pointed to. |
26 virtual size_t size() const = 0; | 27 virtual size_t size() const = 0; |
27 | 28 |
28 protected: | 29 protected: |
29 friend class base::RefCountedThreadSafe<RefCountedMemory>; | 30 friend class base::RefCountedThreadSafe<RefCountedMemory>; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 std::vector<unsigned char> data; | 73 std::vector<unsigned char> data; |
73 | 74 |
74 protected: | 75 protected: |
75 friend class base::RefCountedThreadSafe<RefCountedBytes>; | 76 friend class base::RefCountedThreadSafe<RefCountedBytes>; |
76 virtual ~RefCountedBytes(); | 77 virtual ~RefCountedBytes(); |
77 | 78 |
78 private: | 79 private: |
79 DISALLOW_COPY_AND_ASSIGN(RefCountedBytes); | 80 DISALLOW_COPY_AND_ASSIGN(RefCountedBytes); |
80 }; | 81 }; |
81 | 82 |
82 #endif // BASE_REF_COUNTED_MEMORY_H_ | 83 #endif // BASE_MEMORY_REF_COUNTED_MEMORY_H_ |
OLD | NEW |