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

Side by Side Diff: base/pickle.h

Issue 35893002: IPC pickling optimization for render passes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ccmessagesperf-reserve: nits Created 7 years, 1 month 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 | Annotate | Revision Log
« 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 <string> 8 #include <string>
9 9
10 #include "base/base_export.h" 10 #include "base/base_export.h"
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 // with BeginWriteData), the Pickle can 266 // with BeginWriteData), the Pickle can
267 // be 'trimmed' if the amount of data required is less than originally 267 // be 'trimmed' if the amount of data required is less than originally
268 // requested. For example, you may have created a buffer with 10K of data, 268 // requested. For example, you may have created a buffer with 10K of data,
269 // but decided to only fill 10 bytes of that data. Use this function 269 // but decided to only fill 10 bytes of that data. Use this function
270 // to trim the buffer so that we don't send 9990 bytes of unused data. 270 // to trim the buffer so that we don't send 9990 bytes of unused data.
271 // You cannot increase the size of the variable buffer; only shrink it. 271 // You cannot increase the size of the variable buffer; only shrink it.
272 // This function assumes that the length of the variable buffer has 272 // This function assumes that the length of the variable buffer has
273 // not been changed. 273 // not been changed.
274 void TrimWriteData(int length); 274 void TrimWriteData(int length);
275 275
276 // Reserves space for upcoming writes when multiple writes will be made and
277 // their sizes are computed in advance. It can be significantly faster to call
278 // Reserve() before calling WriteFoo() multiple times.
279 void Reserve(size_t additional_capacity);
280
276 // Payload follows after allocation of Header (header size is customizable). 281 // Payload follows after allocation of Header (header size is customizable).
277 struct Header { 282 struct Header {
278 uint32 payload_size; // Specifies the size of the payload. 283 uint32 payload_size; // Specifies the size of the payload.
279 }; 284 };
280 285
281 // Returns the header, cast to a user-specified type T. The type T must be a 286 // Returns the header, cast to a user-specified type T. The type T must be a
282 // subclass of Header and its size must correspond to the header_size passed 287 // subclass of Header and its size must correspond to the header_size passed
283 // to the Pickle constructor. 288 // to the Pickle constructor.
284 template <class T> 289 template <class T>
285 T* headerT() { 290 T* headerT() {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 // Allocation size of payload (or -1 if allocation is const). 359 // Allocation size of payload (or -1 if allocation is const).
355 size_t capacity_; 360 size_t capacity_;
356 size_t variable_buffer_offset_; // IF non-zero, then offset to a buffer. 361 size_t variable_buffer_offset_; // IF non-zero, then offset to a buffer.
357 362
358 FRIEND_TEST_ALL_PREFIXES(PickleTest, Resize); 363 FRIEND_TEST_ALL_PREFIXES(PickleTest, Resize);
359 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNext); 364 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNext);
360 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNextWithIncompleteHeader); 365 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNextWithIncompleteHeader);
361 }; 366 };
362 367
363 #endif // BASE_PICKLE_H__ 368 #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