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

Side by Side Diff: base/memory/ref_counted_memory.h

Issue 614103004: replace 'virtual ... OVERRIDE' with '... override' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: process base/ Created 6 years, 2 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
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 #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 <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 // matter. 45 // matter.
46 class BASE_EXPORT RefCountedStaticMemory : public RefCountedMemory { 46 class BASE_EXPORT RefCountedStaticMemory : public RefCountedMemory {
47 public: 47 public:
48 RefCountedStaticMemory() 48 RefCountedStaticMemory()
49 : data_(NULL), length_(0) {} 49 : data_(NULL), length_(0) {}
50 RefCountedStaticMemory(const void* data, size_t length) 50 RefCountedStaticMemory(const void* data, size_t length)
51 : data_(static_cast<const unsigned char*>(length ? data : NULL)), 51 : data_(static_cast<const unsigned char*>(length ? data : NULL)),
52 length_(length) {} 52 length_(length) {}
53 53
54 // Overridden from RefCountedMemory: 54 // Overridden from RefCountedMemory:
55 virtual const unsigned char* front() const OVERRIDE; 55 const unsigned char* front() const override;
56 virtual size_t size() const OVERRIDE; 56 size_t size() const override;
57 57
58 private: 58 private:
59 virtual ~RefCountedStaticMemory(); 59 virtual ~RefCountedStaticMemory();
60 60
61 const unsigned char* data_; 61 const unsigned char* data_;
62 size_t length_; 62 size_t length_;
63 63
64 DISALLOW_COPY_AND_ASSIGN(RefCountedStaticMemory); 64 DISALLOW_COPY_AND_ASSIGN(RefCountedStaticMemory);
65 }; 65 };
66 66
67 // An implementation of RefCountedMemory, where we own the data in a vector. 67 // An implementation of RefCountedMemory, where we own the data in a vector.
68 class BASE_EXPORT RefCountedBytes : public RefCountedMemory { 68 class BASE_EXPORT RefCountedBytes : public RefCountedMemory {
69 public: 69 public:
70 RefCountedBytes(); 70 RefCountedBytes();
71 71
72 // Constructs a RefCountedBytes object by _copying_ from |initializer|. 72 // Constructs a RefCountedBytes object by _copying_ from |initializer|.
73 explicit RefCountedBytes(const std::vector<unsigned char>& initializer); 73 explicit RefCountedBytes(const std::vector<unsigned char>& initializer);
74 74
75 // Constructs a RefCountedBytes object by copying |size| bytes from |p|. 75 // Constructs a RefCountedBytes object by copying |size| bytes from |p|.
76 RefCountedBytes(const unsigned char* p, size_t size); 76 RefCountedBytes(const unsigned char* p, size_t size);
77 77
78 // Constructs a RefCountedBytes object by performing a swap. (To non 78 // Constructs a RefCountedBytes object by performing a swap. (To non
79 // destructively build a RefCountedBytes, use the constructor that takes a 79 // destructively build a RefCountedBytes, use the constructor that takes a
80 // vector.) 80 // vector.)
81 static RefCountedBytes* TakeVector(std::vector<unsigned char>* to_destroy); 81 static RefCountedBytes* TakeVector(std::vector<unsigned char>* to_destroy);
82 82
83 // Overridden from RefCountedMemory: 83 // Overridden from RefCountedMemory:
84 virtual const unsigned char* front() const OVERRIDE; 84 const unsigned char* front() const override;
85 virtual size_t size() const OVERRIDE; 85 size_t size() const override;
86 86
87 const std::vector<unsigned char>& data() const { return data_; } 87 const std::vector<unsigned char>& data() const { return data_; }
88 std::vector<unsigned char>& data() { return data_; } 88 std::vector<unsigned char>& data() { return data_; }
89 89
90 private: 90 private:
91 virtual ~RefCountedBytes(); 91 virtual ~RefCountedBytes();
92 92
93 std::vector<unsigned char> data_; 93 std::vector<unsigned char> data_;
94 94
95 DISALLOW_COPY_AND_ASSIGN(RefCountedBytes); 95 DISALLOW_COPY_AND_ASSIGN(RefCountedBytes);
96 }; 96 };
97 97
98 // An implementation of RefCountedMemory, where the bytes are stored in an STL 98 // An implementation of RefCountedMemory, where the bytes are stored in an STL
99 // string. Use this if your data naturally arrives in that format. 99 // string. Use this if your data naturally arrives in that format.
100 class BASE_EXPORT RefCountedString : public RefCountedMemory { 100 class BASE_EXPORT RefCountedString : public RefCountedMemory {
101 public: 101 public:
102 RefCountedString(); 102 RefCountedString();
103 103
104 // Constructs a RefCountedString object by performing a swap. (To non 104 // Constructs a RefCountedString object by performing a swap. (To non
105 // destructively build a RefCountedString, use the default constructor and 105 // destructively build a RefCountedString, use the default constructor and
106 // copy into object->data()). 106 // copy into object->data()).
107 static RefCountedString* TakeString(std::string* to_destroy); 107 static RefCountedString* TakeString(std::string* to_destroy);
108 108
109 // Overridden from RefCountedMemory: 109 // Overridden from RefCountedMemory:
110 virtual const unsigned char* front() const OVERRIDE; 110 const unsigned char* front() const override;
111 virtual size_t size() const OVERRIDE; 111 size_t size() const override;
112 112
113 const std::string& data() const { return data_; } 113 const std::string& data() const { return data_; }
114 std::string& data() { return data_; } 114 std::string& data() { return data_; }
115 115
116 private: 116 private:
117 virtual ~RefCountedString(); 117 virtual ~RefCountedString();
118 118
119 std::string data_; 119 std::string data_;
120 120
121 DISALLOW_COPY_AND_ASSIGN(RefCountedString); 121 DISALLOW_COPY_AND_ASSIGN(RefCountedString);
122 }; 122 };
123 123
124 // An implementation of RefCountedMemory that holds a chunk of memory 124 // An implementation of RefCountedMemory that holds a chunk of memory
125 // previously allocated with malloc or calloc, and that therefore must be freed 125 // previously allocated with malloc or calloc, and that therefore must be freed
126 // using free(). 126 // using free().
127 class BASE_EXPORT RefCountedMallocedMemory : public base::RefCountedMemory { 127 class BASE_EXPORT RefCountedMallocedMemory : public base::RefCountedMemory {
128 public: 128 public:
129 RefCountedMallocedMemory(void* data, size_t length); 129 RefCountedMallocedMemory(void* data, size_t length);
130 130
131 // Overridden from RefCountedMemory: 131 // Overridden from RefCountedMemory:
132 virtual const unsigned char* front() const OVERRIDE; 132 const unsigned char* front() const override;
133 virtual size_t size() const OVERRIDE; 133 size_t size() const override;
134 134
135 private: 135 private:
136 virtual ~RefCountedMallocedMemory(); 136 virtual ~RefCountedMallocedMemory();
137 137
138 unsigned char* data_; 138 unsigned char* data_;
139 size_t length_; 139 size_t length_;
140 140
141 DISALLOW_COPY_AND_ASSIGN(RefCountedMallocedMemory); 141 DISALLOW_COPY_AND_ASSIGN(RefCountedMallocedMemory);
142 }; 142 };
143 143
144 } // namespace base 144 } // namespace base
145 145
146 #endif // BASE_MEMORY_REF_COUNTED_MEMORY_H_ 146 #endif // BASE_MEMORY_REF_COUNTED_MEMORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698