summaryrefslogtreecommitdiffstats
path: root/base/pickle.h
diff options
context:
space:
mode:
authorAvi Drissman <avi@chromium.org>2014-12-22 14:14:56 -0500
committerAvi Drissman <avi@chromium.org>2014-12-22 19:13:42 +0000
commitb740bfe23ae7ad244356a4a7538b95ae560251db (patch)
treed2fa2e288c98d8ad8853b53716eae29c0c2a1d7d /base/pickle.h
parent94df224252d8304792b53bbefe8c97b761710315 (diff)
downloadchromium_src-b740bfe23ae7ad244356a4a7538b95ae560251db.zip
chromium_src-b740bfe23ae7ad244356a4a7538b95ae560251db.tar.gz
chromium_src-b740bfe23ae7ad244356a4a7538b95ae560251db.tar.bz2
Remove deprecated methods from Pickle.
BUG=444578 TEST=none R=nasko@chromium.org TBR=ben@chromium.org Review URL: https://codereview.chromium.org/818833004 Cr-Commit-Position: refs/heads/master@{#309445}
Diffstat (limited to 'base/pickle.h')
-rw-r--r--base/pickle.h99
1 files changed, 15 insertions, 84 deletions
diff --git a/base/pickle.h b/base/pickle.h
index 11cf484..f2a198e 100644
--- a/base/pickle.h
+++ b/base/pickle.h
@@ -26,7 +26,7 @@ class BASE_EXPORT PickleIterator {
// 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 iterator
+ // result could not be extracted. It is not possible to read from the iterator
// after that.
bool ReadBool(bool* result) WARN_UNUSED_RESULT;
bool ReadInt(int* result) WARN_UNUSED_RESULT;
@@ -41,10 +41,21 @@ class BASE_EXPORT PickleIterator {
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;
- // Safer version of ReadInt() checks for the result not being negative.
+ // A safer version of ReadInt() that 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;
@@ -57,7 +68,7 @@ class BASE_EXPORT PickleIterator {
}
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;
}
@@ -142,91 +153,11 @@ class BASE_EXPORT Pickle {
// 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);
}