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

Unified Diff: base/pickle.h

Issue 825353003: Revert of Remove deprecated methods from Pickle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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_unittest.cc » ('j') | no next file with comments »
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 f2a198e3f2da9e13be0b4e20f1fcf8460133327b..11cf4841f67903b7bd62cd6bdc4dda5467a4f47c 100644
--- a/base/pickle.h
+++ b/base/pickle.h
@@ -26,7 +26,7 @@
// Methods for reading the payload of the Pickle. To read from the start of
// the Pickle, create a PickleIterator from a Pickle. If successful, these
// methods return true. Otherwise, false is returned to indicate that the
- // result could not be extracted. It is not possible to read from the iterator
+ // result could not be extracted. It is not possible to read from iterator
// after that.
bool ReadBool(bool* result) WARN_UNUSED_RESULT;
bool ReadInt(int* result) WARN_UNUSED_RESULT;
@@ -41,21 +41,10 @@
bool ReadString(std::string* result) WARN_UNUSED_RESULT;
bool ReadWString(std::wstring* result) WARN_UNUSED_RESULT;
bool ReadString16(base::string16* result) WARN_UNUSED_RESULT;
-
- // A pointer to the data will be placed in |*data|, and the length will be
- // placed in |*length|. The pointer placed into |*data| points into the
- // message's buffer so it will be scoped to the lifetime of the message (or
- // until the message data is mutated). Do not keep the pointer around!
bool ReadData(const char** data, int* length) WARN_UNUSED_RESULT;
-
- // A pointer to the data will be placed in |*data|. The caller specifies the
- // number of bytes to read, and ReadBytes will validate this length. The
- // pointer placed into |*data| points into the message's buffer so it will be
- // scoped to the lifetime of the message (or until the message data is
- // mutated). Do not keep the pointer around!
bool ReadBytes(const char** data, int length) WARN_UNUSED_RESULT;
- // A safer version of ReadInt() that checks for the result not being negative.
+ // Safer version of ReadInt() checks for the result not being negative.
// Use it for reading the object sizes.
bool ReadLength(int* result) WARN_UNUSED_RESULT {
return ReadInt(result) && *result >= 0;
@@ -68,7 +57,7 @@
}
private:
- // Aligns 'i' by rounding it up to the next multiple of 'alignment'.
+ // Aligns 'i' by rounding it up to the next multiple of 'alignment'
static size_t AlignInt(size_t i, int alignment) {
return i + (alignment - (i % alignment)) % alignment;
}
@@ -153,11 +142,91 @@
// Returns the data for this Pickle.
const void* data() const { return header_; }
+ // For compatibility, these older style read methods pass through to the
+ // PickleIterator methods.
+ // TODO(jbates) Remove these methods.
+ bool ReadBool(PickleIterator* iter,
+ bool* result) const WARN_UNUSED_RESULT {
+ return iter->ReadBool(result);
+ }
+ bool ReadInt(PickleIterator* iter,
+ int* result) const WARN_UNUSED_RESULT {
+ return iter->ReadInt(result);
+ }
+ bool ReadLong(PickleIterator* iter,
+ long* result) const WARN_UNUSED_RESULT {
+ return iter->ReadLong(result);
+ }
+ bool ReadUInt16(PickleIterator* iter,
+ uint16* result) const WARN_UNUSED_RESULT {
+ return iter->ReadUInt16(result);
+ }
+ bool ReadUInt32(PickleIterator* iter,
+ uint32* result) const WARN_UNUSED_RESULT {
+ return iter->ReadUInt32(result);
+ }
+ bool ReadInt64(PickleIterator* iter,
+ int64* result) const WARN_UNUSED_RESULT {
+ return iter->ReadInt64(result);
+ }
+ bool ReadUInt64(PickleIterator* iter,
+ uint64* result) const WARN_UNUSED_RESULT {
+ return iter->ReadUInt64(result);
+ }
+ bool ReadSizeT(PickleIterator* iter,
+ size_t* result) const WARN_UNUSED_RESULT {
+ return iter->ReadSizeT(result);
+ }
+ bool ReadFloat(PickleIterator* iter,
+ float* result) const WARN_UNUSED_RESULT {
+ return iter->ReadFloat(result);
+ }
+ bool ReadDouble(PickleIterator* iter,
+ double* result) const WARN_UNUSED_RESULT {
+ return iter->ReadDouble(result);
+ }
+ bool ReadString(PickleIterator* iter,
+ std::string* result) const WARN_UNUSED_RESULT {
+ return iter->ReadString(result);
+ }
+ bool ReadWString(PickleIterator* iter,
+ std::wstring* result) const WARN_UNUSED_RESULT {
+ return iter->ReadWString(result);
+ }
+ bool ReadString16(PickleIterator* iter,
+ base::string16* result) const WARN_UNUSED_RESULT {
+ return iter->ReadString16(result);
+ }
+ // A pointer to the data will be placed in *data, and the length will be
+ // placed in *length. This buffer will be into the message's buffer so will
+ // be scoped to the lifetime of the message (or until the message data is
+ // mutated).
+ bool ReadData(PickleIterator* iter,
+ const char** data,
+ int* length) const WARN_UNUSED_RESULT {
+ return iter->ReadData(data, length);
+ }
+ // A pointer to the data will be placed in *data. The caller specifies the
+ // number of bytes to read, and ReadBytes will validate this length. The
+ // returned buffer will be into the message's buffer so will be scoped to the
+ // lifetime of the message (or until the message data is mutated).
+ bool ReadBytes(PickleIterator* iter,
+ const char** data,
+ int length) const WARN_UNUSED_RESULT {
+ return iter->ReadBytes(data, length);
+ }
+
+ // Safer version of ReadInt() checks for the result not being negative.
+ // Use it for reading the object sizes.
+ bool ReadLength(PickleIterator* iter,
+ int* result) const WARN_UNUSED_RESULT {
+ return iter->ReadLength(result);
+ }
+
// Methods for adding to the payload of the Pickle. These values are
// appended to the end of the Pickle's payload. When reading values from a
// Pickle, it is important to read them in the order in which they were added
// to the Pickle.
-
bool WriteBool(bool value) {
return WriteInt(value ? 1 : 0);
}
« no previous file with comments | « no previous file | base/pickle_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698