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_PICKLE_H_ | 5 #ifndef BASE_PICKLE_H_ |
6 #define BASE_PICKLE_H_ | 6 #define BASE_PICKLE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 // Note: There are no virtual methods in this class. This destructor is | 146 // Note: There are no virtual methods in this class. This destructor is |
147 // virtual as an element of defensive coding. Other classes have derived from | 147 // virtual as an element of defensive coding. Other classes have derived from |
148 // this class, and there is a *chance* that they will cast into this base | 148 // this class, and there is a *chance* that they will cast into this base |
149 // class before destruction. At least one such class does have a virtual | 149 // class before destruction. At least one such class does have a virtual |
150 // destructor, suggesting at least some need to call more derived destructors. | 150 // destructor, suggesting at least some need to call more derived destructors. |
151 virtual ~Pickle(); | 151 virtual ~Pickle(); |
152 | 152 |
153 // Performs a deep copy. | 153 // Performs a deep copy. |
154 Pickle& operator=(const Pickle& other); | 154 Pickle& operator=(const Pickle& other); |
155 | 155 |
156 // Returns the size of the Pickle's data. | 156 // Returns the number of bytes written in the Pickle, including the header. |
157 size_t size() const { return header_size_ + header_->payload_size; } | 157 size_t size() const { return header_size_ + header_->payload_size; } |
158 | 158 |
159 // Returns the data for this Pickle. | 159 // Returns the data for this Pickle. |
160 const void* data() const { return header_; } | 160 const void* data() const { return header_; } |
161 | 161 |
| 162 // Returns the effective memory capacity of this Pickle, that is, the total |
| 163 // number of bytes currently dynamically allocated or 0 in the case of a |
| 164 // read-only Pickle. This should be used only for diagnostic / profiling |
| 165 // purposes. |
| 166 size_t GetTotalAllocatedSize() const; |
| 167 |
162 // Methods for adding to the payload of the Pickle. These values are | 168 // Methods for adding to the payload of the Pickle. These values are |
163 // appended to the end of the Pickle's payload. When reading values from a | 169 // appended to the end of the Pickle's payload. When reading values from a |
164 // Pickle, it is important to read them in the order in which they were added | 170 // Pickle, it is important to read them in the order in which they were added |
165 // to the Pickle. | 171 // to the Pickle. |
166 | 172 |
167 bool WriteBool(bool value) { | 173 bool WriteBool(bool value) { |
168 return WriteInt(value ? 1 : 0); | 174 return WriteInt(value ? 1 : 0); |
169 } | 175 } |
170 bool WriteInt(int value) { | 176 bool WriteInt(int value) { |
171 return WritePOD(value); | 177 return WritePOD(value); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 | 308 |
303 FRIEND_TEST_ALL_PREFIXES(PickleTest, Resize); | 309 FRIEND_TEST_ALL_PREFIXES(PickleTest, Resize); |
304 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNext); | 310 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNext); |
305 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNextWithIncompleteHeader); | 311 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNextWithIncompleteHeader); |
306 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNextOverflow); | 312 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNextOverflow); |
307 }; | 313 }; |
308 | 314 |
309 } // namespace base | 315 } // namespace base |
310 | 316 |
311 #endif // BASE_PICKLE_H_ | 317 #endif // BASE_PICKLE_H_ |
OLD | NEW |