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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/pickle.cc » ('j') | mojo/public/cpp/bindings/lib/pickle_buffer.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/pickle.h
diff --git a/base/pickle.h b/base/pickle.h
index 72b33ddc979a50a3f8fc0ecbd628889212f99a78..5a77ed7404591d8307ba952cde096a0122ea0a50 100644
--- a/base/pickle.h
+++ b/base/pickle.h
@@ -258,6 +258,18 @@ class BASE_EXPORT Pickle {
// of the header.
void Resize(size_t new_capacity);
+ // Claims |num_bytes| bytes of payload. This is similar to Reserve in that it
yzshen1 2015/12/15 19:07:02 style nit: Reserve -> Reserve() and |ClaimBytes| -
+ // may grow the capacity, but it also advances the write offset of the pickle
+ // by |num_bytes|. Claimed memory is NOT initialized, though any alignment
+ // padding is zeroed.
+ //
+ // Unless you're SURE you're going to write to all the allocated bytes, you
+ // should use |ClaimBytes| instead.
+ void* ClaimUninitializedBytes(size_t num_bytes);
+
+ // Claims |num_bytes| bytes of payload, zeroing its contents.
+ void* ClaimBytes(size_t num_bytes);
+
// Find the end of the pickled data that starts at range_start. Returns NULL
// if the entire Pickle is not found in the given data range.
static const char* FindNext(size_t header_size,
@@ -299,6 +311,8 @@ class BASE_EXPORT Pickle {
WriteBytesStatic<sizeof(data)>(&data);
return true;
}
+
+ inline void* ClaimUninitializedBytesInternal(size_t num_bytes);
inline void WriteBytesCommon(const void* data, size_t length);
FRIEND_TEST_ALL_PREFIXES(PickleTest, DeepCopyResize);
« no previous file with comments | « no previous file | base/pickle.cc » ('j') | mojo/public/cpp/bindings/lib/pickle_buffer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698