Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 const char* payload() const { | 173 const char* payload() const { |
| 174 return reinterpret_cast<const char*>(header_) + header_size_; | 174 return reinterpret_cast<const char*>(header_) + header_size_; |
| 175 } | 175 } |
| 176 | 176 |
| 177 // Returns the address of the byte immediately following the currently valid | 177 // Returns the address of the byte immediately following the currently valid |
| 178 // header + payload. | 178 // header + payload. |
| 179 char* end_of_payload() { | 179 char* end_of_payload() { |
| 180 return payload() + payload_size(); | 180 return payload() + payload_size(); |
| 181 } | 181 } |
| 182 const char* end_of_payload() const { | 182 const char* end_of_payload() const { |
| 183 return payload() + payload_size(); | 183 return header_ ? payload() + payload_size() : NULL; |
|
darin (slow to review)
2010/11/11 17:33:57
what about the non-const version of end_of_payload
rvargas (doing something else)
2010/11/11 22:35:36
The expectation for the non-const version is to ha
| |
| 184 } | 184 } |
| 185 | 185 |
| 186 size_t capacity() const { | 186 size_t capacity() const { |
| 187 return capacity_; | 187 return capacity_; |
| 188 } | 188 } |
| 189 | 189 |
| 190 // Resizes the buffer for use when writing the specified amount of data. The | 190 // Resizes the buffer for use when writing the specified amount of data. The |
| 191 // location that the data should be written at is returned, or NULL if there | 191 // location that the data should be written at is returned, or NULL if there |
| 192 // was an error. Call EndWrite with the returned offset and the given length | 192 // was an error. Call EndWrite with the returned offset and the given length |
| 193 // to pad out for the next write. | 193 // to pad out for the next write. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 231 // Allocation size of payload (or -1 if allocation is const). | 231 // Allocation size of payload (or -1 if allocation is const). |
| 232 size_t capacity_; | 232 size_t capacity_; |
| 233 size_t variable_buffer_offset_; // IF non-zero, then offset to a buffer. | 233 size_t variable_buffer_offset_; // IF non-zero, then offset to a buffer. |
| 234 | 234 |
| 235 FRIEND_TEST_ALL_PREFIXES(PickleTest, Resize); | 235 FRIEND_TEST_ALL_PREFIXES(PickleTest, Resize); |
| 236 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNext); | 236 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNext); |
| 237 FRIEND_TEST_ALL_PREFIXES(PickleTest, IteratorHasRoom); | 237 FRIEND_TEST_ALL_PREFIXES(PickleTest, IteratorHasRoom); |
| 238 }; | 238 }; |
| 239 | 239 |
| 240 #endif // BASE_PICKLE_H__ | 240 #endif // BASE_PICKLE_H__ |
| OLD | NEW |