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

Side by Side Diff: base/pickle.h

Issue 1524613002: [mojo] Use base::Pickle for Message storage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: happy compiler happy robots Created 5 years 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
« no previous file with comments | « no previous file | base/pickle.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_PICKLE_H_ 5 #ifndef BASE_PICKLE_H_
6 #define BASE_PICKLE_H_ 6 #define BASE_PICKLE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 } 251 }
252 252
253 size_t capacity_after_header() const { 253 size_t capacity_after_header() const {
254 return capacity_after_header_; 254 return capacity_after_header_;
255 } 255 }
256 256
257 // Resize the capacity, note that the input value should not include the size 257 // Resize the capacity, note that the input value should not include the size
258 // of the header. 258 // of the header.
259 void Resize(size_t new_capacity); 259 void Resize(size_t new_capacity);
260 260
261 // Claims |num_bytes| bytes of payload. This is similar to Reserve() in that
262 // it may grow the capacity, but it also advances the write offset of the
263 // pickle by |num_bytes|. Claimed memory, including padding, is zeroed.
264 //
265 // Returns the address of the first byte claimed.
266 void* ClaimBytes(size_t num_bytes);
267
261 // Find the end of the pickled data that starts at range_start. Returns NULL 268 // Find the end of the pickled data that starts at range_start. Returns NULL
262 // if the entire Pickle is not found in the given data range. 269 // if the entire Pickle is not found in the given data range.
263 static const char* FindNext(size_t header_size, 270 static const char* FindNext(size_t header_size,
264 const char* range_start, 271 const char* range_start,
265 const char* range_end); 272 const char* range_end);
266 273
267 // Parse pickle header and return total size of the pickle. Data range 274 // Parse pickle header and return total size of the pickle. Data range
268 // doesn't need to contain entire pickle. 275 // doesn't need to contain entire pickle.
269 // Returns true if pickle header was found and parsed. Callers must check 276 // Returns true if pickle header was found and parsed. Callers must check
270 // returned |pickle_size| for sanity (against maximum message size, etc). 277 // returned |pickle_size| for sanity (against maximum message size, etc).
(...skipping 21 matching lines...) Expand all
292 size_t write_offset_; 299 size_t write_offset_;
293 300
294 // Just like WriteBytes, but with a compile-time size, for performance. 301 // Just like WriteBytes, but with a compile-time size, for performance.
295 template<size_t length> void BASE_EXPORT WriteBytesStatic(const void* data); 302 template<size_t length> void BASE_EXPORT WriteBytesStatic(const void* data);
296 303
297 // Writes a POD by copying its bytes. 304 // Writes a POD by copying its bytes.
298 template <typename T> bool WritePOD(const T& data) { 305 template <typename T> bool WritePOD(const T& data) {
299 WriteBytesStatic<sizeof(data)>(&data); 306 WriteBytesStatic<sizeof(data)>(&data);
300 return true; 307 return true;
301 } 308 }
309
310 inline void* ClaimUninitializedBytesInternal(size_t num_bytes);
302 inline void WriteBytesCommon(const void* data, size_t length); 311 inline void WriteBytesCommon(const void* data, size_t length);
303 312
304 FRIEND_TEST_ALL_PREFIXES(PickleTest, DeepCopyResize); 313 FRIEND_TEST_ALL_PREFIXES(PickleTest, DeepCopyResize);
305 FRIEND_TEST_ALL_PREFIXES(PickleTest, Resize); 314 FRIEND_TEST_ALL_PREFIXES(PickleTest, Resize);
306 FRIEND_TEST_ALL_PREFIXES(PickleTest, PeekNext); 315 FRIEND_TEST_ALL_PREFIXES(PickleTest, PeekNext);
307 FRIEND_TEST_ALL_PREFIXES(PickleTest, PeekNextOverflow); 316 FRIEND_TEST_ALL_PREFIXES(PickleTest, PeekNextOverflow);
308 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNext); 317 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNext);
309 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNextWithIncompleteHeader); 318 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNextWithIncompleteHeader);
310 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNextOverflow); 319 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNextOverflow);
311 }; 320 };
312 321
313 } // namespace base 322 } // namespace base
314 323
315 #endif // BASE_PICKLE_H_ 324 #endif // BASE_PICKLE_H_
OLDNEW
« no previous file with comments | « no previous file | base/pickle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698