diff options
author | jbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-07 20:42:56 +0000 |
---|---|---|
committer | jbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-07 20:42:56 +0000 |
commit | ce208f877048d4c7bbb57e0df045f0f39a9c80bf (patch) | |
tree | 24210ee34fc2c341d9d45c722e2941c9ab8ce768 | |
parent | d1f43abcb958e76806007d59f75f2da6078be89e (diff) | |
download | chromium_src-ce208f877048d4c7bbb57e0df045f0f39a9c80bf.zip chromium_src-ce208f877048d4c7bbb57e0df045f0f39a9c80bf.tar.gz chromium_src-ce208f877048d4c7bbb57e0df045f0f39a9c80bf.tar.bz2 |
Refactor Pickle Read methods to use higher performance PickleIterator.
There was a lot of redundant error checking and initialization code in all Pickle Read methods because of the void** iterator type. This change replaces the void* iterator with PickleIterator, which encapsulates the read pointer so that less error checking and initialization code is needed for reading.
PickleIterator has all the necessary data to do the actual reading. The advantage of having it provide Read methods (as opposed to leaving them solely in the Pickle interface) is that the callers do not need to pass around the const Pickle* once they have a PickleIterator.
Followup CLs will refactor the call sites to remove const Pickle* arguments where they are now unnecessary. Then the Pickle::Read* methods can be removed entirely.
The alternative approach would have been to change the Pickle::Read methods to non-const and remove the iterator parameter (making Read methods advance an internal read pointer). Unfortunately, the const Read with iterator design is entrenched throughout the chromium code, making this a much more complex change with the same performance outcome.
BUG=13108
Review URL: https://chromiumcodereview.appspot.com/9447084
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125447 0039d316-1c4b-4281-b951-d872f2087c98
129 files changed, 862 insertions, 765 deletions
diff --git a/base/file_path.cc b/base/file_path.cc index c4f1c54..3b1fca4 100644 --- a/base/file_path.cc +++ b/base/file_path.cc @@ -586,12 +586,12 @@ void FilePath::WriteToPickle(Pickle* pickle) { #endif } -bool FilePath::ReadFromPickle(Pickle* pickle, void** iter) { +bool FilePath::ReadFromPickle(PickleIterator* iter) { #if defined(OS_WIN) - if (!pickle->ReadString16(iter, &path_)) + if (!iter->ReadString16(&path_)) return false; #else - if (!pickle->ReadString(iter, &path_)) + if (!iter->ReadString(&path_)) return false; #endif diff --git a/base/file_path.h b/base/file_path.h index bde3cec..4d763eb 100644 --- a/base/file_path.h +++ b/base/file_path.h @@ -122,6 +122,7 @@ #endif // OS_WIN class Pickle; +class PickleIterator; // An abstraction to isolate users from the differences between native // pathnames on different platforms. @@ -339,7 +340,7 @@ class BASE_EXPORT FilePath { static FilePath FromUTF8Unsafe(const std::string& utf8); void WriteToPickle(Pickle* pickle); - bool ReadFromPickle(Pickle* pickle, void** iter); + bool ReadFromPickle(PickleIterator* iter); // Normalize all path separators to backslash on Windows // (if FILE_PATH_USES_WIN_SEPARATORS is true), or do nothing on POSIX systems. diff --git a/base/metrics/histogram.cc b/base/metrics/histogram.cc index a6f2b27..442b5b3 100644 --- a/base/metrics/histogram.cc +++ b/base/metrics/histogram.cc @@ -266,15 +266,15 @@ bool Histogram::DeserializeHistogramInfo(const std::string& histogram_info) { int pickle_flags; SampleSet sample; - void* iter = NULL; - if (!pickle.ReadString(&iter, &histogram_name) || - !pickle.ReadInt(&iter, &declared_min) || - !pickle.ReadInt(&iter, &declared_max) || - !pickle.ReadSize(&iter, &bucket_count) || - !pickle.ReadUInt32(&iter, &range_checksum) || - !pickle.ReadInt(&iter, &histogram_type) || - !pickle.ReadInt(&iter, &pickle_flags) || - !sample.Histogram::SampleSet::Deserialize(&iter, pickle)) { + PickleIterator iter(pickle); + if (!iter.ReadString(&histogram_name) || + !iter.ReadInt(&declared_min) || + !iter.ReadInt(&declared_max) || + !iter.ReadSize(&bucket_count) || + !iter.ReadUInt32(&range_checksum) || + !iter.ReadInt(&histogram_type) || + !iter.ReadInt(&pickle_flags) || + !sample.Histogram::SampleSet::Deserialize(&iter)) { DLOG(ERROR) << "Pickle error decoding Histogram: " << histogram_name; return false; } @@ -304,7 +304,7 @@ bool Histogram::DeserializeHistogramInfo(const std::string& histogram_info) { render_histogram = BooleanHistogram::FactoryGet(histogram_name, flags); } else if (histogram_type == CUSTOM_HISTOGRAM) { std::vector<Histogram::Sample> sample_ranges(bucket_count); - if (!CustomHistogram::DeserializeRanges(&iter, pickle, &sample_ranges)) { + if (!CustomHistogram::DeserializeRanges(&iter, &sample_ranges)) { DLOG(ERROR) << "Pickle error decoding ranges: " << histogram_name; return false; } @@ -772,16 +772,16 @@ bool Histogram::SampleSet::Serialize(Pickle* pickle) const { return true; } -bool Histogram::SampleSet::Deserialize(void** iter, const Pickle& pickle) { +bool Histogram::SampleSet::Deserialize(PickleIterator* iter) { DCHECK_EQ(counts_.size(), 0u); DCHECK_EQ(sum_, 0); DCHECK_EQ(redundant_count_, 0); size_t counts_size; - if (!pickle.ReadInt64(iter, &sum_) || - !pickle.ReadInt64(iter, &redundant_count_) || - !pickle.ReadSize(iter, &counts_size)) { + if (!iter->ReadInt64(&sum_) || + !iter->ReadInt64(&redundant_count_) || + !iter->ReadSize(&counts_size)) { return false; } @@ -791,7 +791,7 @@ bool Histogram::SampleSet::Deserialize(void** iter, const Pickle& pickle) { int count = 0; for (size_t index = 0; index < counts_size; ++index) { int i; - if (!pickle.ReadInt(iter, &i)) + if (!iter->ReadInt(&i)) return false; counts_.push_back(i); count += i; @@ -1015,9 +1015,9 @@ bool CustomHistogram::SerializeRanges(Pickle* pickle) const { // static bool CustomHistogram::DeserializeRanges( - void** iter, const Pickle& pickle, std::vector<Histogram::Sample>* ranges) { + PickleIterator* iter, std::vector<Histogram::Sample>* ranges) { for (size_t i = 0; i < ranges->size(); ++i) { - if (!pickle.ReadInt(iter, &(*ranges)[i])) + if (!iter->ReadInt(&(*ranges)[i])) return false; } return true; diff --git a/base/metrics/histogram.h b/base/metrics/histogram.h index d203e54..69d9b4c 100644 --- a/base/metrics/histogram.h +++ b/base/metrics/histogram.h @@ -54,6 +54,7 @@ #include "base/time.h" class Pickle; +class PickleIterator; namespace base { @@ -404,7 +405,7 @@ class BASE_EXPORT Histogram { void Subtract(const SampleSet& other); bool Serialize(Pickle* pickle) const; - bool Deserialize(void** iter, const Pickle& pickle); + bool Deserialize(PickleIterator* iter); protected: // Actual histogram data is stored in buckets, showing the count of values @@ -757,7 +758,7 @@ class BASE_EXPORT CustomHistogram : public Histogram { // Helper for deserializing CustomHistograms. |*ranges| should already be // correctly sized before this call. Return true on success. - static bool DeserializeRanges(void** iter, const Pickle& pickle, + static bool DeserializeRanges(PickleIterator* iter, std::vector<Histogram::Sample>* ranges); diff --git a/base/pickle.cc b/base/pickle.cc index 28b6292..a095e35 100644 --- a/base/pickle.cc +++ b/base/pickle.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -15,6 +15,143 @@ const int Pickle::kPayloadUnit = 64; static const size_t kCapacityReadOnly = static_cast<size_t>(-1); +PickleIterator::PickleIterator(const Pickle& pickle) + : read_ptr_(pickle.payload()), + read_end_ptr_(pickle.end_of_payload()) { +} + +template <typename Type> +inline bool PickleIterator::ReadBuiltinType(Type* result) { + const char* read_from = GetReadPointerAndAdvance<Type>(); + if (!read_from) + return false; + if (sizeof(Type) > sizeof(uint32)) + memcpy(result, read_from, sizeof(*result)); + else + *result = *reinterpret_cast<const Type*>(read_from); + return true; +} + +template<typename Type> +inline const char* PickleIterator::GetReadPointerAndAdvance() { + const char* current_read_ptr = read_ptr_; + if (read_ptr_ + sizeof(Type) > read_end_ptr_) + return NULL; + if (sizeof(Type) < sizeof(uint32)) + read_ptr_ += AlignInt(sizeof(Type), sizeof(uint32)); + else + read_ptr_ += sizeof(Type); + return current_read_ptr; +} + +const char* PickleIterator::GetReadPointerAndAdvance(int num_bytes) { + const char* current_read_ptr = read_ptr_; + const char* end_data_ptr = read_ptr_ + num_bytes; + if (num_bytes < 0) + return NULL; + // Check for enough space and for wrapping. + if (end_data_ptr > read_end_ptr_ || end_data_ptr < current_read_ptr) + return NULL; + read_ptr_ += AlignInt(num_bytes, sizeof(uint32)); + return current_read_ptr; +} + +inline const char* PickleIterator::GetReadPointerAndAdvance(int num_elements, + size_t size_element) { + // Check for int32 overflow. + int64 num_bytes = static_cast<int64>(num_elements) * size_element; + int num_bytes32 = static_cast<int>(num_bytes); + if (num_bytes != static_cast<int64>(num_bytes32)) + return NULL; + return GetReadPointerAndAdvance(num_bytes32); +} + +bool PickleIterator::ReadBool(bool* result) { + return ReadBuiltinType(result); +} + +bool PickleIterator::ReadInt(int* result) { + return ReadBuiltinType(result); +} + +bool PickleIterator::ReadLong(long* result) { + return ReadBuiltinType(result); +} + +bool PickleIterator::ReadSize(size_t* result) { + return ReadBuiltinType(result); +} + +bool PickleIterator::ReadUInt16(uint16* result) { + return ReadBuiltinType(result); +} + +bool PickleIterator::ReadUInt32(uint32* result) { + return ReadBuiltinType(result); +} + +bool PickleIterator::ReadInt64(int64* result) { + return ReadBuiltinType(result); +} + +bool PickleIterator::ReadUInt64(uint64* result) { + return ReadBuiltinType(result); +} + +bool PickleIterator::ReadString(std::string* result) { + int len; + if (!ReadInt(&len)) + return false; + const char* read_from = GetReadPointerAndAdvance(len); + if (!read_from) + return false; + + result->assign(read_from, len); + return true; +} + +bool PickleIterator::ReadWString(std::wstring* result) { + int len; + if (!ReadInt(&len)) + return false; + const char* read_from = GetReadPointerAndAdvance(len, sizeof(wchar_t)); + if (!read_from) + return false; + + result->assign(reinterpret_cast<const wchar_t*>(read_from), len); + return true; +} + +bool PickleIterator::ReadString16(string16* result) { + int len; + if (!ReadInt(&len)) + return false; + const char* read_from = GetReadPointerAndAdvance(len, sizeof(char16)); + if (!read_from) + return false; + + result->assign(reinterpret_cast<const char16*>(read_from), len); + return true; +} + +bool PickleIterator::ReadData(const char** data, int* length) { + *length = 0; + *data = 0; + + if (!ReadInt(length)) + return false; + + return ReadBytes(data, *length); +} + +bool PickleIterator::ReadBytes(const char** data, int length) { + const char* read_from = GetReadPointerAndAdvance(length); + if (!read_from) + return false; + *data = read_from; + return true; +} + // Payload is uint32 aligned. Pickle::Pickle() @@ -94,209 +231,6 @@ Pickle& Pickle::operator=(const Pickle& other) { return *this; } -bool Pickle::ReadBool(void** iter, bool* result) const { - DCHECK(iter); - - int tmp; - if (!ReadInt(iter, &tmp)) - return false; - DCHECK(0 == tmp || 1 == tmp); - *result = tmp ? true : false; - return true; -} - -bool Pickle::ReadInt(void** iter, int* result) const { - DCHECK(iter); - if (!*iter) - *iter = const_cast<char*>(payload()); - - if (!IteratorHasRoomFor(*iter, sizeof(*result))) - return false; - - // TODO(jar): http://crbug.com/13108 Pickle should be cleaned up, and not - // dependent on alignment. - // Next line is otherwise the same as: memcpy(result, *iter, sizeof(*result)); - *result = *reinterpret_cast<int*>(*iter); - - UpdateIter(iter, sizeof(*result)); - return true; -} - -bool Pickle::ReadLong(void** iter, long* result) const { - DCHECK(iter); - if (!*iter) - *iter = const_cast<char*>(payload()); - - if (!IteratorHasRoomFor(*iter, sizeof(*result))) - return false; - - // TODO(jar): http://crbug.com/13108 Pickle should be cleaned up, and not - // dependent on alignment. - memcpy(result, *iter, sizeof(*result)); - - UpdateIter(iter, sizeof(*result)); - return true; -} - -bool Pickle::ReadSize(void** iter, size_t* result) const { - DCHECK(iter); - if (!*iter) - *iter = const_cast<char*>(payload()); - - if (!IteratorHasRoomFor(*iter, sizeof(*result))) - return false; - - // TODO(jar): http://crbug.com/13108 Pickle should be cleaned up, and not - // dependent on alignment. - // Next line is otherwise the same as: memcpy(result, *iter, sizeof(*result)); - *result = *reinterpret_cast<size_t*>(*iter); - - UpdateIter(iter, sizeof(*result)); - return true; -} - -bool Pickle::ReadUInt16(void** iter, uint16* result) const { - DCHECK(iter); - if (!*iter) - *iter = const_cast<char*>(payload()); - - if (!IteratorHasRoomFor(*iter, sizeof(*result))) - return false; - - memcpy(result, *iter, sizeof(*result)); - - UpdateIter(iter, sizeof(*result)); - return true; -} - -bool Pickle::ReadUInt32(void** iter, uint32* result) const { - DCHECK(iter); - if (!*iter) - *iter = const_cast<char*>(payload()); - - if (!IteratorHasRoomFor(*iter, sizeof(*result))) - return false; - - memcpy(result, *iter, sizeof(*result)); - - UpdateIter(iter, sizeof(*result)); - return true; -} - -bool Pickle::ReadInt64(void** iter, int64* result) const { - DCHECK(iter); - if (!*iter) - *iter = const_cast<char*>(payload()); - - if (!IteratorHasRoomFor(*iter, sizeof(*result))) - return false; - - memcpy(result, *iter, sizeof(*result)); - - UpdateIter(iter, sizeof(*result)); - return true; -} - -bool Pickle::ReadUInt64(void** iter, uint64* result) const { - DCHECK(iter); - if (!*iter) - *iter = const_cast<char*>(payload()); - - if (!IteratorHasRoomFor(*iter, sizeof(*result))) - return false; - - memcpy(result, *iter, sizeof(*result)); - - UpdateIter(iter, sizeof(*result)); - return true; -} - -bool Pickle::ReadString(void** iter, std::string* result) const { - DCHECK(iter); - - int len; - if (!ReadLength(iter, &len)) - return false; - if (!IteratorHasRoomFor(*iter, len)) - return false; - - char* chars = reinterpret_cast<char*>(*iter); - result->assign(chars, len); - - UpdateIter(iter, len); - return true; -} - -bool Pickle::ReadWString(void** iter, std::wstring* result) const { - DCHECK(iter); - - int len; - if (!ReadLength(iter, &len)) - return false; - // Avoid integer overflow. - if (len > INT_MAX / static_cast<int>(sizeof(wchar_t))) - return false; - if (!IteratorHasRoomFor(*iter, len * sizeof(wchar_t))) - return false; - - wchar_t* chars = reinterpret_cast<wchar_t*>(*iter); - result->assign(chars, len); - - UpdateIter(iter, len * sizeof(wchar_t)); - return true; -} - -bool Pickle::ReadString16(void** iter, string16* result) const { - DCHECK(iter); - - int len; - if (!ReadLength(iter, &len)) - return false; - if (!IteratorHasRoomFor(*iter, len * sizeof(char16))) - return false; - - char16* chars = reinterpret_cast<char16*>(*iter); - result->assign(chars, len); - - UpdateIter(iter, len * sizeof(char16)); - return true; -} - -bool Pickle::ReadData(void** iter, const char** data, int* length) const { - DCHECK(iter); - DCHECK(data); - DCHECK(length); - *length = 0; - *data = 0; - - if (!ReadLength(iter, length)) - return false; - - return ReadBytes(iter, data, *length); -} - -bool Pickle::ReadBytes(void** iter, const char** data, int length) const { - DCHECK(iter); - DCHECK(data); - *data = 0; - if (!*iter) - *iter = const_cast<char*>(payload()); - - if (!IteratorHasRoomFor(*iter, length)) - return false; - - *data = reinterpret_cast<const char*>(*iter); - - UpdateIter(iter, length); - return true; -} - -bool Pickle::ReadLength(void** iter, int* result) const { - if (!ReadInt(iter, result)) - return false; - return ((*result) >= 0); -} - bool Pickle::WriteString(const std::string& value) { if (!WriteInt(static_cast<int>(value.size()))) return false; diff --git a/base/pickle.h b/base/pickle.h index 65353de..47e3bf6 100644 --- a/base/pickle.h +++ b/base/pickle.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -10,10 +10,80 @@ #include "base/base_export.h" #include "base/basictypes.h" +#include "base/compiler_specific.h" #include "base/gtest_prod_util.h" #include "base/logging.h" #include "base/string16.h" +class Pickle; + +// PickleIterator reads data from a Pickle. The Pickle object must remain valid +// while the PickleIterator object is in use. +class BASE_EXPORT PickleIterator { + public: + PickleIterator() : read_ptr_(NULL), read_end_ptr_(NULL) {} + explicit PickleIterator(const Pickle& pickle); + + // 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. + bool ReadBool(bool* result) WARN_UNUSED_RESULT; + bool ReadInt(int* result) WARN_UNUSED_RESULT; + bool ReadLong(long* result) WARN_UNUSED_RESULT; + bool ReadSize(size_t* result) WARN_UNUSED_RESULT; + bool ReadUInt16(uint16* result) WARN_UNUSED_RESULT; + bool ReadUInt32(uint32* result) WARN_UNUSED_RESULT; + bool ReadInt64(int64* result) WARN_UNUSED_RESULT; + bool ReadUInt64(uint64* result) WARN_UNUSED_RESULT; + bool ReadString(std::string* result) WARN_UNUSED_RESULT; + bool ReadWString(std::wstring* result) WARN_UNUSED_RESULT; + bool ReadString16(string16* result) WARN_UNUSED_RESULT; + bool ReadData(const char** data, int* length) WARN_UNUSED_RESULT; + bool ReadBytes(const char** data, int length) WARN_UNUSED_RESULT; + + // 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; + } + + // Skips bytes in the read buffer and returns true if there are at least + // num_bytes available. Otherwise, does nothing and returns false. + bool SkipBytes(int num_bytes) WARN_UNUSED_RESULT { + return !!GetReadPointerAndAdvance(num_bytes); + } + + private: + // 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; + } + + // Read Type from Pickle. + template <typename Type> + inline bool ReadBuiltinType(Type* result); + + // Get read pointer for Type and advance read pointer. + template<typename Type> + inline const char* GetReadPointerAndAdvance(); + + // Get read pointer for |num_bytes| and advance read pointer. This method + // checks num_bytes for negativity and wrapping. + const char* GetReadPointerAndAdvance(int num_bytes); + + // Get read pointer for (num_elements * size_element) bytes and advance read + // pointer. This method checks for int overflow, negativity and wrapping. + inline const char* GetReadPointerAndAdvance(int num_elements, + size_t size_element); + + // Pointers to the Pickle data. + const char* read_ptr_; + const char* read_end_ptr_; + + FRIEND_TEST_ALL_PREFIXES(PickleTest, GetReadPointerAndAdvance); +}; + // This class provides facilities for basic binary value packing and unpacking. // // The Pickle class supports appending primitive values (ints, strings, etc.) @@ -66,27 +136,54 @@ class BASE_EXPORT Pickle { // Returns the data for this Pickle. const void* data() const { return header_; } - // Methods for reading the payload of the Pickle. To read from the start of - // the Pickle, initialize *iter to NULL. If successful, these methods return - // true. Otherwise, false is returned to indicate that the result could not - // be extracted. - bool ReadBool(void** iter, bool* result) const; - bool ReadInt(void** iter, int* result) const; - bool ReadLong(void** iter, long* result) const; - bool ReadSize(void** iter, size_t* result) const; - bool ReadUInt16(void** iter, uint16* result) const; - bool ReadUInt32(void** iter, uint32* result) const; - bool ReadInt64(void** iter, int64* result) const; - bool ReadUInt64(void** iter, uint64* result) const; - bool ReadString(void** iter, std::string* result) const; - bool ReadWString(void** iter, std::wstring* result) const; - bool ReadString16(void** iter, string16* result) const; - bool ReadData(void** iter, const char** data, int* length) const; - bool ReadBytes(void** iter, const char** data, int length) const; + // 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 { + return iter->ReadBool(result); + } + bool ReadInt(PickleIterator* iter, int* result) const { + return iter->ReadInt(result); + } + bool ReadLong(PickleIterator* iter, long* result) const { + return iter->ReadLong(result); + } + bool ReadSize(PickleIterator* iter, size_t* result) const { + return iter->ReadSize(result); + } + bool ReadUInt16(PickleIterator* iter, uint16* result) const { + return iter->ReadUInt16(result); + } + bool ReadUInt32(PickleIterator* iter, uint32* result) const { + return iter->ReadUInt32(result); + } + bool ReadInt64(PickleIterator* iter, int64* result) const { + return iter->ReadInt64(result); + } + bool ReadUInt64(PickleIterator* iter, uint64* result) const { + return iter->ReadUInt64(result); + } + bool ReadString(PickleIterator* iter, std::string* result) const { + return iter->ReadString(result); + } + bool ReadWString(PickleIterator* iter, std::wstring* result) const { + return iter->ReadWString(result); + } + bool ReadString16(PickleIterator* iter, string16* result) const { + return iter->ReadString16(result); + } + bool ReadData(PickleIterator* iter, const char** data, int* length) const { + return iter->ReadData(data, length); + } + bool ReadBytes(PickleIterator* iter, const char** data, int length) const { + 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(void** iter, int* result) const; + bool ReadLength(PickleIterator* iter, int* result) const { + 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 @@ -162,17 +259,6 @@ class BASE_EXPORT Pickle { return static_cast<const T*>(header_); } - // Returns true if the given iterator could point to data with the given - // length. If there is no room for the given data before the end of the - // payload, returns false. - bool IteratorHasRoomFor(const void* iter, int len) const { - if ((len < 0) || (iter < header_) || iter > end_of_payload()) - return false; - const char* end_of_region = reinterpret_cast<const char*>(iter) + len; - // Watch out for overflow in pointer calculation, which wraps. - return (iter <= end_of_region) && (end_of_region <= end_of_payload()); - } - protected: size_t payload_size() const { return header_->payload_size; } @@ -220,13 +306,6 @@ class BASE_EXPORT Pickle { return i + (alignment - (i % alignment)) % alignment; } - // Moves the iterator by the given number of bytes, making sure it is aligned. - // Pointer (iterator) is NOT aligned, but the change in the pointer - // is guaranteed to be a multiple of sizeof(uint32). - static void UpdateIter(void** iter, int bytes) { - *iter = static_cast<char*>(*iter) + AlignInt(bytes, sizeof(uint32)); - } - // 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, @@ -237,6 +316,8 @@ class BASE_EXPORT Pickle { static const int kPayloadUnit; private: + friend class PickleIterator; + Header* header_; size_t header_size_; // Supports extra data between header and payload. // Allocation size of payload (or -1 if allocation is const). @@ -246,7 +327,6 @@ class BASE_EXPORT Pickle { FRIEND_TEST_ALL_PREFIXES(PickleTest, Resize); FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNext); FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNextWithIncompleteHeader); - FRIEND_TEST_ALL_PREFIXES(PickleTest, IteratorHasRoom); }; #endif // BASE_PICKLE_H__ diff --git a/base/pickle_unittest.cc b/base/pickle_unittest.cc index 07be5e3..8cb1d2a1 100644 --- a/base/pickle_unittest.cc +++ b/base/pickle_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -23,7 +23,7 @@ const uint16 testuint16 = 32123; // checks that the result void VerifyResult(const Pickle& pickle) { - void* iter = NULL; + PickleIterator iter(pickle); int outint; EXPECT_TRUE(pickle.ReadInt(&iter, &outint)); @@ -100,7 +100,7 @@ TEST(PickleTest, SmallBuffer) { // We should not touch the buffer. Pickle pickle(buffer.get(), 1); - void* iter = NULL; + PickleIterator iter(pickle); int data; EXPECT_FALSE(pickle.ReadInt(&iter, &data)); } @@ -111,7 +111,7 @@ TEST(PickleTest, BigSize) { Pickle pickle(reinterpret_cast<char*>(buffer), sizeof(buffer)); - void* iter = NULL; + PickleIterator iter(pickle); int data; EXPECT_FALSE(pickle.ReadInt(&iter, &data)); } @@ -121,7 +121,7 @@ TEST(PickleTest, UnalignedSize) { Pickle pickle(reinterpret_cast<char*>(buffer), sizeof(buffer)); - void* iter = NULL; + PickleIterator iter(pickle); int data; EXPECT_FALSE(pickle.ReadInt(&iter, &data)); } @@ -130,7 +130,7 @@ TEST(PickleTest, ZeroLenStr) { Pickle pickle; EXPECT_TRUE(pickle.WriteString("")); - void* iter = NULL; + PickleIterator iter(pickle); std::string outstr; EXPECT_TRUE(pickle.ReadString(&iter, &outstr)); EXPECT_EQ("", outstr); @@ -140,7 +140,7 @@ TEST(PickleTest, ZeroLenWStr) { Pickle pickle; EXPECT_TRUE(pickle.WriteWString(L"")); - void* iter = NULL; + PickleIterator iter(pickle); std::string outstr; EXPECT_TRUE(pickle.ReadString(&iter, &outstr)); EXPECT_EQ("", outstr); @@ -150,7 +150,7 @@ TEST(PickleTest, BadLenStr) { Pickle pickle; EXPECT_TRUE(pickle.WriteInt(-2)); - void* iter = NULL; + PickleIterator iter(pickle); std::string outstr; EXPECT_FALSE(pickle.ReadString(&iter, &outstr)); } @@ -159,7 +159,7 @@ TEST(PickleTest, BadLenWStr) { Pickle pickle; EXPECT_TRUE(pickle.WriteInt(-1)); - void* iter = NULL; + PickleIterator iter(pickle); std::wstring woutstr; EXPECT_FALSE(pickle.ReadWString(&iter, &woutstr)); } @@ -188,19 +188,23 @@ TEST(PickleTest, FindNextWithIncompleteHeader) { EXPECT_TRUE(NULL == Pickle::FindNext(header_size, start, end)); } -TEST(PickleTest, IteratorHasRoom) { +TEST(PickleTest, GetReadPointerAndAdvance) { Pickle pickle; + + PickleIterator iter(pickle); + EXPECT_FALSE(iter.GetReadPointerAndAdvance(1)); + EXPECT_TRUE(pickle.WriteInt(1)); EXPECT_TRUE(pickle.WriteInt(2)); - - const void* iter = 0; - EXPECT_FALSE(pickle.IteratorHasRoomFor(iter, 1)); - iter = pickle.payload(); - EXPECT_TRUE(pickle.IteratorHasRoomFor(iter, 0)); - EXPECT_TRUE(pickle.IteratorHasRoomFor(iter, 1)); - EXPECT_FALSE(pickle.IteratorHasRoomFor(iter, -1)); - EXPECT_TRUE(pickle.IteratorHasRoomFor(iter, sizeof(int) * 2)); - EXPECT_FALSE(pickle.IteratorHasRoomFor(iter, (sizeof(int) * 2) + 1)); + int bytes = sizeof(int) * 2; + + EXPECT_TRUE(PickleIterator(pickle).GetReadPointerAndAdvance(0)); + EXPECT_TRUE(PickleIterator(pickle).GetReadPointerAndAdvance(1)); + EXPECT_FALSE(PickleIterator(pickle).GetReadPointerAndAdvance(-1)); + EXPECT_TRUE(PickleIterator(pickle).GetReadPointerAndAdvance(bytes)); + EXPECT_FALSE(PickleIterator(pickle).GetReadPointerAndAdvance(bytes + 1)); + EXPECT_FALSE(PickleIterator(pickle).GetReadPointerAndAdvance(INT_MAX)); + EXPECT_FALSE(PickleIterator(pickle).GetReadPointerAndAdvance(INT_MIN)); } TEST(PickleTest, Resize) { @@ -252,7 +256,7 @@ TEST(PickleTest, HeaderPadding) { // this should not overwrite the 'int' payload pickle.headerT<CustomHeader>()->blah = 10; - void* iter = NULL; + PickleIterator iter(pickle); int result; ASSERT_TRUE(pickle.ReadInt(&iter, &result)); @@ -273,25 +277,32 @@ TEST(PickleTest, EqualsOperator) { TEST(PickleTest, EvilLengths) { Pickle source; std::string str(100000, 'A'); - source.WriteData(str.c_str(), 100000); + EXPECT_TRUE(source.WriteData(str.c_str(), 100000)); // ReadString16 used to have its read buffer length calculation wrong leading // to out-of-bounds reading. - void* iter = NULL; + PickleIterator iter(source); string16 str16; EXPECT_FALSE(source.ReadString16(&iter, &str16)); // And check we didn't break ReadString16. str16 = (wchar_t) 'A'; Pickle str16_pickle; - str16_pickle.WriteString16(str16); - iter = NULL; + EXPECT_TRUE(str16_pickle.WriteString16(str16)); + iter = PickleIterator(str16_pickle); EXPECT_TRUE(str16_pickle.ReadString16(&iter, &str16)); EXPECT_EQ(1U, str16.length()); + // Check we don't fail in a length check with invalid String16 size. + // (1<<31) * sizeof(char16) == 0, so this is particularly evil. + Pickle bad_len; + EXPECT_TRUE(bad_len.WriteInt(1 << 31)); + iter = PickleIterator(bad_len); + EXPECT_FALSE(bad_len.ReadString16(&iter, &str16)); + // Check we don't fail in a length check with large WStrings. Pickle big_len; - big_len.WriteInt(1 << 30); - iter = NULL; + EXPECT_TRUE(big_len.WriteInt(1 << 30)); + iter = PickleIterator(big_len); std::wstring wstr; EXPECT_FALSE(big_len.ReadWString(&iter, &wstr)); } @@ -301,7 +312,7 @@ TEST(PickleTest, ZeroLength) { Pickle pickle; EXPECT_TRUE(pickle.WriteData(NULL, 0)); - void* iter = NULL; + PickleIterator iter(pickle); const char* outdata; int outdatalen; EXPECT_TRUE(pickle.ReadData(&iter, &outdata, &outdatalen)); @@ -315,8 +326,8 @@ TEST(PickleTest, ReadBytes) { int data = 0x7abcd; EXPECT_TRUE(pickle.WriteBytes(&data, sizeof(data))); - void* iter = NULL; - const char* outdata_char; + PickleIterator iter(pickle); + const char* outdata_char = NULL; EXPECT_TRUE(pickle.ReadBytes(&iter, &outdata_char, sizeof(data))); int outdata; diff --git a/chrome/browser/automation/url_request_automation_job.cc b/chrome/browser/automation/url_request_automation_job.cc index c5b3d70..231a4c5 100644 --- a/chrome/browser/automation/url_request_automation_job.cc +++ b/chrome/browser/automation/url_request_automation_job.cc @@ -253,7 +253,7 @@ bool URLRequestAutomationJob::MayFilterMessage(const IPC::Message& message, case AutomationMsg_RequestStarted::ID: case AutomationMsg_RequestData::ID: case AutomationMsg_RequestEnd::ID: { - void* iter = NULL; + PickleIterator iter(message); if (message.ReadInt(&iter, request_id)) return true; break; diff --git a/chrome/browser/bookmarks/bookmark_node_data.cc b/chrome/browser/bookmarks/bookmark_node_data.cc index 7d1d72f..14c77d3 100644 --- a/chrome/browser/bookmarks/bookmark_node_data.cc +++ b/chrome/browser/bookmarks/bookmark_node_data.cc @@ -55,7 +55,7 @@ void BookmarkNodeData::Element::WriteToPickle(Pickle* pickle) const { } bool BookmarkNodeData::Element::ReadFromPickle(Pickle* pickle, - void** iterator) { + PickleIterator* iterator) { std::string url_spec; if (!pickle->ReadBool(iterator, &is_url) || !pickle->ReadString(iterator, &url_spec) || @@ -294,9 +294,9 @@ void BookmarkNodeData::WriteToPickle(Profile* profile, Pickle* pickle) const { } bool BookmarkNodeData::ReadFromPickle(Pickle* pickle) { - void* data_iterator = NULL; + PickleIterator data_iterator(*pickle); size_t element_count; - if (profile_path_.ReadFromPickle(pickle, &data_iterator) && + if (profile_path_.ReadFromPickle(&data_iterator) && pickle->ReadSize(&data_iterator, &element_count)) { std::vector<Element> tmp_elements; tmp_elements.resize(element_count); diff --git a/chrome/browser/bookmarks/bookmark_node_data.h b/chrome/browser/bookmarks/bookmark_node_data.h index 748e78a..5c1f9e6 100644 --- a/chrome/browser/bookmarks/bookmark_node_data.h +++ b/chrome/browser/bookmarks/bookmark_node_data.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -18,6 +18,7 @@ class BookmarkNode; class Pickle; +class PickleIterator; class Profile; // BookmarkNodeData is used to represent the following: @@ -64,7 +65,7 @@ struct BookmarkNodeData { // For reading/writing this Element. void WriteToPickle(Pickle* pickle) const; - bool ReadFromPickle(Pickle* pickle, void** iterator); + bool ReadFromPickle(Pickle* pickle, PickleIterator* iterator); // ID of the node. int64 id_; diff --git a/chrome/browser/extensions/execute_code_in_tab_function.cc b/chrome/browser/extensions/execute_code_in_tab_function.cc index 5e98a8d..d17de24 100644 --- a/chrome/browser/extensions/execute_code_in_tab_function.cc +++ b/chrome/browser/extensions/execute_code_in_tab_function.cc @@ -238,7 +238,7 @@ bool ExecuteCodeInTabFunction::OnMessageReceived(const IPC::Message& message) { return false; int message_request_id; - void* iter = NULL; + PickleIterator iter(message); if (!message.ReadInt(&iter, &message_request_id)) { NOTREACHED() << "malformed extension message"; return true; diff --git a/chrome/browser/extensions/extension_browser_actions_api.cc b/chrome/browser/extensions/extension_browser_actions_api.cc index 0a37658..df58bfd 100644 --- a/chrome/browser/extensions/extension_browser_actions_api.cc +++ b/chrome/browser/extensions/extension_browser_actions_api.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -49,7 +49,7 @@ bool BrowserActionSetIconFunction::RunBrowserAction() { base::BinaryValue* binary = NULL; EXTENSION_FUNCTION_VALIDATE(details_->GetBinary("imageData", &binary)); IPC::Message bitmap_pickle(binary->GetBuffer(), binary->GetSize()); - void* iter = NULL; + PickleIterator iter(bitmap_pickle); SkBitmap bitmap; EXTENSION_FUNCTION_VALIDATE( IPC::ReadParam(&bitmap_pickle, &iter, &bitmap)); diff --git a/chrome/browser/extensions/extension_messages_browsertest.cc b/chrome/browser/extensions/extension_messages_browsertest.cc index 6f9feb3..a79f021 100644 --- a/chrome/browser/extensions/extension_messages_browsertest.cc +++ b/chrome/browser/extensions/extension_messages_browsertest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -65,7 +65,7 @@ TEST_F(ChromeRenderViewTest, ExtensionMessagesOpenChannel) { render_thread_->sink().GetUniqueMessageMatching( ExtensionHostMsg_OpenChannelToExtension::ID); ASSERT_TRUE(open_channel_msg); - void* iter = IPC::SyncMessage::GetDataIterator(open_channel_msg); + PickleIterator iter = IPC::SyncMessage::GetDataIterator(open_channel_msg); ExtensionHostMsg_OpenChannelToExtension::SendParam open_params; ASSERT_TRUE(IPC::ReadParam(open_channel_msg, &iter, &open_params)); EXPECT_EQ("testName", open_params.d); diff --git a/chrome/browser/extensions/extension_page_actions_module.cc b/chrome/browser/extensions/extension_page_actions_module.cc index 1e97ad7..d154d76 100644 --- a/chrome/browser/extensions/extension_page_actions_module.cc +++ b/chrome/browser/extensions/extension_page_actions_module.cc @@ -161,7 +161,7 @@ bool PageActionSetIconFunction::RunImpl() { int icon_index; if (args->GetBinary("imageData", &binary)) { IPC::Message bitmap_pickle(binary->GetBuffer(), binary->GetSize()); - void* iter = NULL; + PickleIterator iter(bitmap_pickle); scoped_ptr<SkBitmap> bitmap(new SkBitmap); EXTENSION_FUNCTION_VALIDATE( IPC::ReadParam(&bitmap_pickle, &iter, bitmap.get())); diff --git a/chrome/browser/extensions/extension_page_capture_api.cc b/chrome/browser/extensions/extension_page_capture_api.cc index 0f51bb25..3ae91d0 100644 --- a/chrome/browser/extensions/extension_page_capture_api.cc +++ b/chrome/browser/extensions/extension_page_capture_api.cc @@ -72,7 +72,7 @@ bool PageCaptureSaveAsMHTMLFunction::OnMessageReceivedFromRenderView( return false; int message_request_id; - void* iter = NULL; + PickleIterator iter(message); if (!message.ReadInt(&iter, &message_request_id)) { NOTREACHED() << "malformed extension message"; return true; diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc index 1f7d530..6ab586a 100644 --- a/chrome/browser/extensions/extension_tabs_module.cc +++ b/chrome/browser/extensions/extension_tabs_module.cc @@ -1359,7 +1359,7 @@ bool UpdateTabFunction::OnMessageReceived(const IPC::Message& message) { return false; int message_request_id = -1; - void* iter = NULL; + PickleIterator iter(message); if (!message.ReadInt(&iter, &message_request_id)) { NOTREACHED() << "malformed extension message"; return true; diff --git a/chrome/browser/importer/profile_import_process_messages.h b/chrome/browser/importer/profile_import_process_messages.h index 5487cfe..293bafe 100644 --- a/chrome/browser/importer/profile_import_process_messages.h +++ b/chrome/browser/importer/profile_import_process_messages.h @@ -35,7 +35,7 @@ struct ParamTraits<importer::SourceProfile> { WriteParam(m, p.app_path); WriteParam(m, static_cast<int>(p.services_supported)); } - static bool Read(const Message* m, void** iter, param_type* p) { + static bool Read(const Message* m, PickleIterator* iter, param_type* p) { if (!ReadParam(m, iter, &p->importer_name)) return false; @@ -83,7 +83,7 @@ struct ParamTraits<history::URLRow> { WriteParam(m, p.last_visit()); WriteParam(m, p.hidden()); } - static bool Read(const Message* m, void** iter, param_type* p) { + static bool Read(const Message* m, PickleIterator* iter, param_type* p) { history::URLID id; GURL url; string16 title; @@ -137,7 +137,7 @@ struct ParamTraits<ProfileWriter::BookmarkEntry> { WriteParam(m, p.title); WriteParam(m, p.creation_time); } - static bool Read(const Message* m, void** iter, param_type* p) { + static bool Read(const Message* m, PickleIterator* iter, param_type* p) { return (ReadParam(m, iter, &p->in_toolbar)) && (ReadParam(m, iter, &p->is_folder)) && @@ -172,7 +172,7 @@ struct ParamTraits<history::ImportedFaviconUsage> { WriteParam(m, p.png_data); WriteParam(m, p.urls); } - static bool Read(const Message* m, void** iter, param_type* p) { + static bool Read(const Message* m, PickleIterator* iter, param_type* p) { return ReadParam(m, iter, &p->favicon_url) && ReadParam(m, iter, &p->png_data) && @@ -198,7 +198,7 @@ struct ParamTraits<TemplateURLRef> { WriteParam(m, p.index_offset()); WriteParam(m, p.page_offset()); } - static bool Read(const Message* m, void** iter, param_type* p) { + static bool Read(const Message* m, PickleIterator* iter, param_type* p) { std::string url; int index_offset; int page_offset; @@ -224,7 +224,7 @@ struct ParamTraits<TemplateURL::ImageRef> { WriteParam(m, p.height); WriteParam(m, p.url); } - static bool Read(const Message* m, void** iter, param_type* p) { + static bool Read(const Message* m, PickleIterator* iter, param_type* p) { std::string type; int width; int height; @@ -278,7 +278,7 @@ struct ParamTraits<TemplateURL> { WriteParam(m, p.usage_count()); WriteParam(m, p.prepopulate_id()); } - static bool Read(const Message* m, void** iter, param_type* p) { + static bool Read(const Message* m, PickleIterator* iter, param_type* p) { string16 short_name; string16 description; bool includes_suggestions_url; diff --git a/chrome/browser/password_manager/native_backend_kwallet_x.cc b/chrome/browser/password_manager/native_backend_kwallet_x.cc index 787ed5b..964a70c 100644 --- a/chrome/browser/password_manager/native_backend_kwallet_x.cc +++ b/chrome/browser/password_manager/native_backend_kwallet_x.cc @@ -682,7 +682,7 @@ bool NativeBackendKWallet::CheckSerializedValue(const uint8_t* byte_array, void NativeBackendKWallet::DeserializeValue(const std::string& signon_realm, const Pickle& pickle, PasswordFormList* forms) { - void* iter = NULL; + PickleIterator iter(pickle); int version = -1; if (!pickle.ReadInt(&iter, &version) || version != kPickleVersion) { @@ -739,7 +739,7 @@ void NativeBackendKWallet::DeserializeValue(const std::string& signon_realm, } } -bool NativeBackendKWallet::ReadGURL(const Pickle& pickle, void** iter, +bool NativeBackendKWallet::ReadGURL(const Pickle& pickle, PickleIterator* iter, GURL* url) { std::string url_string; if (!pickle.ReadString(iter, &url_string)) { diff --git a/chrome/browser/password_manager/native_backend_kwallet_x.h b/chrome/browser/password_manager/native_backend_kwallet_x.h index 23d259b..6774a8e 100644 --- a/chrome/browser/password_manager/native_backend_kwallet_x.h +++ b/chrome/browser/password_manager/native_backend_kwallet_x.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -15,6 +15,7 @@ #include "chrome/browser/profiles/profile.h" class Pickle; +class PickleIterator; class PrefService; namespace webkit { @@ -129,7 +130,7 @@ class NativeBackendKWallet : public PasswordStoreX::NativeBackend { // Convenience function to read a GURL from a Pickle. Assumes the URL has // been written as a std::string. Returns true on success. - static bool ReadGURL(const Pickle& pickle, void** iter, GURL* url); + static bool ReadGURL(const Pickle& pickle, PickleIterator* iter, GURL* url); // In case the fields in the pickle ever change, version them so we can try to // read old pickles. (Note: do not eat old pickles past the expiration date.) diff --git a/chrome/browser/sessions/base_session_service.cc b/chrome/browser/sessions/base_session_service.cc index 9f4d05a..6925d91 100644 --- a/chrome/browser/sessions/base_session_service.cc +++ b/chrome/browser/sessions/base_session_service.cc @@ -273,7 +273,7 @@ bool BaseSessionService::RestoreUpdateTabNavigationCommand( scoped_ptr<Pickle> pickle(command.PayloadAsPickle()); if (!pickle.get()) return false; - void* iterator = NULL; + PickleIterator iterator(*pickle); std::string url_spec; if (!pickle->ReadInt(&iterator, tab_id) || !pickle->ReadInt(&iterator, &(navigation->index_)) || @@ -328,7 +328,7 @@ bool BaseSessionService::RestoreSetTabExtensionAppIDCommand( if (!pickle.get()) return false; - void* iterator = NULL; + PickleIterator iterator(*pickle); return pickle->ReadInt(&iterator, tab_id) && pickle->ReadString(&iterator, extension_app_id); } @@ -341,7 +341,7 @@ bool BaseSessionService::RestoreSetWindowAppNameCommand( if (!pickle.get()) return false; - void* iterator = NULL; + PickleIterator iterator(*pickle); return pickle->ReadInt(&iterator, window_id) && pickle->ReadString(&iterator, app_name); } diff --git a/chrome/browser/sessions/compress_data_helper.cc b/chrome/browser/sessions/compress_data_helper.cc index 987af6a..d879fe6 100644 --- a/chrome/browser/sessions/compress_data_helper.cc +++ b/chrome/browser/sessions/compress_data_helper.cc @@ -83,7 +83,7 @@ void CompressDataHelper::CompressAndWriteStringToPickle(const std::string& str, // static bool CompressDataHelper::ReadAndDecompressStringFromPickle(const Pickle& pickle, - void** iter, + PickleIterator* iter, std::string* str) { // Read the size of the original data. int original_size = 0; diff --git a/chrome/browser/sessions/compress_data_helper.h b/chrome/browser/sessions/compress_data_helper.h index d7cbbaa..768fc5e 100644 --- a/chrome/browser/sessions/compress_data_helper.h +++ b/chrome/browser/sessions/compress_data_helper.h @@ -11,6 +11,7 @@ #include <string> class Pickle; +class PickleIterator; class CompressDataHelper { public: @@ -25,7 +26,7 @@ class CompressDataHelper { // indicates the position of the data. The same iterator is used by // Pickle::Read* functions. static bool ReadAndDecompressStringFromPickle(const Pickle& pickle, - void** iter, + PickleIterator* iter, std::string* str); private: DISALLOW_IMPLICIT_CONSTRUCTORS(CompressDataHelper); diff --git a/chrome/browser/sessions/compress_data_helper_unittest.cc b/chrome/browser/sessions/compress_data_helper_unittest.cc index 3e1da3f..f993bc5 100644 --- a/chrome/browser/sessions/compress_data_helper_unittest.cc +++ b/chrome/browser/sessions/compress_data_helper_unittest.cc @@ -23,7 +23,7 @@ TEST_F(CompressDataHelperTest, CompressAndDecompressData) { EXPECT_GT(bytes_written, 0); EXPECT_LT(bytes_written, max_bytes + 1); - void* it = NULL; + PickleIterator it(pickle); std::string data_out; ASSERT_TRUE(CompressDataHelper::ReadAndDecompressStringFromPickle( @@ -45,7 +45,7 @@ TEST_F(CompressDataHelperTest, CompressAndDecompressEmptyData) { EXPECT_EQ(0, bytes_written); - void* it = NULL; + PickleIterator it(pickle); std::string data_out; ASSERT_TRUE(CompressDataHelper::ReadAndDecompressStringFromPickle( pickle, &it, &data_out)); @@ -65,7 +65,7 @@ TEST_F(CompressDataHelperTest, TooMuchData) { EXPECT_EQ(0, bytes_written); // When the data is read, we get an empty string back. - void* it = NULL; + PickleIterator it(pickle); std::string data_out; ASSERT_TRUE(CompressDataHelper::ReadAndDecompressStringFromPickle( pickle, &it, &data_out)); diff --git a/chrome/browser/sessions/session_service.cc b/chrome/browser/sessions/session_service.cc index 2ba33b5..dcd56f0 100644 --- a/chrome/browser/sessions/session_service.cc +++ b/chrome/browser/sessions/session_service.cc @@ -1304,8 +1304,8 @@ bool SessionService::ReplacePendingCommand(SessionCommand* command) { // well. if (command->id() != kCommandUpdateTabNavigation) return false; - void* iterator = NULL; scoped_ptr<Pickle> command_pickle(command->PayloadAsPickle()); + PickleIterator iterator(*command_pickle); SessionID::id_type command_tab_id; int command_nav_index; if (!command_pickle->ReadInt(&iterator, &command_tab_id) || @@ -1323,7 +1323,7 @@ bool SessionService::ReplacePendingCommand(SessionCommand* command) { // the command. Make sure we delete the pickle before the command, else // the pickle references deleted memory. scoped_ptr<Pickle> existing_pickle(existing_command->PayloadAsPickle()); - iterator = NULL; + iterator = PickleIterator(*existing_pickle); if (!existing_pickle->ReadInt(&iterator, &existing_tab_id) || !existing_pickle->ReadInt(&iterator, &existing_nav_index)) { return false; diff --git a/chrome/browser/ui/views/extensions/browser_action_drag_data.cc b/chrome/browser/ui/views/extensions/browser_action_drag_data.cc index 0a5413f..5af5222 100644 --- a/chrome/browser/ui/views/extensions/browser_action_drag_data.cc +++ b/chrome/browser/ui/views/extensions/browser_action_drag_data.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -71,7 +71,7 @@ void BrowserActionDragData::WriteToPickle( } bool BrowserActionDragData::ReadFromPickle(Pickle* pickle) { - void* data_iterator = NULL; + PickleIterator data_iterator(*pickle); const char* tmp; if (!pickle->ReadBytes(&data_iterator, &tmp, sizeof(profile_))) diff --git a/chrome/browser/visitedlink/visitedlink_unittest.cc b/chrome/browser/visitedlink/visitedlink_unittest.cc index f0b4f7f..39af08e 100644 --- a/chrome/browser/visitedlink/visitedlink_unittest.cc +++ b/chrome/browser/visitedlink/visitedlink_unittest.cc @@ -526,7 +526,7 @@ class VisitRelayingRenderProcessHost : public MockRenderProcessHost { Profile::FromBrowserContext(GetBrowserContext())); if (msg->type() == ChromeViewMsg_VisitedLink_Add::ID) { - void* iter = NULL; + PickleIterator iter(*msg); std::vector<uint64> fingerprints; CHECK(IPC::ReadParam(msg, &iter, &fingerprints)); counting_profile->CountAddEvent(fingerprints.size()); diff --git a/chrome/common/automation_messages.cc b/chrome/common/automation_messages.cc index 1801fd6..ef3dd47 100644 --- a/chrome/common/automation_messages.cc +++ b/chrome/common/automation_messages.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -73,7 +73,7 @@ void ParamTraits<ContextMenuModel>::Write(Message* m, // static bool ParamTraits<ContextMenuModel>::Read(const Message* m, - void** iter, + PickleIterator* iter, param_type* p) { size_t item_count = 0; if (!ReadParam(m, iter, &item_count)) diff --git a/chrome/common/automation_messages.h b/chrome/common/automation_messages.h index 3d5598e..3d4064f 100644 --- a/chrome/common/automation_messages.h +++ b/chrome/common/automation_messages.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -192,7 +192,7 @@ template <> struct ParamTraits<ContextMenuModel> { typedef ContextMenuModel param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* p); + static bool Read(const Message* m, PickleIterator* iter, param_type* p); static void Log(const param_type& p, std::string* l); }; diff --git a/chrome/common/common_param_traits.cc b/chrome/common/common_param_traits.cc index 8a14b30..e741e4f 100644 --- a/chrome/common/common_param_traits.cc +++ b/chrome/common/common_param_traits.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -13,7 +13,7 @@ void ParamTraits<ContentSetting>::Write(Message* m, const param_type& p) { m->WriteInt(static_cast<int>(p)); } -bool ParamTraits<ContentSetting>::Read(const Message* m, void** iter, +bool ParamTraits<ContentSetting>::Read(const Message* m, PickleIterator* iter, param_type* p) { int type; if (!m->ReadInt(iter, &type)) @@ -51,8 +51,9 @@ void ParamTraits<ContentSettingsType>::Write(Message* m, const param_type& p) { m->WriteInt(static_cast<int>(p)); } -bool ParamTraits<ContentSettingsType>::Read(const Message* m, void** iter, - param_type* p) { +bool ParamTraits<ContentSettingsType>::Read(const Message* m, + PickleIterator* iter, + param_type* p) { int type; if (!m->ReadInt(iter, &type)) return false; diff --git a/chrome/common/common_param_traits.h b/chrome/common/common_param_traits.h index 08a1853..1b9fa23 100644 --- a/chrome/common/common_param_traits.h +++ b/chrome/common/common_param_traits.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -11,6 +11,8 @@ #include "chrome/common/content_settings.h" #include "ipc/ipc_param_traits.h" +class PickleIterator; + namespace IPC { class Message; @@ -19,7 +21,7 @@ template <> struct ParamTraits<ContentSetting> { typedef ContentSetting param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* p); + static bool Read(const Message* m, PickleIterator* iter, param_type* p); static void Log(const param_type& p, std::string* l); }; @@ -27,7 +29,7 @@ template <> struct ParamTraits<ContentSettingsType> { typedef ContentSettingsType param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* p); + static bool Read(const Message* m, PickleIterator* iter, param_type* p); static void Log(const param_type& p, std::string* l); }; diff --git a/chrome/common/common_param_traits_unittest.cc b/chrome/common/common_param_traits_unittest.cc index 26f7eb6..c956fae 100644 --- a/chrome/common/common_param_traits_unittest.cc +++ b/chrome/common/common_param_traits_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -32,7 +32,7 @@ TEST(IPCMessageTest, Serialize) { IPC::ParamTraits<GURL>::Write(&msg, input); GURL output; - void* iter = NULL; + PickleIterator iter(msg); EXPECT_TRUE(IPC::ParamTraits<GURL>::Read(&msg, &iter, &output)); // We want to test each component individually to make sure its range was @@ -53,7 +53,7 @@ TEST(IPCMessageTest, Serialize) { IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); msg.WriteInt(99); GURL output; - void* iter = NULL; + PickleIterator iter(msg); EXPECT_FALSE(IPC::ParamTraits<GURL>::Read(&msg, &iter, &output)); } @@ -66,7 +66,7 @@ TEST(IPCMessageTest, Pair) { IPC::ParamTraits<TestPair>::Write(&msg, input); TestPair output; - void* iter = NULL; + PickleIterator iter(msg); EXPECT_TRUE(IPC::ParamTraits<TestPair>::Read(&msg, &iter, &output)); EXPECT_EQ(output.first, "foo"); EXPECT_EQ(output.second, "bar"); @@ -85,7 +85,7 @@ TEST(IPCMessageTest, Bitmap) { IPC::ParamTraits<SkBitmap>::Write(&msg, bitmap); SkBitmap output; - void* iter = NULL; + PickleIterator iter(msg); EXPECT_TRUE(IPC::ParamTraits<SkBitmap>::Read(&msg, &iter, &output)); EXPECT_EQ(bitmap.config(), output.config()); @@ -101,7 +101,7 @@ TEST(IPCMessageTest, Bitmap) { // Copy the first message block over to |bad_msg|. const char* fixed_data; int fixed_data_size; - iter = NULL; + iter = PickleIterator(msg); msg.ReadData(&iter, &fixed_data, &fixed_data_size); bad_msg.WriteData(fixed_data, fixed_data_size); // Add some bogus pixel data. @@ -111,7 +111,7 @@ TEST(IPCMessageTest, Bitmap) { bad_msg.WriteData(bogus_pixels.get(), bogus_pixels_size); // Make sure we don't read out the bitmap! SkBitmap bad_output; - iter = NULL; + iter = PickleIterator(bad_msg); EXPECT_FALSE(IPC::ParamTraits<SkBitmap>::Read(&bad_msg, &iter, &bad_output)); } @@ -125,7 +125,7 @@ TEST(IPCMessageTest, ListValue) { IPC::WriteParam(&msg, input); ListValue output; - void* iter = NULL; + PickleIterator iter(msg); EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output)); EXPECT_TRUE(input.Equals(&output)); @@ -133,7 +133,7 @@ TEST(IPCMessageTest, ListValue) { // Also test the corrupt case. IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL); bad_msg.WriteInt(99); - iter = NULL; + iter = PickleIterator(bad_msg); EXPECT_FALSE(IPC::ReadParam(&bad_msg, &iter, &output)); } @@ -159,7 +159,7 @@ TEST(IPCMessageTest, DictionaryValue) { IPC::WriteParam(&msg, input); DictionaryValue output; - void* iter = NULL; + PickleIterator iter(msg); EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output)); EXPECT_TRUE(input.Equals(&output)); @@ -167,7 +167,7 @@ TEST(IPCMessageTest, DictionaryValue) { // Also test the corrupt case. IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL); bad_msg.WriteInt(99); - iter = NULL; + iter = PickleIterator(bad_msg); EXPECT_FALSE(IPC::ReadParam(&bad_msg, &iter, &output)); } @@ -179,7 +179,7 @@ TEST(IPCMessageTest, HostPortPair) { IPC::ParamTraits<net::HostPortPair>::Write(&msg, input); net::HostPortPair output; - void* iter = NULL; + PickleIterator iter(msg); EXPECT_TRUE(IPC::ParamTraits<net::HostPortPair>::Read(&msg, &iter, &output)); EXPECT_EQ(input.host(), output.host()); EXPECT_EQ(input.port(), output.port()); diff --git a/chrome/common/content_settings_pattern.cc b/chrome/common/content_settings_pattern.cc index 1eb0697..8008cba 100644 --- a/chrome/common/content_settings_pattern.cc +++ b/chrome/common/content_settings_pattern.cc @@ -403,7 +403,7 @@ void ContentSettingsPattern::WriteToMessage(IPC::Message* m) const { } bool ContentSettingsPattern::ReadFromMessage(const IPC::Message* m, - void** iter) { + PickleIterator* iter) { return IPC::ReadParam(m, iter, &is_valid_) && IPC::ReadParam(m, iter, &parts_); } diff --git a/chrome/common/content_settings_pattern.h b/chrome/common/content_settings_pattern.h index d670b78..858d210 100644 --- a/chrome/common/content_settings_pattern.h +++ b/chrome/common/content_settings_pattern.h @@ -16,6 +16,8 @@ #include "base/gtest_prod_util.h" class GURL; +class Pickle; +class PickleIterator; namespace content_settings { class PatternParser; @@ -167,7 +169,7 @@ class ContentSettingsPattern { // Serializes the pattern to an IPC message or deserializes it. void WriteToMessage(IPC::Message* m) const; - bool ReadFromMessage(const IPC::Message* m, void** iter); + bool ReadFromMessage(const IPC::Message* m, PickleIterator* iter); // True if this is a valid pattern. bool IsValid() const { return is_valid_; } diff --git a/chrome/common/extensions/extension_messages.cc b/chrome/common/extensions/extension_messages.cc index fd1fa2b..bda807b 100644 --- a/chrome/common/extensions/extension_messages.cc +++ b/chrome/common/extensions/extension_messages.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -45,7 +45,7 @@ struct ParamTraits<Extension::Location> { int val = static_cast<int>(p); WriteParam(m, val); } - static bool Read(const Message* m, void** iter, param_type* p) { + static bool Read(const Message* m, PickleIterator* iter, param_type* p) { int val = 0; if (!ReadParam(m, iter, &val) || val < Extension::INVALID || @@ -64,7 +64,7 @@ void ParamTraits<URLPattern>::Write(Message* m, const param_type& p) { WriteParam(m, p.GetAsString()); } -bool ParamTraits<URLPattern>::Read(const Message* m, void** iter, +bool ParamTraits<URLPattern>::Read(const Message* m, PickleIterator* iter, param_type* p) { int valid_schemes; std::string spec; @@ -91,7 +91,7 @@ void ParamTraits<URLPatternSet>::Write(Message* m, const param_type& p) { WriteParam(m, p.patterns()); } -bool ParamTraits<URLPatternSet>::Read(const Message* m, void** iter, +bool ParamTraits<URLPatternSet>::Read(const Message* m, PickleIterator* iter, param_type* p) { std::set<URLPattern> patterns; if (!ReadParam(m, iter, &patterns)) @@ -113,7 +113,7 @@ void ParamTraits<ExtensionAPIPermission::ID>::Write( } bool ParamTraits<ExtensionAPIPermission::ID>::Read( - const Message* m, void** iter, param_type* p) { + const Message* m, PickleIterator* iter, param_type* p) { int api_id = -2; if (!ReadParam(m, iter, &api_id)) return false; @@ -136,7 +136,7 @@ void ParamTraits<ExtensionMsg_Loaded_Params>::Write(Message* m, } bool ParamTraits<ExtensionMsg_Loaded_Params>::Read(const Message* m, - void** iter, + PickleIterator* iter, param_type* p) { p->manifest.reset(new DictionaryValue()); return ReadParam(m, iter, &p->location) && diff --git a/chrome/common/extensions/extension_messages.h b/chrome/common/extensions/extension_messages.h index e45d677..276020e 100644 --- a/chrome/common/extensions/extension_messages.h +++ b/chrome/common/extensions/extension_messages.h @@ -128,7 +128,7 @@ template <> struct ParamTraits<URLPattern> { typedef URLPattern param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* p); + static bool Read(const Message* m, PickleIterator* iter, param_type* p); static void Log(const param_type& p, std::string* l); }; @@ -136,7 +136,7 @@ template <> struct ParamTraits<URLPatternSet> { typedef URLPatternSet param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* p); + static bool Read(const Message* m, PickleIterator* iter, param_type* p); static void Log(const param_type& p, std::string* l); }; @@ -144,7 +144,7 @@ template <> struct ParamTraits<ExtensionAPIPermission::ID> { typedef ExtensionAPIPermission::ID param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* p); + static bool Read(const Message* m, PickleIterator* iter, param_type* p); static void Log(const param_type& p, std::string* l); }; @@ -152,7 +152,7 @@ template <> struct ParamTraits<ExtensionMsg_Loaded_Params> { typedef ExtensionMsg_Loaded_Params param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* p); + static bool Read(const Message* m, PickleIterator* iter, param_type* p); static void Log(const param_type& p, std::string* l); }; diff --git a/chrome/common/extensions/extension_unpacker.cc b/chrome/common/extensions/extension_unpacker.cc index aded697..a5a1916 100644 --- a/chrome/common/extensions/extension_unpacker.cc +++ b/chrome/common/extensions/extension_unpacker.cc @@ -252,7 +252,7 @@ bool ExtensionUnpacker::ReadImagesFromFile(const FilePath& extension_path, return false; IPC::Message pickle(file_str.data(), file_str.size()); - void* iter = NULL; + PickleIterator iter(pickle); return IPC::ReadParam(&pickle, &iter, images); } @@ -266,7 +266,7 @@ bool ExtensionUnpacker::ReadMessageCatalogsFromFile( return false; IPC::Message pickle(file_str.data(), file_str.size()); - void* iter = NULL; + PickleIterator iter(pickle); return IPC::ReadParam(&pickle, &iter, catalogs); } diff --git a/chrome/common/extensions/user_script.cc b/chrome/common/extensions/user_script.cc index d60b421..8fffaa4 100644 --- a/chrome/common/extensions/user_script.cc +++ b/chrome/common/extensions/user_script.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -89,7 +89,7 @@ void UserScript::File::Pickle(::Pickle* pickle) const { // Do not write content. It will be serialized by other means. } -void UserScript::File::Unpickle(const ::Pickle& pickle, void** iter) { +void UserScript::File::Unpickle(const ::Pickle& pickle, PickleIterator* iter) { // Read the url from the pickle. std::string url; CHECK(pickle.ReadString(iter, &url)); @@ -140,7 +140,7 @@ void UserScript::PickleScripts(::Pickle* pickle, } } -void UserScript::Unpickle(const ::Pickle& pickle, void** iter) { +void UserScript::Unpickle(const ::Pickle& pickle, PickleIterator* iter) { // Read the run location. int run_location = 0; CHECK(pickle.ReadInt(iter, &run_location)); @@ -160,7 +160,7 @@ void UserScript::Unpickle(const ::Pickle& pickle, void** iter) { UnpickleScripts(pickle, iter, &css_scripts_); } -void UserScript::UnpickleGlobs(const ::Pickle& pickle, void** iter, +void UserScript::UnpickleGlobs(const ::Pickle& pickle, PickleIterator* iter, std::vector<std::string>* globs) { size_t num_globs = 0; CHECK(pickle.ReadSize(iter, &num_globs)); @@ -172,7 +172,8 @@ void UserScript::UnpickleGlobs(const ::Pickle& pickle, void** iter, } } -void UserScript::UnpickleURLPatternSet(const ::Pickle& pickle, void** iter, +void UserScript::UnpickleURLPatternSet(const ::Pickle& pickle, + PickleIterator* iter, URLPatternSet* pattern_list) { size_t num_patterns = 0; CHECK(pickle.ReadSize(iter, &num_patterns)); @@ -199,7 +200,7 @@ void UserScript::UnpickleURLPatternSet(const ::Pickle& pickle, void** iter, } } -void UserScript::UnpickleScripts(const ::Pickle& pickle, void** iter, +void UserScript::UnpickleScripts(const ::Pickle& pickle, PickleIterator* iter, FileList* scripts) { size_t num_files = 0; CHECK(pickle.ReadSize(iter, &num_files)); diff --git a/chrome/common/extensions/user_script.h b/chrome/common/extensions/user_script.h index 53147fc..47b0287 100644 --- a/chrome/common/extensions/user_script.h +++ b/chrome/common/extensions/user_script.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -16,6 +16,7 @@ #include "chrome/common/extensions/url_pattern_set.h" class Pickle; +class PickleIterator; // Represents a user script, either a standalone one, or one that is part of an // extension. @@ -82,7 +83,7 @@ class UserScript { // Serialization support. The content and FilePath members will not be // serialized! void Pickle(::Pickle* pickle) const; - void Unpickle(const ::Pickle& pickle, void** iter); + void Unpickle(const ::Pickle& pickle, PickleIterator* iter); private: // Where the script file lives on the disk. We keep the path split so that @@ -187,7 +188,7 @@ class UserScript { // Deserialize the script from a pickle. Note that this always succeeds // because presumably we were the one that pickled it, and we did it // correctly. - void Unpickle(const ::Pickle& pickle, void** iter); + void Unpickle(const ::Pickle& pickle, PickleIterator* iter); private: // Pickle helper functions used to pickle the individual types of components. @@ -198,11 +199,11 @@ class UserScript { void PickleScripts(::Pickle* pickle, const FileList& scripts) const; // Unpickle helper functions used to unpickle individual types of components. - void UnpickleGlobs(const ::Pickle& pickle, void** iter, + void UnpickleGlobs(const ::Pickle& pickle, PickleIterator* iter, std::vector<std::string>* globs); - void UnpickleURLPatternSet(const ::Pickle& pickle, void** iter, + void UnpickleURLPatternSet(const ::Pickle& pickle, PickleIterator* iter, URLPatternSet* pattern_list); - void UnpickleScripts(const ::Pickle& pickle, void** iter, + void UnpickleScripts(const ::Pickle& pickle, PickleIterator* iter, FileList* scripts); // The location to run the script inside the document. diff --git a/chrome/common/extensions/user_script_unittest.cc b/chrome/common/extensions/user_script_unittest.cc index 1afe6ab..51e9b31 100644 --- a/chrome/common/extensions/user_script_unittest.cc +++ b/chrome/common/extensions/user_script_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -189,7 +189,7 @@ TEST(ExtensionUserScriptTest, Pickle) { Pickle pickle; script1.Pickle(&pickle); - void* iter = NULL; + PickleIterator iter(pickle); UserScript script2; script2.Unpickle(pickle, &iter); diff --git a/chrome/common/render_messages.cc b/chrome/common/render_messages.cc index 726f082..ce17fa3 100644 --- a/chrome/common/render_messages.cc +++ b/chrome/common/render_messages.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -12,7 +12,7 @@ void ParamTraits<ContentSettingsPattern>::Write( } bool ParamTraits<ContentSettingsPattern>::Read( - const Message* m, void** iter, ContentSettingsPattern* pattern) { + const Message* m, PickleIterator* iter, ContentSettingsPattern* pattern) { return pattern->ReadFromMessage(m, iter); } diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index d6186b7..44933a6 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -85,7 +85,7 @@ struct ParamTraits<gfx::NativeView> { NOTIMPLEMENTED(); } - static bool Read(const Message* m, void** iter, param_type* p) { + static bool Read(const Message* m, PickleIterator* iter, param_type* p) { NOTIMPLEMENTED(); *p = NULL; return true; @@ -102,7 +102,7 @@ template <> struct ParamTraits<ContentSettingsPattern> { typedef ContentSettingsPattern param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; diff --git a/chrome/renderer/extensions/user_script_slave.cc b/chrome/renderer/extensions/user_script_slave.cc index c064197..6aa7171 100644 --- a/chrome/renderer/extensions/user_script_slave.cc +++ b/chrome/renderer/extensions/user_script_slave.cc @@ -155,10 +155,10 @@ bool UserScriptSlave::UpdateScripts(base::SharedMemoryHandle shared_memory) { return false; // Unpickle scripts. - void* iter = NULL; size_t num_scripts = 0; Pickle pickle(reinterpret_cast<char*>(shared_memory_->memory()), pickle_size); + PickleIterator iter(pickle); pickle.ReadSize(&iter, &num_scripts); scripts_.reserve(num_scripts); diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc index fdfc5eb..3cdad28 100644 --- a/chrome/test/automation/automation_proxy.cc +++ b/chrome/test/automation/automation_proxy.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -79,7 +79,7 @@ class AutomationMessageFilter : public IPC::ChannelProxy::MessageFilter { void OnAutomationHello(const IPC::Message& hello_message) { std::string server_version; - void* iter = NULL; + PickleIterator iter(hello_message); if (!hello_message.ReadString(&iter, &server_version)) { // We got an AutomationMsg_Hello from an old automation provider // that doesn't send version info. Leave server_version as an empty @@ -462,7 +462,7 @@ bool AutomationProxy::Send(IPC::Message* message, int timeout_ms) { } void AutomationProxy::InvalidateHandle(const IPC::Message& message) { - void* iter = NULL; + PickleIterator iter(message); int handle; if (message.ReadInt(&iter, &handle)) { diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc index a1768f4..403836b 100644 --- a/chrome/test/automation/automation_proxy_uitest.cc +++ b/chrome/test/automation/automation_proxy_uitest.cc @@ -757,7 +757,7 @@ void ExternalTabUITestMockClient::IgnoreFaviconNetworkRequest() { void ExternalTabUITestMockClient::InvalidateHandle( const IPC::Message& message) { - void* iter = NULL; + PickleIterator iter(message); int handle; ASSERT_TRUE(message.ReadInt(&iter, &handle)); diff --git a/chrome_frame/cfproxy_support.cc b/chrome_frame/cfproxy_support.cc index 903397d..0e5e966 100644 --- a/chrome_frame/cfproxy_support.cc +++ b/chrome_frame/cfproxy_support.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -32,7 +32,7 @@ void DispatchReplyFail(uint32 type, bool DispatchReplyOk(const IPC::Message* reply_msg, uint32 type, ChromeProxyDelegate* delegate, SyncMessageContext* ctx, TabsMap* tab2delegate) { - void* iter = IPC::SyncMessage::GetDataIterator(reply_msg); + PickleIterator iter = IPC::SyncMessage::GetDataIterator(reply_msg); switch (type) { case AutomationMsg_CreateExternalTab::ID: { // Tuple4<HWND, HWND, int, int> out; diff --git a/content/browser/download/base_file.cc b/content/browser/download/base_file.cc index f7d045d2..4564548 100644 --- a/content/browser/download/base_file.cc +++ b/content/browser/download/base_file.cc @@ -455,9 +455,9 @@ bool BaseFile::SetHashState(const std::string& hash_state_bytes) { return false; Pickle hash_state(hash_state_bytes.c_str(), hash_state_bytes.size()); - void* data_iterator = NULL; + PickleIterator data_iterator(hash_state); - return secure_hash_->Deserialize(&data_iterator, &hash_state); + return secure_hash_->Deserialize(&data_iterator); } bool BaseFile::IsEmptyHash(const std::string& hash) { diff --git a/content/browser/renderer_host/render_sandbox_host_linux.cc b/content/browser/renderer_host/render_sandbox_host_linux.cc index 9fb2ad3..ea40db2 100644 --- a/content/browser/renderer_host/render_sandbox_host_linux.cc +++ b/content/browser/renderer_host/render_sandbox_host_linux.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -124,7 +124,7 @@ class SandboxIPCProcess { return; Pickle pickle(buf, len); - void* iter = NULL; + PickleIterator iter(pickle); int kind; if (!pickle.ReadInt(&iter, &kind)) @@ -155,7 +155,7 @@ class SandboxIPCProcess { } } - void HandleFontMatchRequest(int fd, const Pickle& pickle, void* iter, + void HandleFontMatchRequest(int fd, const Pickle& pickle, PickleIterator iter, std::vector<int>& fds) { bool filefaceid_valid; uint32_t filefaceid; @@ -207,7 +207,7 @@ class SandboxIPCProcess { SendRendererReply(fds, reply, -1); } - void HandleFontOpenRequest(int fd, const Pickle& pickle, void* iter, + void HandleFontOpenRequest(int fd, const Pickle& pickle, PickleIterator iter, std::vector<int>& fds) { uint32_t filefaceid; if (!pickle.ReadUInt32(&iter, &filefaceid)) @@ -227,7 +227,8 @@ class SandboxIPCProcess { close(result_fd); } - void HandleGetFontFamilyForChars(int fd, const Pickle& pickle, void* iter, + void HandleGetFontFamilyForChars(int fd, const Pickle& pickle, + PickleIterator iter, std::vector<int>& fds) { // The other side of this call is // chrome/renderer/renderer_sandbox_support_linux.cc @@ -278,7 +279,8 @@ class SandboxIPCProcess { SendRendererReply(fds, reply, -1); } - void HandleGetStyleForStrike(int fd, const Pickle& pickle, void* iter, + void HandleGetStyleForStrike(int fd, const Pickle& pickle, + PickleIterator iter, std::vector<int>& fds) { std::string family; int sizeAndStyle; @@ -303,7 +305,7 @@ class SandboxIPCProcess { SendRendererReply(fds, reply, -1); } - void HandleLocaltime(int fd, const Pickle& pickle, void* iter, + void HandleLocaltime(int fd, const Pickle& pickle, PickleIterator iter, std::vector<int>& fds) { // The other side of this call is in zygote_main_linux.cc @@ -333,7 +335,8 @@ class SandboxIPCProcess { SendRendererReply(fds, reply, -1); } - void HandleGetChildWithInode(int fd, const Pickle& pickle, void* iter, + void HandleGetChildWithInode(int fd, const Pickle& pickle, + PickleIterator iter, std::vector<int>& fds) { // The other side of this call is in zygote_main_linux.cc if (sandbox_cmd_.empty()) { @@ -365,7 +368,8 @@ class SandboxIPCProcess { SendRendererReply(fds, reply, -1); } - void HandleMakeSharedMemorySegment(int fd, const Pickle& pickle, void* iter, + void HandleMakeSharedMemorySegment(int fd, const Pickle& pickle, + PickleIterator iter, std::vector<int>& fds) { base::SharedMemoryCreateOptions options; if (!pickle.ReadUInt32(&iter, &options.size)) @@ -380,7 +384,8 @@ class SandboxIPCProcess { SendRendererReply(fds, reply, shm_fd); } - void HandleMatchWithFallback(int fd, const Pickle& pickle, void* iter, + void HandleMatchWithFallback(int fd, const Pickle& pickle, + PickleIterator iter, std::vector<int>& fds) { // Unlike the other calls, for which we are an indirection in front of // WebKit or Skia, this call is always made via this sandbox helper diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc index 5f88047..d47bc65 100644 --- a/content/browser/renderer_host/render_view_host_impl.cc +++ b/content/browser/renderer_host/render_view_host_impl.cc @@ -962,7 +962,7 @@ void RenderViewHostImpl::OnMsgRenderViewGone(int status, int exit_code) { void RenderViewHostImpl::OnMsgNavigate(const IPC::Message& msg) { // Read the parameters out of the IPC message directly to avoid making another // copy when we filter the URLs. - void* iter = NULL; + PickleIterator iter(msg); ViewHostMsg_FrameNavigate_Params validated_params; if (!IPC::ParamTraits<ViewHostMsg_FrameNavigate_Params>:: Read(&msg, &iter, &validated_params)) diff --git a/content/browser/renderer_host/resource_dispatcher_host_unittest.cc b/content/browser/renderer_host/resource_dispatcher_host_unittest.cc index 33723d2..65b2f3c 100644 --- a/content/browser/renderer_host/resource_dispatcher_host_unittest.cc +++ b/content/browser/renderer_host/resource_dispatcher_host_unittest.cc @@ -55,7 +55,7 @@ void GetResponseHead(const std::vector<IPC::Message>& messages, // The first messages should be received response. ASSERT_EQ(ResourceMsg_ReceivedResponse::ID, messages[0].type()); - void* iter = NULL; + PickleIterator iter(messages[0]); int request_id; ASSERT_TRUE(IPC::ReadParam(&messages[0], &iter, &request_id)); ASSERT_TRUE(IPC::ReadParam(&messages[0], &iter, response_head)); @@ -539,7 +539,7 @@ void CheckSuccessfulRequest(const std::vector<IPC::Message>& messages, // should probably test multiple chunks later ASSERT_EQ(ResourceMsg_DataReceived::ID, messages[1].type()); - void* iter = NULL; + PickleIterator iter(messages[1]); int request_id; ASSERT_TRUE(IPC::ReadParam(&messages[1], &iter, &request_id)); base::SharedMemoryHandle shm_handle; @@ -618,7 +618,7 @@ TEST_F(ResourceDispatcherHostTest, Cancel) { int request_id; net::URLRequestStatus status; - void* iter = NULL; + PickleIterator iter(msgs[1][1]); ASSERT_TRUE(IPC::ReadParam(&msgs[1][1], &iter, &request_id)); ASSERT_TRUE(IPC::ReadParam(&msgs[1][1], &iter, &status)); @@ -695,7 +695,7 @@ TEST_F(ResourceDispatcherHostTest, PausedCancel) { int request_id; net::URLRequestStatus status; - void* iter = NULL; + PickleIterator iter(msgs[0][1]); ASSERT_TRUE(IPC::ReadParam(&msgs[0][1], &iter, &request_id)); ASSERT_TRUE(IPC::ReadParam(&msgs[0][1], &iter, &status)); @@ -1069,7 +1069,7 @@ TEST_F(ResourceDispatcherHostTest, TooManyOutstandingRequests) { int request_id; net::URLRequestStatus status; - void* iter = NULL; + PickleIterator iter(msgs[index][0]); EXPECT_TRUE(IPC::ReadParam(&msgs[index][0], &iter, &request_id)); EXPECT_TRUE(IPC::ReadParam(&msgs[index][0], &iter, &status)); @@ -1233,7 +1233,7 @@ TEST_F(ResourceDispatcherHostTest, ForbiddenDownload) { int request_id; net::URLRequestStatus status; - void* iter = NULL; + PickleIterator iter(msgs[0][0]); EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &request_id)); EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &status)); @@ -1387,7 +1387,7 @@ TEST_F(ResourceDispatcherHostTest, UnknownURLScheme) { int request_id; net::URLRequestStatus status; - void* iter = NULL; + PickleIterator iter(msgs[0][0]); EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &request_id)); EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &status)); diff --git a/content/browser/zygote_host_impl_linux.cc b/content/browser/zygote_host_impl_linux.cc index 7a1818d..7be97ed 100644 --- a/content/browser/zygote_host_impl_linux.cc +++ b/content/browser/zygote_host_impl_linux.cc @@ -278,7 +278,7 @@ pid_t ZygoteHostImpl::ForkRequest( const ssize_t len = ReadReply(buf, sizeof(buf)); Pickle reply_pickle(buf, len); - void* iter = NULL; + PickleIterator iter(reply_pickle); if (len <= 0 || !reply_pickle.ReadInt(&iter, &pid)) return base::kNullProcessHandle; @@ -437,7 +437,7 @@ base::TerminationStatus ZygoteHostImpl::GetTerminationStatus( Pickle read_pickle(buf, len); int status, tmp_exit_code; - void* iter = NULL; + PickleIterator iter(read_pickle); if (!read_pickle.ReadInt(&iter, &status) || !read_pickle.ReadInt(&iter, &tmp_exit_code)) { LOG(WARNING) << "Error parsing GetTerminationStatus response from zygote."; diff --git a/content/browser/zygote_main_linux.cc b/content/browser/zygote_main_linux.cc index c073cc7..e1dbf1c 100644 --- a/content/browser/zygote_main_linux.cc +++ b/content/browser/zygote_main_linux.cc @@ -169,7 +169,7 @@ class Zygote { } Pickle pickle(buf, len); - void* iter = NULL; + PickleIterator iter(pickle); int kind; if (pickle.ReadInt(&iter, &kind)) { @@ -204,7 +204,7 @@ class Zygote { return false; } - void HandleReapRequest(int fd, const Pickle& pickle, void* iter) { + void HandleReapRequest(int fd, const Pickle& pickle, PickleIterator iter) { base::ProcessId child; base::ProcessId actual_child; @@ -225,7 +225,9 @@ class Zygote { base::EnsureProcessTerminated(actual_child); } - void HandleGetTerminationStatus(int fd, const Pickle& pickle, void* iter) { + void HandleGetTerminationStatus(int fd, + const Pickle& pickle, + PickleIterator iter) { base::ProcessHandle child; if (!pickle.ReadInt(&iter, &child)) { @@ -347,7 +349,7 @@ class Zygote { } Pickle reply(reinterpret_cast<char*>(reply_buf), r); - void* iter = NULL; + PickleIterator iter(reply); if (!reply.ReadInt(&iter, &real_pid)) goto error; if (real_pid <= 0) { @@ -393,7 +395,7 @@ class Zygote { // Returns -1 on error, otherwise returns twice, returning 0 to the child // process and the child process ID to the parent process, like fork(). base::ProcessId ReadArgsAndFork(const Pickle& pickle, - void* iter, + PickleIterator iter, std::vector<int>& fds, std::string* uma_name, int* uma_sample, @@ -486,7 +488,7 @@ class Zygote { // otherwise writes the child_pid back to the browser via |fd|. Writes a // child_pid of -1 on error. bool HandleForkRequest(int fd, const Pickle& pickle, - void* iter, std::vector<int>& fds) { + PickleIterator iter, std::vector<int>& fds) { std::string uma_name; int uma_sample; int uma_boundary_value; @@ -521,7 +523,9 @@ class Zygote { return false; } - bool HandleGetSandboxStatus(int fd, const Pickle& pickle, void* iter) { + bool HandleGetSandboxStatus(int fd, + const Pickle& pickle, + PickleIterator iter) { if (HANDLE_EINTR(write(fd, &sandbox_flags_, sizeof(sandbox_flags_)) != sizeof(sandbox_flags_))) { PLOG(ERROR) << "write"; @@ -567,7 +571,7 @@ static void ProxyLocaltimeCallToBrowser(time_t input, struct tm* output, } Pickle reply(reinterpret_cast<char*>(reply_buf), r); - void* iter = NULL; + PickleIterator iter(reply); std::string result, timezone; if (!reply.ReadString(&iter, &result) || !reply.ReadString(&iter, &timezone) || diff --git a/content/common/child_process_sandbox_support_impl_linux.cc b/content/common/child_process_sandbox_support_impl_linux.cc index 9040cd0..bd9a7f2 100644 --- a/content/common/child_process_sandbox_support_impl_linux.cc +++ b/content/common/child_process_sandbox_support_impl_linux.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -36,7 +36,7 @@ void GetFontFamilyForCharacters(const uint16_t* utf16, bool isItalic = false; if (n != -1) { Pickle reply(reinterpret_cast<char*>(buf), n); - void* pickle_iter = NULL; + PickleIterator pickle_iter(reply); if (reply.ReadString(&pickle_iter, &family_name) && reply.ReadBool(&pickle_iter, &isBold) && reply.ReadBool(&pickle_iter, &isItalic)) { @@ -64,7 +64,7 @@ void GetRenderStyleForStrike(const char* family, int sizeAndStyle, } Pickle reply(reinterpret_cast<char*>(buf), n); - void* pickle_iter = NULL; + PickleIterator pickle_iter(reply); int useBitmaps, useAutoHint, useHinting, hintStyle, useAntiAlias, useSubpixel; if (reply.ReadInt(&pickle_iter, &useBitmaps) && reply.ReadInt(&pickle_iter, &useAutoHint) && diff --git a/content/common/clipboard_messages.cc b/content/common/clipboard_messages.cc index 866a1c1..cae2f46 100644 --- a/content/common/clipboard_messages.cc +++ b/content/common/clipboard_messages.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -14,7 +14,7 @@ void ParamTraits<ui::Clipboard::FormatType>::Write( } bool ParamTraits<ui::Clipboard::FormatType>::Read( - const Message* m, void** iter, param_type* r) { + const Message* m, PickleIterator* iter, param_type* r) { std::string serialization; if (!ReadParam(m, iter, &serialization)) return false; diff --git a/content/common/clipboard_messages.h b/content/common/clipboard_messages.h index 91d1ad6..6a4cf6c5 100644 --- a/content/common/clipboard_messages.h +++ b/content/common/clipboard_messages.h @@ -24,7 +24,7 @@ template<> struct ParamTraits<ui::Clipboard::FormatType> { typedef ui::Clipboard::FormatType param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; diff --git a/content/common/font_config_ipc_linux.cc b/content/common/font_config_ipc_linux.cc index c7c6073..13ea2296 100644 --- a/content/common/font_config_ipc_linux.cc +++ b/content/common/font_config_ipc_linux.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -53,7 +53,7 @@ bool FontConfigIPC::Match(std::string* result_family, return false; Pickle reply(reinterpret_cast<char*>(reply_buf), r); - void* iter = NULL; + PickleIterator iter(reply); bool result; if (!reply.ReadBool(&iter, &result)) return false; @@ -98,7 +98,7 @@ int FontConfigIPC::Open(unsigned filefaceid) { Pickle reply(reinterpret_cast<char*>(reply_buf), r); bool result; - void* iter = NULL; + PickleIterator iter(reply); if (!reply.ReadBool(&iter, &result) || !result) { if (result_fd) diff --git a/content/common/indexed_db/indexed_db_param_traits.cc b/content/common/indexed_db/indexed_db_param_traits.cc index c580cd1..57fca9a 100644 --- a/content/common/indexed_db/indexed_db_param_traits.cc +++ b/content/common/indexed_db/indexed_db_param_traits.cc @@ -19,7 +19,7 @@ void ParamTraits<content::SerializedScriptValue>::Write(Message* m, } bool ParamTraits<content::SerializedScriptValue>::Read(const Message* m, - void** iter, + PickleIterator* iter, param_type* r) { bool is_null; bool is_invalid; @@ -70,7 +70,7 @@ void ParamTraits<IndexedDBKey>::Write(Message* m, const param_type& p) { } bool ParamTraits<IndexedDBKey>::Read(const Message* m, - void** iter, + PickleIterator* iter, param_type* r) { int type; if (!ReadParam(m, iter, &type)) @@ -149,7 +149,7 @@ void ParamTraits<IndexedDBKeyRange>::Write(Message* m, const param_type& p) { } bool ParamTraits<IndexedDBKeyRange>::Read(const Message* m, - void** iter, + PickleIterator* iter, param_type* r) { IndexedDBKey lower; diff --git a/content/common/indexed_db/indexed_db_param_traits.h b/content/common/indexed_db/indexed_db_param_traits.h index 930ed0b..3dfd5b8 100644 --- a/content/common/indexed_db/indexed_db_param_traits.h +++ b/content/common/indexed_db/indexed_db_param_traits.h @@ -27,7 +27,7 @@ template <> struct ParamTraits<content::SerializedScriptValue> { typedef content::SerializedScriptValue param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -35,7 +35,7 @@ template <> struct ParamTraits<IndexedDBKey> { typedef IndexedDBKey param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -43,7 +43,7 @@ template <> struct ParamTraits<IndexedDBKeyRange> { typedef IndexedDBKeyRange param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; diff --git a/content/common/mac/attributed_string_coder.h b/content/common/mac/attributed_string_coder.h index 054cb45..0da8a9b 100644 --- a/content/common/mac/attributed_string_coder.h +++ b/content/common/mac/attributed_string_coder.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -102,7 +102,7 @@ template <> struct ParamTraits<mac::AttributedStringCoder::EncodedString> { typedef mac::AttributedStringCoder::EncodedString param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -110,7 +110,7 @@ template <> struct ParamTraits<mac::AttributedStringCoder::FontAttribute> { typedef mac::AttributedStringCoder::FontAttribute param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; diff --git a/content/common/mac/attributed_string_coder.mm b/content/common/mac/attributed_string_coder.mm index 706368d..78a1efb 100644 --- a/content/common/mac/attributed_string_coder.mm +++ b/content/common/mac/attributed_string_coder.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -126,7 +126,7 @@ void ParamTraits<AttributedStringCoder::EncodedString>::Write( } bool ParamTraits<AttributedStringCoder::EncodedString>::Read( - const Message* m, void** iter, param_type* p) { + const Message* m, PickleIterator* iter, param_type* p) { bool success = true; string16 result; @@ -149,7 +149,7 @@ void ParamTraits<AttributedStringCoder::FontAttribute>::Write( } bool ParamTraits<AttributedStringCoder::FontAttribute>::Read( - const Message* m, void** iter, param_type* p) { + const Message* m, PickleIterator* iter, param_type* p) { bool success = true; FontDescriptor font; diff --git a/content/common/pepper_file_messages.cc b/content/common/pepper_file_messages.cc index 7986c62..313c2b7 100644 --- a/content/common/pepper_file_messages.cc +++ b/content/common/pepper_file_messages.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -13,7 +13,7 @@ void ParamTraits<webkit::ppapi::PepperFilePath>::Write(Message* m, } bool ParamTraits<webkit::ppapi::PepperFilePath>::Read(const Message* m, - void** iter, + PickleIterator* iter, param_type* p) { unsigned domain; FilePath path; diff --git a/content/common/pepper_file_messages.h b/content/common/pepper_file_messages.h index 941824d..d202d53 100644 --- a/content/common/pepper_file_messages.h +++ b/content/common/pepper_file_messages.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -20,7 +20,7 @@ template <> struct ParamTraits<webkit::ppapi::PepperFilePath> { typedef webkit::ppapi::PepperFilePath param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* p); + static bool Read(const Message* m, PickleIterator* iter, param_type* p); static void Log(const param_type& p, std::string* l); }; diff --git a/content/common/resource_dispatcher.cc b/content/common/resource_dispatcher.cc index e824c6f..69937ef 100644 --- a/content/common/resource_dispatcher.cc +++ b/content/common/resource_dispatcher.cc @@ -293,7 +293,7 @@ bool ResourceDispatcher::OnMessageReceived(const IPC::Message& message) { int request_id; - void* iter = NULL; + PickleIterator iter(message); if (!message.ReadInt(&iter, &request_id)) { NOTREACHED() << "malformed resource message"; return true; @@ -677,7 +677,7 @@ bool ResourceDispatcher::IsResourceDispatcherMessage( // static void ResourceDispatcher::ReleaseResourcesInDataMessage( const IPC::Message& message) { - void* iter = NULL; + PickleIterator iter(message); int request_id; if (!message.ReadInt(&iter, &request_id)) { NOTREACHED() << "malformed resource message"; diff --git a/content/common/ssl_status_serialization.cc b/content/common/ssl_status_serialization.cc index fdd6406..87593a5 100644 --- a/content/common/ssl_status_serialization.cc +++ b/content/common/ssl_status_serialization.cc @@ -38,7 +38,7 @@ bool DeserializeSecurityInfo(const std::string& state, } Pickle pickle(state.data(), static_cast<int>(state.size())); - void * iter = NULL; + PickleIterator iter(pickle); return pickle.ReadInt(&iter, cert_id) && pickle.ReadUInt32(&iter, cert_status) && pickle.ReadInt(&iter, security_bits) && diff --git a/content/ppapi_plugin/ppapi_thread.cc b/content/ppapi_plugin/ppapi_thread.cc index 8ef6d6b..6450cf8 100644 --- a/content/ppapi_plugin/ppapi_thread.cc +++ b/content/ppapi_plugin/ppapi_thread.cc @@ -256,7 +256,7 @@ void PpapiThread::OnMsgSetNetworkState(bool online) { void PpapiThread::OnPluginDispatcherMessageReceived(const IPC::Message& msg) { // The first parameter should be a plugin dispatcher ID. - void* iter = NULL; + PickleIterator iter(msg); uint32 id = 0; if (!msg.ReadUInt32(&iter, &id)) { NOTREACHED(); diff --git a/content/public/common/common_param_traits.cc b/content/public/common/common_param_traits.cc index 22bb7a9..0477833 100644 --- a/content/public/common/common_param_traits.cc +++ b/content/public/common/common_param_traits.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -55,7 +55,7 @@ void ParamTraits<GURL>::Write(Message* m, const GURL& p) { // TODO(brettw) bug 684583: Add encoding for query params. } -bool ParamTraits<GURL>::Read(const Message* m, void** iter, GURL* p) { +bool ParamTraits<GURL>::Read(const Message* m, PickleIterator* iter, GURL* p) { std::string s; if (!m->ReadString(iter, &s) || s.length() > content::kMaxURLChars) { *p = GURL(); @@ -74,7 +74,7 @@ void ParamTraits<ResourceType::Type>::Write(Message* m, const param_type& p) { } bool ParamTraits<ResourceType::Type>::Read(const Message* m, - void** iter, + PickleIterator* iter, param_type* p) { int type; if (!m->ReadInt(iter, &type) || !ResourceType::ValidType(type)) @@ -145,7 +145,8 @@ void ParamTraits<net::URLRequestStatus>::Write(Message* m, WriteParam(m, p.error()); } -bool ParamTraits<net::URLRequestStatus>::Read(const Message* m, void** iter, +bool ParamTraits<net::URLRequestStatus>::Read(const Message* m, + PickleIterator* iter, param_type* r) { int status, error; if (!ReadParam(m, iter, &status) || !ReadParam(m, iter, &error)) @@ -237,7 +238,7 @@ struct ParamTraits<net::UploadData::Element> { } } } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { int type; if (!ReadParam(m, iter, &type)) return false; @@ -308,7 +309,7 @@ void ParamTraits<scoped_refptr<net::UploadData> >::Write(Message* m, } bool ParamTraits<scoped_refptr<net::UploadData> >::Read(const Message* m, - void** iter, + PickleIterator* iter, param_type* r) { bool has_object; if (!ReadParam(m, iter, &has_object)) @@ -341,7 +342,8 @@ void ParamTraits<net::HostPortPair>::Write(Message* m, const param_type& p) { WriteParam(m, p.port()); } -bool ParamTraits<net::HostPortPair>::Read(const Message* m, void** iter, +bool ParamTraits<net::HostPortPair>::Read(const Message* m, + PickleIterator* iter, param_type* r) { std::string host; uint16 port; @@ -367,7 +369,7 @@ void ParamTraits<scoped_refptr<net::HttpResponseHeaders> >::Write( } bool ParamTraits<scoped_refptr<net::HttpResponseHeaders> >::Read( - const Message* m, void** iter, param_type* r) { + const Message* m, PickleIterator* iter, param_type* r) { bool has_object; if (!ReadParam(m, iter, &has_object)) return false; @@ -386,7 +388,7 @@ void ParamTraits<net::IPEndPoint>::Write(Message* m, const param_type& p) { WriteParam(m, p.port()); } -bool ParamTraits<net::IPEndPoint>::Read(const Message* m, void** iter, +bool ParamTraits<net::IPEndPoint>::Read(const Message* m, PickleIterator* iter, param_type* p) { net::IPAddressNumber address; int port; @@ -410,7 +412,7 @@ void ParamTraits<base::PlatformFileInfo>::Write( } bool ParamTraits<base::PlatformFileInfo>::Read( - const Message* m, void** iter, param_type* p) { + const Message* m, PickleIterator* iter, param_type* p) { double last_modified; double last_accessed; double creation_time; @@ -448,7 +450,7 @@ void ParamTraits<gfx::Point>::Write(Message* m, const gfx::Point& p) { m->WriteInt(p.y()); } -bool ParamTraits<gfx::Point>::Read(const Message* m, void** iter, +bool ParamTraits<gfx::Point>::Read(const Message* m, PickleIterator* iter, gfx::Point* r) { int x, y; if (!m->ReadInt(iter, &x) || @@ -468,7 +470,9 @@ void ParamTraits<gfx::Size>::Write(Message* m, const gfx::Size& p) { m->WriteInt(p.height()); } -bool ParamTraits<gfx::Size>::Read(const Message* m, void** iter, gfx::Size* r) { +bool ParamTraits<gfx::Size>::Read(const Message* m, + PickleIterator* iter, + gfx::Size* r) { int w, h; if (!m->ReadInt(iter, &w) || !m->ReadInt(iter, &h)) @@ -489,7 +493,9 @@ void ParamTraits<gfx::Rect>::Write(Message* m, const gfx::Rect& p) { m->WriteInt(p.height()); } -bool ParamTraits<gfx::Rect>::Read(const Message* m, void** iter, gfx::Rect* r) { +bool ParamTraits<gfx::Rect>::Read(const Message* m, + PickleIterator* iter, + gfx::Rect* r) { int x, y, w, h; if (!m->ReadInt(iter, &x) || !m->ReadInt(iter, &y) || @@ -513,7 +519,9 @@ void ParamTraits<ui::Range>::Write(Message* m, const ui::Range& r) { m->WriteSize(r.end()); } -bool ParamTraits<ui::Range>::Read(const Message* m, void** iter, ui::Range* r) { +bool ParamTraits<ui::Range>::Read(const Message* m, + PickleIterator* iter, + ui::Range* r) { size_t start, end; if (!m->ReadSize(iter, &start) || !m->ReadSize(iter, &end)) return false; @@ -538,7 +546,9 @@ void ParamTraits<SkBitmap>::Write(Message* m, const SkBitmap& p) { static_cast<int>(pixel_size)); } -bool ParamTraits<SkBitmap>::Read(const Message* m, void** iter, SkBitmap* r) { +bool ParamTraits<SkBitmap>::Read(const Message* m, + PickleIterator* iter, + SkBitmap* r) { const char* fixed_data; int fixed_data_size = 0; if (!m->ReadData(iter, &fixed_data, &fixed_data_size) || diff --git a/content/public/common/common_param_traits.h b/content/public/common/common_param_traits.h index c768e3d..6afb2fd 100644 --- a/content/public/common/common_param_traits.h +++ b/content/public/common/common_param_traits.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -51,7 +51,7 @@ template <> struct CONTENT_EXPORT ParamTraits<GURL> { typedef GURL param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* p); + static bool Read(const Message* m, PickleIterator* iter, param_type* p); static void Log(const param_type& p, std::string* l); }; @@ -59,7 +59,7 @@ template <> struct ParamTraits<ResourceType::Type> { typedef ResourceType::Type param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* p); + static bool Read(const Message* m, PickleIterator* iter, param_type* p); static void Log(const param_type& p, std::string* l); }; @@ -67,7 +67,7 @@ template <> struct CONTENT_EXPORT ParamTraits<net::URLRequestStatus> { typedef net::URLRequestStatus param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -75,7 +75,7 @@ template <> struct CONTENT_EXPORT ParamTraits<scoped_refptr<net::UploadData> > { typedef scoped_refptr<net::UploadData> param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -83,7 +83,7 @@ template<> struct CONTENT_EXPORT ParamTraits<net::HostPortPair> { typedef net::HostPortPair param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -91,7 +91,7 @@ template <> struct ParamTraits<scoped_refptr<net::HttpResponseHeaders> > { typedef scoped_refptr<net::HttpResponseHeaders> param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -99,7 +99,7 @@ template <> struct ParamTraits<net::IPEndPoint> { typedef net::IPEndPoint param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* p); + static bool Read(const Message* m, PickleIterator* iter, param_type* p); static void Log(const param_type& p, std::string* l); }; @@ -107,7 +107,7 @@ template <> struct ParamTraits<base::PlatformFileInfo> { typedef base::PlatformFileInfo param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -115,7 +115,7 @@ template <> struct CONTENT_EXPORT ParamTraits<gfx::Point> { typedef gfx::Point param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -123,7 +123,7 @@ template <> struct CONTENT_EXPORT ParamTraits<gfx::Size> { typedef gfx::Size param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -131,7 +131,7 @@ template <> struct CONTENT_EXPORT ParamTraits<gfx::Rect> { typedef gfx::Rect param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -146,7 +146,7 @@ struct ParamTraits<gfx::NativeWindow> { m->WriteData(reinterpret_cast<const char*>(&p), sizeof(p)); #endif } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { #if defined(OS_WIN) return m->ReadUInt32(iter, reinterpret_cast<uint32*>(r)); #else @@ -171,7 +171,7 @@ template <> struct CONTENT_EXPORT ParamTraits<ui::Range> { typedef ui::Range param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -183,7 +183,7 @@ struct ParamTraits<TransportDIB::Id> { WriteParam(m, p.handle); WriteParam(m, p.sequence_num); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { return (ReadParam(m, iter, &r->handle) && ReadParam(m, iter, &r->sequence_num)); } @@ -204,7 +204,7 @@ struct ParamTraits<TransportDIB::Id> { static void Write(Message* m, const param_type& p) { WriteParam(m, p.shmkey); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { return ReadParam(m, iter, &r->shmkey); } static void Log(const param_type& p, std::string* l) { @@ -222,7 +222,7 @@ struct CONTENT_EXPORT ParamTraits<SkBitmap> { // Note: This function expects parameter |r| to be of type &SkBitmap since // r->SetConfig() and r->SetPixels() are called. - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; diff --git a/content/public/common/webkit_param_traits.cc b/content/public/common/webkit_param_traits.cc index 5d4e059..5d586d8 100644 --- a/content/public/common/webkit_param_traits.cc +++ b/content/public/common/webkit_param_traits.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -57,7 +57,7 @@ void ParamTraits<webkit_glue::ResourceLoadTimingInfo>::Write( } bool ParamTraits<webkit_glue::ResourceLoadTimingInfo>::Read( - const Message* m, void** iter, param_type* r) { + const Message* m, PickleIterator* iter, param_type* r) { bool is_null; if (!ReadParam(m, iter, &is_null)) return false; @@ -128,7 +128,7 @@ void ParamTraits<scoped_refptr<webkit_glue::ResourceDevToolsInfo> >::Write( } bool ParamTraits<scoped_refptr<webkit_glue::ResourceDevToolsInfo> >::Read( - const Message* m, void** iter, param_type* r) { + const Message* m, PickleIterator* iter, param_type* r) { bool has_object; if (!ReadParam(m, iter, &has_object)) return false; @@ -177,7 +177,7 @@ void ParamTraits<NPVariant_Param>::Write(Message* m, const param_type& p) { } bool ParamTraits<NPVariant_Param>::Read(const Message* m, - void** iter, + PickleIterator* iter, param_type* r) { int type; if (!ReadParam(m, iter, &type)) @@ -230,9 +230,9 @@ void ParamTraits<NPIdentifier_Param>::Write(Message* m, const param_type& p) { } bool ParamTraits<NPIdentifier_Param>::Read(const Message* m, - void** iter, + PickleIterator* iter, param_type* r) { - return webkit_glue::DeserializeNPIdentifier(*m, iter, &r->identifier); + return webkit_glue::DeserializeNPIdentifier(iter, &r->identifier); } void ParamTraits<NPIdentifier_Param>::Log(const param_type& p, std::string* l) { @@ -256,7 +256,7 @@ void ParamTraits<webkit::WebPluginMimeType>::Write(Message* m, } bool ParamTraits<webkit::WebPluginMimeType>::Read(const Message* m, - void** iter, + PickleIterator* iter, param_type* p) { return ReadParam(m, iter, &p->mime_type) && @@ -288,7 +288,7 @@ void ParamTraits<webkit::WebPluginInfo>::Write(Message* m, } bool ParamTraits<webkit::WebPluginInfo>::Read(const Message* m, - void** iter, + PickleIterator* iter, param_type* p) { return ReadParam(m, iter, &p->name) && @@ -328,7 +328,7 @@ void ParamTraits<webkit::forms::PasswordForm>::Write(Message* m, } bool ParamTraits<webkit::forms::PasswordForm>::Read(const Message* m, - void** iter, + PickleIterator* iter, param_type* p) { return ReadParam(m, iter, &p->signon_realm) && diff --git a/content/public/common/webkit_param_traits.h b/content/public/common/webkit_param_traits.h index 786b8ec..a1e0002 100644 --- a/content/public/common/webkit_param_traits.h +++ b/content/public/common/webkit_param_traits.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -82,7 +82,7 @@ template <> struct ParamTraits<webkit_glue::ResourceLoadTimingInfo> { typedef webkit_glue::ResourceLoadTimingInfo param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -90,7 +90,7 @@ template <> struct ParamTraits<scoped_refptr<webkit_glue::ResourceDevToolsInfo> > { typedef scoped_refptr<webkit_glue::ResourceDevToolsInfo> param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -98,7 +98,7 @@ template <> struct ParamTraits<NPVariant_Param> { typedef NPVariant_Param param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -106,7 +106,7 @@ template <> struct ParamTraits<NPIdentifier_Param> { typedef NPIdentifier_Param param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -114,7 +114,7 @@ template <> struct ParamTraits<webkit::WebPluginMimeType> { typedef webkit::WebPluginMimeType param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -122,7 +122,7 @@ template <> struct CONTENT_EXPORT ParamTraits<webkit::WebPluginInfo> { typedef webkit::WebPluginInfo param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -132,8 +132,8 @@ struct ParamTraits<WebCursor> { static void Write(Message* m, const param_type& p) { p.Serialize(m); } - static bool Read(const Message* m, void** iter, param_type* r) { - return r->Deserialize(m, iter); + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { + return r->Deserialize(iter); } static void Log(const param_type& p, std::string* l) { l->append("<WebCursor>"); @@ -146,7 +146,7 @@ struct ParamTraits<WebKit::WebInputEvent::Type> { static void Write(Message* m, const param_type& p) { m->WriteInt(p); } - static bool Read(const Message* m, void** iter, param_type* p) { + static bool Read(const Message* m, PickleIterator* iter, param_type* p) { int type; if (!m->ReadInt(iter, &type)) return false; @@ -199,7 +199,7 @@ struct ParamTraits<WebInputEventPointer> { m->WriteData(reinterpret_cast<const char*>(p), p->size); } // Note: upon read, the event has the lifetime of the message. - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { const char* data; int data_length; if (!m->ReadData(iter, &data, &data_length)) { @@ -245,7 +245,7 @@ template <> struct CONTENT_EXPORT ParamTraits<webkit::forms::PasswordForm> { typedef webkit::forms::PasswordForm param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* p); + static bool Read(const Message* m, PickleIterator* iter, param_type* p); static void Log(const param_type& p, std::string* l); }; diff --git a/content/renderer/gpu/input_event_filter.cc b/content/renderer/gpu/input_event_filter.cc index a0129ea..81d07ac 100644 --- a/content/renderer/gpu/input_event_filter.cc +++ b/content/renderer/gpu/input_event_filter.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -93,7 +93,7 @@ const WebInputEvent* InputEventFilter::CrackMessage( const IPC::Message& message) { DCHECK(message.type() == ViewMsg_HandleInputEvent::ID); - void* iter = NULL; + PickleIterator iter(message); const char* data; int data_length; if (!message.ReadData(&iter, &data, &data_length)) diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc index c5c16dc..549331a 100644 --- a/content/renderer/render_widget.cc +++ b/content/renderer/render_widget.cc @@ -507,7 +507,7 @@ void RenderWidget::OnSwapBuffersComplete() { void RenderWidget::OnHandleInputEvent(const IPC::Message& message) { TRACE_EVENT0("renderer", "RenderWidget::OnHandleInputEvent"); - void* iter = NULL; + PickleIterator iter(message); const char* data; int data_length; diff --git a/content/test/mock_render_thread.cc b/content/test/mock_render_thread.cc index 1663531..ce74409 100644 --- a/content/test/mock_render_thread.cc +++ b/content/test/mock_render_thread.cc @@ -24,7 +24,7 @@ void MockRenderThread::VerifyRunJavaScriptMessageSend( const IPC::Message* alert_msg = sink_.GetUniqueMessageMatching(ViewHostMsg_RunJavaScriptMessage::ID); ASSERT_TRUE(alert_msg); - void* iter = IPC::SyncMessage::GetDataIterator(alert_msg); + PickleIterator iter = IPC::SyncMessage::GetDataIterator(alert_msg); ViewHostMsg_RunJavaScriptMessage::SendParam alert_param; ASSERT_TRUE(IPC::ReadParam(alert_msg, &iter, &alert_param)); EXPECT_EQ(expected_alert_message, alert_param.a); diff --git a/crypto/secure_hash.h b/crypto/secure_hash.h index 4a49380..28b78c1 100644 --- a/crypto/secure_hash.h +++ b/crypto/secure_hash.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -10,6 +10,7 @@ #include "crypto/crypto_export.h" class Pickle; +class PickleIterator; namespace crypto { @@ -36,7 +37,7 @@ class CRYPTO_EXPORT SecureHash { // |data_iterator| allows this to be used as part of a larger pickle. // |pickle| holds the saved data. // Returns success or failure. - virtual bool Deserialize(void** data_iterator, Pickle* pickle) = 0; + virtual bool Deserialize(PickleIterator* data_iterator) = 0; protected: SecureHash() {} diff --git a/crypto/secure_hash_default.cc b/crypto/secure_hash_default.cc index 6607dfe..834a276 100644 --- a/crypto/secure_hash_default.cc +++ b/crypto/secure_hash_default.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -36,7 +36,7 @@ class SecureHashSHA256NSS : public SecureHash { } virtual bool Serialize(Pickle* pickle); - virtual bool Deserialize(void** data_iterator, Pickle* pickle); + virtual bool Deserialize(PickleIterator* data_iterator); private: SHA256Context ctx_; @@ -55,26 +55,23 @@ bool SecureHashSHA256NSS::Serialize(Pickle* pickle) { return true; } -bool SecureHashSHA256NSS::Deserialize(void** data_iterator, Pickle* pickle) { - if (!pickle) - return false; - +bool SecureHashSHA256NSS::Deserialize(PickleIterator* data_iterator) { int version; - if (!pickle->ReadInt(data_iterator, &version)) + if (!data_iterator->ReadInt(&version)) return false; if (version > kSecureHashVersion) return false; // We don't know how to deal with this. std::string type; - if (!pickle->ReadString(data_iterator, &type)) + if (!data_iterator->ReadString(&type)) return false; if (type != kSHA256Descriptor) return false; // It's the wrong kind. const char* data = NULL; - if (!pickle->ReadBytes(data_iterator, &data, sizeof(ctx_))) + if (!data_iterator->ReadBytes(&data, sizeof(ctx_))) return false; memcpy(&ctx_, data, sizeof(ctx_)); diff --git a/crypto/secure_hash_openssl.cc b/crypto/secure_hash_openssl.cc index 098bf27..a542e22 100644 --- a/crypto/secure_hash_openssl.cc +++ b/crypto/secure_hash_openssl.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -40,7 +40,7 @@ class SecureHashSHA256OpenSSL : public SecureHash { } virtual bool Serialize(Pickle* pickle); - virtual bool Deserialize(void** data_iterator, Pickle* pickle); + virtual bool Deserialize(PickleIterator* data_iterator); private: SHA256_CTX ctx_; @@ -59,27 +59,26 @@ bool SecureHashSHA256OpenSSL::Serialize(Pickle* pickle) { return true; } -bool SecureHashSHA256OpenSSL::Deserialize(void** data_iterator, - Pickle* pickle) { - if (!pickle) +bool SecureHashSHA256OpenSSL::Deserialize(PickleIterator* data_iterator) { + if (!data_iterator) return false; int version; - if (!pickle->ReadInt(data_iterator, &version)) + if (!data_iterator->ReadInt(&version)) return false; if (version > kSecureHashVersion) return false; // We don't know how to deal with this. std::string type; - if (!pickle->ReadString(data_iterator, &type)) + if (!data_iterator->ReadString(&type)) return false; if (type != kSHA256Descriptor) return false; // It's the wrong kind. const char* data = NULL; - if (!pickle->ReadBytes(data_iterator, &data, sizeof(ctx_))) + if (!data_iterator->ReadBytes(&data, sizeof(ctx_))) return false; memcpy(&ctx_, data, sizeof(ctx_)); diff --git a/crypto/secure_hash_unittest.cc b/crypto/secure_hash_unittest.cc index 2adddfb..42b9ade3 100644 --- a/crypto/secure_hash_unittest.cc +++ b/crypto/secure_hash_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -62,8 +62,8 @@ TEST(SecureHashTest, TestSerialization) { ctx1->Finish(output1, sizeof(output1)); - void* data_iterator = NULL; - EXPECT_TRUE(ctx2->Deserialize(&data_iterator, &pickle)); + PickleIterator data_iterator(pickle); + EXPECT_TRUE(ctx2->Deserialize(&data_iterator)); ctx2->Update(input4.data(), input4.size()); ctx2->Update(input5.data(), input5.size()); diff --git a/gpu/ipc/gpu_command_buffer_traits.cc b/gpu/ipc/gpu_command_buffer_traits.cc index 66d4189..b502b0fd 100644 --- a/gpu/ipc/gpu_command_buffer_traits.cc +++ b/gpu/ipc/gpu_command_buffer_traits.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -17,7 +17,7 @@ void ParamTraits<gpu::CommandBuffer::State> ::Write(Message* m, } bool ParamTraits<gpu::CommandBuffer::State> ::Read(const Message* m, - void** iter, + PickleIterator* iter, param_type* p) { int32 temp; if (ReadParam(m, iter, &p->num_entries) && diff --git a/gpu/ipc/gpu_command_buffer_traits.h b/gpu/ipc/gpu_command_buffer_traits.h index 12f1306..ac267db 100644 --- a/gpu/ipc/gpu_command_buffer_traits.h +++ b/gpu/ipc/gpu_command_buffer_traits.h @@ -15,7 +15,7 @@ template <> struct GPU_EXPORT ParamTraits<gpu::CommandBuffer::State> { typedef gpu::CommandBuffer::State param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* p); + static bool Read(const Message* m, PickleIterator* iter, param_type* p); static void Log(const param_type& p, std::string* l); }; diff --git a/ipc/ipc_channel_posix.cc b/ipc/ipc_channel_posix.cc index 1960cb0..4d6b8a02 100644 --- a/ipc/ipc_channel_posix.cc +++ b/ipc/ipc_channel_posix.cc @@ -1126,7 +1126,7 @@ void Channel::ChannelImpl::ClearInputFDs() { void Channel::ChannelImpl::HandleHelloMessage(const Message& msg) { // The Hello message contains only the process id. - void *iter = NULL; + PickleIterator iter(msg); int pid; if (!msg.ReadInt(&iter, &pid)) NOTREACHED(); diff --git a/ipc/ipc_fuzzing_tests.cc b/ipc/ipc_fuzzing_tests.cc index 05d177b..aa1fa5f 100644 --- a/ipc/ipc_fuzzing_tests.cc +++ b/ipc/ipc_fuzzing_tests.cc @@ -44,7 +44,7 @@ TEST(IPCMessageIntegrity, ReadBeyondBufferStr) { EXPECT_TRUE(m.WriteInt(v1)); EXPECT_TRUE(m.WriteInt(v2)); - void* iter = NULL; + PickleIterator iter(m); std::string vs; EXPECT_FALSE(m.ReadString(&iter, &vs)); } @@ -57,7 +57,7 @@ TEST(IPCMessageIntegrity, ReadBeyondBufferWStr) { EXPECT_TRUE(m.WriteInt(v1)); EXPECT_TRUE(m.WriteInt(v2)); - void* iter = NULL; + PickleIterator iter(m); std::wstring vs; EXPECT_FALSE(m.ReadWString(&iter, &vs)); } @@ -68,7 +68,7 @@ TEST(IPCMessageIntegrity, ReadBytesBadIterator) { EXPECT_TRUE(m.WriteInt(1)); EXPECT_TRUE(m.WriteInt(2)); - void* iter = NULL; + PickleIterator iter(m); const char* data = NULL; EXPECT_TRUE(m.ReadBytes(&iter, &data, sizeof(int))); } @@ -84,7 +84,7 @@ TEST(IPCMessageIntegrity, ReadVectorNegativeSize) { EXPECT_TRUE(m.WriteInt(3)); std::vector<double> vec; - void* iter = 0; + PickleIterator iter(m); EXPECT_FALSE(ReadParam(&m, &iter, &vec)); } @@ -97,7 +97,7 @@ TEST(IPCMessageIntegrity, ReadVectorTooLarge1) { EXPECT_TRUE(m.WriteInt64(2)); std::vector<int64> vec; - void* iter = 0; + PickleIterator iter(m); EXPECT_FALSE(ReadParam(&m, &iter, &vec)); } @@ -111,7 +111,7 @@ TEST(IPCMessageIntegrity, ReadVectorTooLarge2) { EXPECT_TRUE(m.WriteInt64(2)); std::vector<int64> vec; - void* iter = 0; + PickleIterator iter(m); EXPECT_FALSE(ReadParam(&m, &iter, &vec)); } @@ -212,7 +212,7 @@ class FuzzerClientListener : public SimpleListener { return false; int msg_value1 = 0; int msg_value2 = 0; - void* iter = NULL; + PickleIterator iter(*last_msg_); if (!last_msg_->ReadInt(&iter, &msg_value1)) return false; if (!last_msg_->ReadInt(&iter, &msg_value2)) diff --git a/ipc/ipc_logging.cc b/ipc/ipc_logging.cc index d50766c..b9ca828 100644 --- a/ipc/ipc_logging.cc +++ b/ipc/ipc_logging.cc @@ -109,7 +109,7 @@ void Logging::SetIPCSender(IPC::Message::Sender* sender) { void Logging::OnReceivedLoggingMessage(const Message& message) { std::vector<LogData> data; - void* iter = NULL; + PickleIterator iter(message); if (!ReadParam(&message, &iter, &data)) return; diff --git a/ipc/ipc_message.cc b/ipc/ipc_message.cc index 703588d0..feec91a 100644 --- a/ipc/ipc_message.cc +++ b/ipc/ipc_message.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -100,7 +100,7 @@ bool Message::WriteFileDescriptor(const base::FileDescriptor& descriptor) { } } -bool Message::ReadFileDescriptor(void** iter, +bool Message::ReadFileDescriptor(PickleIterator* iter, base::FileDescriptor* descriptor) const { int descriptor_index; if (!ReadInt(iter, &descriptor_index)) diff --git a/ipc/ipc_message.h b/ipc/ipc_message.h index b630432..2598c8c 100644 --- a/ipc/ipc_message.h +++ b/ipc/ipc_message.h @@ -180,7 +180,8 @@ class IPC_EXPORT Message : public Pickle { bool WriteFileDescriptor(const base::FileDescriptor& descriptor); // Get a file descriptor from the message. Returns false on error. // iter: a Pickle iterator to the current location in the message. - bool ReadFileDescriptor(void** iter, base::FileDescriptor* descriptor) const; + bool ReadFileDescriptor(PickleIterator* iter, + base::FileDescriptor* descriptor) const; #endif #ifdef IPC_MESSAGE_LOG_ENABLED diff --git a/ipc/ipc_message_unittest.cc b/ipc/ipc_message_unittest.cc index 7339e30..2f50ee3 100644 --- a/ipc/ipc_message_unittest.cc +++ b/ipc/ipc_message_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -21,7 +21,7 @@ TEST(IPCMessageTest, ListValue) { IPC::WriteParam(&msg, input); ListValue output; - void* iter = NULL; + PickleIterator iter(msg); EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output)); EXPECT_TRUE(input.Equals(&output)); @@ -29,7 +29,7 @@ TEST(IPCMessageTest, ListValue) { // Also test the corrupt case. IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL); bad_msg.WriteInt(99); - iter = NULL; + iter = PickleIterator(bad_msg); EXPECT_FALSE(IPC::ReadParam(&bad_msg, &iter, &output)); } @@ -56,7 +56,7 @@ TEST(IPCMessageTest, DictionaryValue) { IPC::WriteParam(&msg, input); DictionaryValue output; - void* iter = NULL; + PickleIterator iter(msg); EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output)); EXPECT_TRUE(input.Equals(&output)); @@ -64,6 +64,6 @@ TEST(IPCMessageTest, DictionaryValue) { // Also test the corrupt case. IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL); bad_msg.WriteInt(99); - iter = NULL; + iter = PickleIterator(bad_msg); EXPECT_FALSE(IPC::ReadParam(&bad_msg, &iter, &output)); } diff --git a/ipc/ipc_message_utils.cc b/ipc/ipc_message_utils.cc index 03d326b..72437a9 100644 --- a/ipc/ipc_message_utils.cc +++ b/ipc/ipc_message_utils.cc @@ -23,7 +23,7 @@ const int kMaxRecursionDepth = 100; // Value serialization -static bool ReadValue(const Message* m, void** iter, Value** value, +static bool ReadValue(const Message* m, PickleIterator* iter, Value** value, int recursion); static void WriteValue(Message* m, const Value* value, int recursion) { @@ -102,7 +102,7 @@ static void WriteValue(Message* m, const Value* value, int recursion) { // Helper for ReadValue that reads a DictionaryValue into a pre-allocated // object. -static bool ReadDictionaryValue(const Message* m, void** iter, +static bool ReadDictionaryValue(const Message* m, PickleIterator* iter, DictionaryValue* value, int recursion) { int size; if (!ReadParam(m, iter, &size)) @@ -122,7 +122,7 @@ static bool ReadDictionaryValue(const Message* m, void** iter, // Helper for ReadValue that reads a ReadListValue into a pre-allocated // object. -static bool ReadListValue(const Message* m, void** iter, +static bool ReadListValue(const Message* m, PickleIterator* iter, ListValue* value, int recursion) { int size; if (!ReadParam(m, iter, &size)) @@ -138,7 +138,7 @@ static bool ReadListValue(const Message* m, void** iter, return true; } -static bool ReadValue(const Message* m, void** iter, Value** value, +static bool ReadValue(const Message* m, PickleIterator* iter, Value** value, int recursion) { if (recursion > kMaxRecursionDepth) { LOG(WARNING) << "Max recursion depth hit in ReadValue."; @@ -238,7 +238,7 @@ void ParamTraits<unsigned short>::Write(Message* m, const param_type& p) { m->WriteBytes(&p, sizeof(param_type)); } -bool ParamTraits<unsigned short>::Read(const Message* m, void** iter, +bool ParamTraits<unsigned short>::Read(const Message* m, PickleIterator* iter, param_type* r) { const char* data; if (!m->ReadBytes(iter, &data, sizeof(param_type))) @@ -255,7 +255,7 @@ void ParamTraits<base::Time>::Write(Message* m, const param_type& p) { ParamTraits<int64>::Write(m, p.ToInternalValue()); } -bool ParamTraits<base::Time>::Read(const Message* m, void** iter, +bool ParamTraits<base::Time>::Read(const Message* m, PickleIterator* iter, param_type* r) { int64 value; if (!ParamTraits<int64>::Read(m, iter, &value)) @@ -273,7 +273,7 @@ void ParamTraits<base::TimeDelta> ::Write(Message* m, const param_type& p) { } bool ParamTraits<base::TimeDelta> ::Read(const Message* m, - void** iter, + PickleIterator* iter, param_type* r) { int64 value; bool ret = ParamTraits<int64> ::Read(m, iter, &value); @@ -292,7 +292,7 @@ void ParamTraits<base::TimeTicks> ::Write(Message* m, const param_type& p) { } bool ParamTraits<base::TimeTicks> ::Read(const Message* m, - void** iter, + PickleIterator* iter, param_type* r) { int64 value; bool ret = ParamTraits<int64> ::Read(m, iter, &value); @@ -311,7 +311,7 @@ void ParamTraits<DictionaryValue>::Write(Message* m, const param_type& p) { } bool ParamTraits<DictionaryValue>::Read( - const Message* m, void** iter, param_type* r) { + const Message* m, PickleIterator* iter, param_type* r) { int type; if (!ReadParam(m, iter, &type) || type != Value::TYPE_DICTIONARY) return false; @@ -330,7 +330,7 @@ void ParamTraits<ListValue>::Write(Message* m, const param_type& p) { } bool ParamTraits<ListValue>::Read( - const Message* m, void** iter, param_type* r) { + const Message* m, PickleIterator* iter, param_type* r) { int type; if (!ReadParam(m, iter, &type) || type != Value::TYPE_LIST) return false; @@ -353,7 +353,7 @@ void ParamTraits<NullableString16>::Write(Message* m, const param_type& p) { WriteParam(m, p.is_null()); } -bool ParamTraits<NullableString16>::Read(const Message* m, void** iter, +bool ParamTraits<NullableString16>::Read(const Message* m, PickleIterator* iter, param_type* r) { string16 string; if (!ReadParam(m, iter, &string)) @@ -384,7 +384,9 @@ void ParamTraits<FilePath>::Write(Message* m, const param_type& p) { ParamTraits<FilePath::StringType>::Write(m, p.value()); } -bool ParamTraits<FilePath>::Read(const Message* m, void** iter, param_type* r) { +bool ParamTraits<FilePath>::Read(const Message* m, + PickleIterator* iter, + param_type* r) { FilePath::StringType value; if (!ParamTraits<FilePath::StringType>::Read(m, iter, &value)) return false; @@ -407,7 +409,8 @@ void ParamTraits<base::FileDescriptor>::Write(Message* m, const param_type& p) { } } -bool ParamTraits<base::FileDescriptor>::Read(const Message* m, void** iter, +bool ParamTraits<base::FileDescriptor>::Read(const Message* m, + PickleIterator* iter, param_type* r) { bool valid; if (!ReadParam(m, iter, &valid)) @@ -443,7 +446,8 @@ void ParamTraits<IPC::ChannelHandle>::Write(Message* m, const param_type& p) { #endif } -bool ParamTraits<IPC::ChannelHandle>::Read(const Message* m, void** iter, +bool ParamTraits<IPC::ChannelHandle>::Read(const Message* m, + PickleIterator* iter, param_type* r) { return ReadParam(m, iter, &r->name) #if defined(OS_POSIX) @@ -484,7 +488,9 @@ void ParamTraits<LogData>::Write(Message* m, const param_type& p) { WriteParam(m, p.params); } -bool ParamTraits<LogData>::Read(const Message* m, void** iter, param_type* r) { +bool ParamTraits<LogData>::Read(const Message* m, + PickleIterator* iter, + param_type* r) { return ReadParam(m, iter, &r->channel) && ReadParam(m, iter, &r->routing_id) && diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h index 1a7555b..3908b12 100644 --- a/ipc/ipc_message_utils.h +++ b/ipc/ipc_message_utils.h @@ -124,34 +124,33 @@ struct ChannelHandle; class MessageIterator { public: - explicit MessageIterator(const Message& m) : msg_(m), iter_(NULL) { + explicit MessageIterator(const Message& m) : iter_(m) { } int NextInt() const { int val = -1; - if (!msg_.ReadInt(&iter_, &val)) + if (!iter_.ReadInt(&val)) NOTREACHED(); return val; } const std::string NextString() const { std::string val; - if (!msg_.ReadString(&iter_, &val)) + if (!iter_.ReadString(&val)) NOTREACHED(); return val; } const std::wstring NextWString() const { std::wstring val; - if (!msg_.ReadWString(&iter_, &val)) + if (!iter_.ReadWString(&val)) NOTREACHED(); return val; } void NextData(const char** data, int* length) const { - if (!msg_.ReadData(&iter_, data, length)) { + if (!iter_.ReadData(data, length)) { NOTREACHED(); } } private: - const Message& msg_; - mutable void* iter_; + mutable PickleIterator iter_; }; //----------------------------------------------------------------------------- @@ -170,7 +169,8 @@ static inline void WriteParam(Message* m, const P& p) { } template <class P> -static inline bool WARN_UNUSED_RESULT ReadParam(const Message* m, void** iter, +static inline bool WARN_UNUSED_RESULT ReadParam(const Message* m, + PickleIterator* iter, P* p) { typedef typename SimilarTypeTraits<P>::Type Type; return ParamTraits<Type>::Read(m, iter, reinterpret_cast<Type* >(p)); @@ -188,7 +188,8 @@ struct ParamTraits<bool> { static void Write(Message* m, const param_type& p) { m->WriteBool(p); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, + param_type* r) { return m->ReadBool(iter, r); } static void Log(const param_type& p, std::string* l) { @@ -202,7 +203,8 @@ struct ParamTraits<int> { static void Write(Message* m, const param_type& p) { m->WriteInt(p); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, + param_type* r) { return m->ReadInt(iter, r); } IPC_EXPORT static void Log(const param_type& p, std::string* l); @@ -214,7 +216,8 @@ struct ParamTraits<unsigned int> { static void Write(Message* m, const param_type& p) { m->WriteInt(p); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, + param_type* r) { return m->ReadInt(iter, reinterpret_cast<int*>(r)); } IPC_EXPORT static void Log(const param_type& p, std::string* l); @@ -226,7 +229,8 @@ struct ParamTraits<long> { static void Write(Message* m, const param_type& p) { m->WriteLong(p); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, + param_type* r) { return m->ReadLong(iter, r); } IPC_EXPORT static void Log(const param_type& p, std::string* l); @@ -238,7 +242,8 @@ struct ParamTraits<unsigned long> { static void Write(Message* m, const param_type& p) { m->WriteLong(p); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, + param_type* r) { return m->ReadLong(iter, reinterpret_cast<long*>(r)); } IPC_EXPORT static void Log(const param_type& p, std::string* l); @@ -250,7 +255,8 @@ struct ParamTraits<long long> { static void Write(Message* m, const param_type& p) { m->WriteInt64(static_cast<int64>(p)); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, + param_type* r) { return m->ReadInt64(iter, reinterpret_cast<int64*>(r)); } IPC_EXPORT static void Log(const param_type& p, std::string* l); @@ -262,7 +268,8 @@ struct ParamTraits<unsigned long long> { static void Write(Message* m, const param_type& p) { m->WriteInt64(p); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, + param_type* r) { return m->ReadInt64(iter, reinterpret_cast<int64*>(r)); } IPC_EXPORT static void Log(const param_type& p, std::string* l); @@ -272,7 +279,7 @@ template <> struct IPC_EXPORT ParamTraits<unsigned short> { typedef unsigned short param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -285,7 +292,8 @@ struct ParamTraits<float> { static void Write(Message* m, const param_type& p) { m->WriteData(reinterpret_cast<const char*>(&p), sizeof(param_type)); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, + param_type* r) { const char *data; int data_size; if (!m->ReadData(iter, &data, &data_size) || @@ -307,7 +315,8 @@ struct ParamTraits<double> { static void Write(Message* m, const param_type& p) { m->WriteData(reinterpret_cast<const char*>(&p), sizeof(param_type)); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, + param_type* r) { const char *data; int data_size; if (!m->ReadData(iter, &data, &data_size) || @@ -327,7 +336,7 @@ template <> struct IPC_EXPORT ParamTraits<base::Time> { typedef base::Time param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -335,7 +344,7 @@ template <> struct IPC_EXPORT ParamTraits<base::TimeDelta> { typedef base::TimeDelta param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -343,7 +352,7 @@ template <> struct IPC_EXPORT ParamTraits<base::TimeTicks> { typedef base::TimeTicks param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -354,7 +363,8 @@ struct ParamTraits<LOGFONT> { static void Write(Message* m, const param_type& p) { m->WriteData(reinterpret_cast<const char*>(&p), sizeof(LOGFONT)); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, + param_type* r) { const char *data; int data_size = 0; bool result = m->ReadData(iter, &data, &data_size); @@ -378,7 +388,8 @@ struct ParamTraits<MSG> { static void Write(Message* m, const param_type& p) { m->WriteData(reinterpret_cast<const char*>(&p), sizeof(MSG)); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, + param_type* r) { const char *data; int data_size = 0; bool result = m->ReadData(iter, &data, &data_size); @@ -401,7 +412,7 @@ template <> struct IPC_EXPORT ParamTraits<base::DictionaryValue> { typedef base::DictionaryValue param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -409,7 +420,7 @@ template <> struct IPC_EXPORT ParamTraits<base::ListValue> { typedef base::ListValue param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -419,7 +430,8 @@ struct ParamTraits<std::string> { static void Write(Message* m, const param_type& p) { m->WriteString(p); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, + param_type* r) { return m->ReadString(iter, r); } static void Log(const param_type& p, std::string* l) { @@ -461,7 +473,8 @@ struct ParamTraits<std::vector<unsigned char> > { static_cast<int>(p.size())); } } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, + param_type* r) { const char *data; int data_size = 0; if (!m->ReadData(iter, &data, &data_size) || data_size < 0) @@ -486,7 +499,8 @@ struct ParamTraits<std::vector<char> > { m->WriteData(&p.front(), static_cast<int>(p.size())); } } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, + param_type* r) { const char *data; int data_size = 0; if (!m->ReadData(iter, &data, &data_size) || data_size < 0) @@ -509,7 +523,8 @@ struct ParamTraits<std::vector<bool> > { for (size_t i = 0; i < p.size(); i++) WriteParam(m, p[i]); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, + param_type* r) { int size; // ReadLength() checks for < 0 itself. if (!m->ReadLength(iter, &size)) @@ -540,7 +555,8 @@ struct ParamTraits<std::vector<P> > { for (size_t i = 0; i < p.size(); i++) WriteParam(m, p[i]); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, + param_type* r) { int size; // ReadLength() checks for < 0 itself. if (!m->ReadLength(iter, &size)) @@ -573,7 +589,8 @@ struct ParamTraits<std::set<P> > { for (iter = p.begin(); iter != p.end(); ++iter) WriteParam(m, *iter); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, + param_type* r) { int size; if (!m->ReadLength(iter, &size)) return false; @@ -602,7 +619,8 @@ struct ParamTraits<std::map<K, V> > { WriteParam(m, iter->second); } } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, + param_type* r) { int size; if (!ReadParam(m, iter, &size) || size < 0) return false; @@ -628,7 +646,8 @@ struct ParamTraits<std::wstring> { static void Write(Message* m, const param_type& p) { m->WriteWString(p); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, + param_type* r) { return m->ReadWString(iter, r); } IPC_EXPORT static void Log(const param_type& p, std::string* l); @@ -641,7 +660,8 @@ struct ParamTraits<std::pair<A, B> > { WriteParam(m, p.first); WriteParam(m, p.second); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, + param_type* r) { return ReadParam(m, iter, &r->first) && ReadParam(m, iter, &r->second); } static void Log(const param_type& p, std::string* l) { @@ -657,7 +677,8 @@ template <> struct IPC_EXPORT ParamTraits<NullableString16> { typedef NullableString16 param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -670,7 +691,8 @@ struct ParamTraits<string16> { static void Write(Message* m, const param_type& p) { m->WriteString16(p); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, + param_type* r) { return m->ReadString16(iter, r); } IPC_EXPORT static void Log(const param_type& p, std::string* l); @@ -687,7 +709,8 @@ struct ParamTraits<HANDLE> { // bit systems. m->WriteUInt32(reinterpret_cast<uint32>(p)); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, + param_type* r) { DCHECK_EQ(sizeof(param_type), sizeof(uint32)); return m->ReadUInt32(iter, reinterpret_cast<uint32*>(r)); } @@ -702,7 +725,7 @@ struct ParamTraits<HCURSOR> { static void Write(Message* m, const param_type& p) { m->WriteUInt32(reinterpret_cast<uint32>(p)); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { DCHECK_EQ(sizeof(param_type), sizeof(uint32)); return m->ReadUInt32(iter, reinterpret_cast<uint32*>(r)); } @@ -717,7 +740,7 @@ struct ParamTraits<HACCEL> { static void Write(Message* m, const param_type& p) { m->WriteUInt32(reinterpret_cast<uint32>(p)); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { DCHECK_EQ(sizeof(param_type), sizeof(uint32)); return m->ReadUInt32(iter, reinterpret_cast<uint32*>(r)); } @@ -730,7 +753,7 @@ struct ParamTraits<POINT> { m->WriteInt(p.x); m->WriteInt(p.y); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { int x, y; if (!m->ReadInt(iter, &x) || !m->ReadInt(iter, &y)) return false; @@ -748,7 +771,7 @@ template <> struct IPC_EXPORT ParamTraits<FilePath> { typedef FilePath param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -772,7 +795,7 @@ template<> struct IPC_EXPORT ParamTraits<base::FileDescriptor> { typedef base::FileDescriptor param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; #endif // defined(OS_POSIX) @@ -784,7 +807,7 @@ template<> struct IPC_EXPORT ParamTraits<IPC::ChannelHandle> { typedef ChannelHandle param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -795,7 +818,7 @@ struct ParamTraits<XFORM> { static void Write(Message* m, const param_type& p) { m->WriteData(reinterpret_cast<const char*>(&p), sizeof(XFORM)); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { const char *data; int data_size = 0; bool result = m->ReadData(iter, &data, &data_size); @@ -835,7 +858,7 @@ template <> struct IPC_EXPORT ParamTraits<LogData> { typedef LogData param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l) { // Doesn't make sense to implement this! } @@ -849,7 +872,7 @@ struct ParamTraits<Message> { m->WriteInt(message_size); m->WriteData(reinterpret_cast<const char*>(p.data()), message_size); } - static bool Read(const Message* m, void** iter, Message* r) { + static bool Read(const Message* m, PickleIterator* iter, Message* r) { int size; if (!m->ReadInt(iter, &size)) return false; @@ -869,7 +892,7 @@ struct ParamTraits<Tuple0> { typedef Tuple0 param_type; static void Write(Message* m, const param_type& p) { } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { return true; } static void Log(const param_type& p, std::string* l) { @@ -882,7 +905,7 @@ struct ParamTraits< Tuple1<A> > { static void Write(Message* m, const param_type& p) { WriteParam(m, p.a); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { return ReadParam(m, iter, &r->a); } static void Log(const param_type& p, std::string* l) { @@ -897,7 +920,7 @@ struct ParamTraits< Tuple2<A, B> > { WriteParam(m, p.a); WriteParam(m, p.b); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { return (ReadParam(m, iter, &r->a) && ReadParam(m, iter, &r->b)); } @@ -916,7 +939,7 @@ struct ParamTraits< Tuple3<A, B, C> > { WriteParam(m, p.b); WriteParam(m, p.c); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { return (ReadParam(m, iter, &r->a) && ReadParam(m, iter, &r->b) && ReadParam(m, iter, &r->c)); @@ -939,7 +962,7 @@ struct ParamTraits< Tuple4<A, B, C, D> > { WriteParam(m, p.c); WriteParam(m, p.d); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { return (ReadParam(m, iter, &r->a) && ReadParam(m, iter, &r->b) && ReadParam(m, iter, &r->c) && @@ -966,7 +989,7 @@ struct ParamTraits< Tuple5<A, B, C, D, E> > { WriteParam(m, p.d); WriteParam(m, p.e); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { return (ReadParam(m, iter, &r->a) && ReadParam(m, iter, &r->b) && ReadParam(m, iter, &r->c) && @@ -1054,7 +1077,7 @@ class ParamDeserializer : public MessageReplyDeserializer { public: explicit ParamDeserializer(const RefTuple& out) : out_(out) { } - bool SerializeOutputParameters(const IPC::Message& msg, void* iter) { + bool SerializeOutputParameters(const IPC::Message& msg, PickleIterator iter) { return ReadParam(&msg, &iter, &out_); } diff --git a/ipc/ipc_message_utils_impl.h b/ipc/ipc_message_utils_impl.h index f078b2a..0931e30 100644 --- a/ipc/ipc_message_utils_impl.h +++ b/ipc/ipc_message_utils_impl.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -18,7 +18,7 @@ void MessageSchema<ParamType>::Write(Message* msg, const RefParam& p) { template <class ParamType> bool MessageSchema<ParamType>::Read(const Message* msg, Param* p) { - void* iter = NULL; + PickleIterator iter(*msg); if (ReadParam(msg, &iter, p)) return true; NOTREACHED() << "Error deserializing message " << msg->type(); @@ -35,14 +35,14 @@ void SyncMessageSchema<SendParamType, ReplyParamType>::Write( template <class SendParamType, class ReplyParamType> bool SyncMessageSchema<SendParamType, ReplyParamType>::ReadSendParam( const Message* msg, SendParam* p) { - void* iter = SyncMessage::GetDataIterator(msg); + PickleIterator iter = SyncMessage::GetDataIterator(msg); return ReadParam(msg, &iter, p); } template <class SendParamType, class ReplyParamType> bool SyncMessageSchema<SendParamType, ReplyParamType>::ReadReplyParam( const Message* msg, typename TupleTypes<ReplyParam>::ValueTuple* p) { - void* iter = SyncMessage::GetDataIterator(msg); + PickleIterator iter = SyncMessage::GetDataIterator(msg); return ReadParam(msg, &iter, p); } diff --git a/ipc/ipc_send_fds_test.cc b/ipc/ipc_send_fds_test.cc index 3b845f8..124a3dc 100644 --- a/ipc/ipc_send_fds_test.cc +++ b/ipc/ipc_send_fds_test.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -52,7 +52,7 @@ class MyChannelDescriptorListener : public IPC::Channel::Listener { num_fds_received_(0) {} virtual bool OnMessageReceived(const IPC::Message& message) { - void* iter = NULL; + PickleIterator iter(message); ++num_fds_received_; base::FileDescriptor descriptor; diff --git a/ipc/ipc_sync_message.cc b/ipc/ipc_sync_message.cc index 875f97b..eb0a917 100644 --- a/ipc/ipc_sync_message.cc +++ b/ipc/ipc_sync_message.cc @@ -74,10 +74,12 @@ bool SyncMessage::IsMessageReplyTo(const Message& msg, int request_id) { return GetMessageId(msg) == request_id; } -void* SyncMessage::GetDataIterator(const Message* msg) { - void* iter = const_cast<char*>(msg->payload()); - UpdateIter(&iter, kSyncMessageHeaderSize); - return iter; +PickleIterator SyncMessage::GetDataIterator(const Message* msg) { + PickleIterator iter(*msg); + if (!iter.SkipBytes(kSyncMessageHeaderSize)) + return PickleIterator(); + else + return iter; } int SyncMessage::GetMessageId(const Message& msg) { @@ -110,7 +112,7 @@ Message* SyncMessage::GenerateReply(const Message* msg) { bool SyncMessage::ReadSyncHeader(const Message& msg, SyncHeader* header) { DCHECK(msg.is_sync() || msg.is_reply()); - void* iter = NULL; + PickleIterator iter(msg); bool result = msg.ReadInt(&iter, &header->message_id); if (!result) { NOTREACHED(); diff --git a/ipc/ipc_sync_message.h b/ipc/ipc_sync_message.h index 087df0d..17a7324 100644 --- a/ipc/ipc_sync_message.h +++ b/ipc/ipc_sync_message.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -61,7 +61,7 @@ class IPC_EXPORT SyncMessage : public Message { // Given a reply message, returns an iterator to the beginning of the data // (i.e. skips over the synchronous specific data). - static void* GetDataIterator(const Message* msg); + static PickleIterator GetDataIterator(const Message* msg); // Given a synchronous message (or its reply), returns its id. static int GetMessageId(const Message& msg); @@ -90,7 +90,8 @@ class IPC_EXPORT MessageReplyDeserializer { private: // Derived classes need to implement this, using the given iterator (which // is skipped past the header for synchronous messages). - virtual bool SerializeOutputParameters(const Message& msg, void* iter) = 0; + virtual bool SerializeOutputParameters(const Message& msg, + PickleIterator iter) = 0; }; // When sending a synchronous message, this structure contains an object diff --git a/ipc/ipc_tests.cc b/ipc/ipc_tests.cc index 8b22fc3..14259fa 100644 --- a/ipc/ipc_tests.cc +++ b/ipc/ipc_tests.cc @@ -140,7 +140,7 @@ TEST_F(IPCChannelTest, BasicMessageTest) { EXPECT_TRUE(m.WriteString(v2)); EXPECT_TRUE(m.WriteWString(v3)); - void* iter = NULL; + PickleIterator iter(m); int vi; std::string vs; diff --git a/ipc/param_traits_macros.h b/ipc/param_traits_macros.h index 05ce403..58e74f6 100644 --- a/ipc/param_traits_macros.h +++ b/ipc/param_traits_macros.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -14,7 +14,7 @@ struct IPC_MESSAGE_EXPORT ParamTraits<struct_name> { \ typedef struct_name param_type; \ static void Write(Message* m, const param_type& p); \ - static bool Read(const Message* m, void** iter, param_type* p); \ + static bool Read(const Message* m, PickleIterator* iter, param_type* p); \ static void Log(const param_type& p, std::string* l); \ }; \ } @@ -30,7 +30,7 @@ struct IPC_MESSAGE_EXPORT ParamTraits<enum_name> { \ typedef enum_name param_type; \ static void Write(Message* m, const param_type& p); \ - static bool Read(const Message* m, void** iter, param_type* p); \ + static bool Read(const Message* m, PickleIterator* iter, param_type* p); \ static void Log(const param_type& p, std::string* l); \ }; \ } diff --git a/ipc/param_traits_read_macros.h b/ipc/param_traits_read_macros.h index a78c880..9d89a92 100644 --- a/ipc/param_traits_read_macros.h +++ b/ipc/param_traits_read_macros.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -27,7 +27,7 @@ #undef IPC_STRUCT_TRAITS_END #define IPC_STRUCT_TRAITS_BEGIN(struct_name) \ bool ParamTraits<struct_name>:: \ - Read(const Message* m, void** iter, param_type* p) { \ + Read(const Message* m, PickleIterator* iter, param_type* p) { \ return #define IPC_STRUCT_TRAITS_MEMBER(name) ReadParam(m, iter, &p->name) && #define IPC_STRUCT_TRAITS_PARENT(type) ParamTraits<type>::Read(m, iter, p) && @@ -36,7 +36,7 @@ #undef IPC_ENUM_TRAITS #define IPC_ENUM_TRAITS(enum_name) \ bool ParamTraits<enum_name>:: \ - Read(const Message* m, void** iter, param_type* p) { \ + Read(const Message* m, PickleIterator* iter, param_type* p) { \ int type; \ if (!m->ReadInt(iter, &type)) \ return false; \ diff --git a/net/base/x509_certificate.cc b/net/base/x509_certificate.cc index 0a301e0..cb9b798 100644 --- a/net/base/x509_certificate.cc +++ b/net/base/x509_certificate.cc @@ -324,7 +324,7 @@ X509Certificate* X509Certificate::CreateFromBytes(const char* data, // static X509Certificate* X509Certificate::CreateFromPickle(const Pickle& pickle, - void** pickle_iter, + PickleIterator* pickle_iter, PickleType type) { OSCertHandle cert_handle = ReadOSCertHandleFromPickle(pickle, pickle_iter); if (!cert_handle) diff --git a/net/base/x509_certificate.h b/net/base/x509_certificate.h index 0a603b1..9e00e71 100644 --- a/net/base/x509_certificate.h +++ b/net/base/x509_certificate.h @@ -37,6 +37,7 @@ struct CERTCertificateStr; #endif class Pickle; +class PickleIterator; namespace crypto { class RSAPrivateKey; @@ -181,7 +182,7 @@ class NET_EXPORT X509Certificate // // The returned pointer must be stored in a scoped_refptr<X509Certificate>. static X509Certificate* CreateFromPickle(const Pickle& pickle, - void** pickle_iter, + PickleIterator* pickle_iter, PickleType type); // Parses all of the certificates possible from |data|. |format| is a @@ -554,7 +555,7 @@ class NET_EXPORT X509Certificate // libraries, nor acceptable to CreateFromBytes(). Returns an invalid // handle, NULL, on failure. static OSCertHandle ReadOSCertHandleFromPickle(const Pickle& pickle, - void** pickle_iter); + PickleIterator* pickle_iter); // Writes a single certificate to |pickle|. Returns false on failure. static bool WriteOSCertHandleToPickle(OSCertHandle handle, Pickle* pickle); diff --git a/net/base/x509_certificate_mac.cc b/net/base/x509_certificate_mac.cc index 8541973..afd622f 100644 --- a/net/base/x509_certificate_mac.cc +++ b/net/base/x509_certificate_mac.cc @@ -1565,7 +1565,7 @@ CFArrayRef X509Certificate::CreateOSCertChainForCert() const { // static X509Certificate::OSCertHandle X509Certificate::ReadOSCertHandleFromPickle(const Pickle& pickle, - void** pickle_iter) { + PickleIterator* pickle_iter) { const char* data; int length; if (!pickle.ReadData(pickle_iter, &data, &length)) diff --git a/net/base/x509_certificate_nss.cc b/net/base/x509_certificate_nss.cc index bc72304..edded15 100644 --- a/net/base/x509_certificate_nss.cc +++ b/net/base/x509_certificate_nss.cc @@ -1146,7 +1146,7 @@ SHA1Fingerprint X509Certificate::CalculateCAFingerprint( // static X509Certificate::OSCertHandle X509Certificate::ReadOSCertHandleFromPickle(const Pickle& pickle, - void** pickle_iter) { + PickleIterator* pickle_iter) { const char* data; int length; if (!pickle.ReadData(pickle_iter, &data, &length)) diff --git a/net/base/x509_certificate_openssl.cc b/net/base/x509_certificate_openssl.cc index 3efb989..6eef06e 100644 --- a/net/base/x509_certificate_openssl.cc +++ b/net/base/x509_certificate_openssl.cc @@ -650,7 +650,7 @@ bool X509Certificate::IsSameOSCert(X509Certificate::OSCertHandle a, // static X509Certificate::OSCertHandle X509Certificate::ReadOSCertHandleFromPickle(const Pickle& pickle, - void** pickle_iter) { + PickleIterator* pickle_iter) { const char* data; int length; if (!pickle.ReadData(pickle_iter, &data, &length)) diff --git a/net/base/x509_certificate_unittest.cc b/net/base/x509_certificate_unittest.cc index 7e25cbb..a69df0a 100644 --- a/net/base/x509_certificate_unittest.cc +++ b/net/base/x509_certificate_unittest.cc @@ -1026,7 +1026,7 @@ TEST(X509CertificateTest, Pickle) { Pickle pickle; cert->Persist(&pickle); - void* iter = NULL; + PickleIterator iter(pickle); scoped_refptr<X509Certificate> cert_from_pickle = X509Certificate::CreateFromPickle( pickle, &iter, X509Certificate::PICKLETYPE_CERTIFICATE_CHAIN); diff --git a/net/base/x509_certificate_win.cc b/net/base/x509_certificate_win.cc index 3c80457..a6b186e 100644 --- a/net/base/x509_certificate_win.cc +++ b/net/base/x509_certificate_win.cc @@ -1061,7 +1061,7 @@ SHA1Fingerprint X509Certificate::CalculateCAFingerprint( // static X509Certificate::OSCertHandle X509Certificate::ReadOSCertHandleFromPickle(const Pickle& pickle, - void** pickle_iter) { + PickleIterator* pickle_iter) { const char* data; int length; if (!pickle.ReadData(pickle_iter, &data, &length)) diff --git a/net/http/http_response_headers.cc b/net/http/http_response_headers.cc index 4916498..33d78da 100644 --- a/net/http/http_response_headers.cc +++ b/net/http/http_response_headers.cc @@ -169,7 +169,8 @@ HttpResponseHeaders::HttpResponseHeaders(const std::string& raw_input) GetAllHttpResponseCodes()); } -HttpResponseHeaders::HttpResponseHeaders(const Pickle& pickle, void** iter) +HttpResponseHeaders::HttpResponseHeaders(const Pickle& pickle, + PickleIterator* iter) : response_code_(-1) { std::string raw_input; if (pickle.ReadString(iter, &raw_input)) diff --git a/net/http/http_response_headers.h b/net/http/http_response_headers.h index 0ab162e..6fbc0bb 100644 --- a/net/http/http_response_headers.h +++ b/net/http/http_response_headers.h @@ -16,6 +16,7 @@ #include "net/http/http_version.h" class Pickle; +class PickleIterator; namespace base { class Time; @@ -52,7 +53,7 @@ class NET_EXPORT HttpResponseHeaders // Initializes from the representation stored in the given pickle. The data // for this object is found relative to the given pickle_iter, which should // be passed to the pickle's various Read* methods. - HttpResponseHeaders(const Pickle& pickle, void** pickle_iter); + HttpResponseHeaders(const Pickle& pickle, PickleIterator* pickle_iter); // Appends a representation of this object to the given pickle. // The options argument can be a combination of PersistOptions. diff --git a/net/http/http_response_headers_unittest.cc b/net/http/http_response_headers_unittest.cc index 775946c..f7c5e6f5 100644 --- a/net/http/http_response_headers_unittest.cc +++ b/net/http/http_response_headers_unittest.cc @@ -475,7 +475,7 @@ TEST(HttpResponseHeadersTest, Persist) { Pickle pickle; parsed1->Persist(&pickle, tests[i].options); - void* iter = NULL; + PickleIterator iter(pickle); scoped_refptr<net::HttpResponseHeaders> parsed2( new net::HttpResponseHeaders(pickle, &iter)); diff --git a/net/http/http_response_info.cc b/net/http/http_response_info.cc index 951e2b6..542bdb0 100644 --- a/net/http/http_response_info.cc +++ b/net/http/http_response_info.cc @@ -116,7 +116,7 @@ HttpResponseInfo& HttpResponseInfo::operator=(const HttpResponseInfo& rhs) { bool HttpResponseInfo::InitFromPickle(const Pickle& pickle, bool* response_truncated) { - void* iter = NULL; + PickleIterator iter(pickle); // read flags and verify version int flags; diff --git a/net/http/http_vary_data.cc b/net/http/http_vary_data.cc index 882dc78..c716ca0 100644 --- a/net/http/http_vary_data.cc +++ b/net/http/http_vary_data.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -64,7 +64,7 @@ bool HttpVaryData::Init(const HttpRequestInfo& request_info, return is_valid_ = true; } -bool HttpVaryData::InitFromPickle(const Pickle& pickle, void** iter) { +bool HttpVaryData::InitFromPickle(const Pickle& pickle, PickleIterator* iter) { is_valid_ = false; const char* data; if (pickle.ReadBytes(iter, &data, sizeof(request_digest_))) { diff --git a/net/http/http_vary_data.h b/net/http/http_vary_data.h index baa4d88..4e7a542 100644 --- a/net/http/http_vary_data.h +++ b/net/http/http_vary_data.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -10,6 +10,7 @@ #include "net/base/net_export.h" class Pickle; +class PickleIterator; namespace net { @@ -52,7 +53,7 @@ class NET_EXPORT_PRIVATE HttpVaryData { // is_valid() will return true. Otherwise, false is returned to indicate // that this object is marked as invalid. // - bool InitFromPickle(const Pickle& pickle, void** pickle_iter); + bool InitFromPickle(const Pickle& pickle, PickleIterator* pickle_iter); // Call this method to persist the vary data. Illegal to call this on an // invalid object. diff --git a/net/socket/ssl_host_info.cc b/net/socket/ssl_host_info.cc index bc4a43e..f4edcc6 100644 --- a/net/socket/ssl_host_info.cc +++ b/net/socket/ssl_host_info.cc @@ -64,7 +64,7 @@ bool SSLHostInfo::ParseInner(const std::string& data) { State* state = mutable_state(); Pickle p(data.data(), data.size()); - void* iter = NULL; + PickleIterator iter(p); int num_der_certs; if (!p.ReadInt(&iter, &num_der_certs) || diff --git a/ppapi/proxy/ppapi_param_traits.cc b/ppapi/proxy/ppapi_param_traits.cc index 484cb9b..7c13710 100644 --- a/ppapi/proxy/ppapi_param_traits.cc +++ b/ppapi/proxy/ppapi_param_traits.cc @@ -39,7 +39,7 @@ namespace { // add it to the vector one at a time. template<typename T> bool ReadVectorWithoutCopy(const Message* m, - void** iter, + PickleIterator* iter, std::vector<T>* output) { // This part is just a copy of the the default ParamTraits vector Read(). int size; @@ -81,7 +81,9 @@ void ParamTraits<PP_Bool>::Write(Message* m, const param_type& p) { } // static -bool ParamTraits<PP_Bool>::Read(const Message* m, void** iter, param_type* r) { +bool ParamTraits<PP_Bool>::Read(const Message* m, + PickleIterator* iter, + param_type* r) { // We specifically want to be strict here about what types of input we accept, // which ParamTraits<bool> does for us. We don't want to deserialize "2" into // a PP_Bool, for example. @@ -109,7 +111,7 @@ void ParamTraits<PP_FileInfo>::Write(Message* m, const param_type& p) { } // static -bool ParamTraits<PP_FileInfo>::Read(const Message* m, void** iter, +bool ParamTraits<PP_FileInfo>::Read(const Message* m, PickleIterator* iter, param_type* r) { int type, system_type; if (!ParamTraits<int64_t>::Read(m, iter, &r->size) || @@ -148,7 +150,7 @@ void ParamTraits<PP_NetAddress_Private>::Write(Message* m, // static bool ParamTraits<PP_NetAddress_Private>::Read(const Message* m, - void** iter, + PickleIterator* iter, param_type* p) { uint16 size; if (!ReadParam(m, iter, &size)) @@ -181,7 +183,7 @@ void ParamTraits<PP_ObjectProperty>::Write(Message* m, const param_type& p) { // static bool ParamTraits<PP_ObjectProperty>::Read(const Message* m, - void** iter, + PickleIterator* iter, param_type* r) { // FIXME(brettw); return true; @@ -220,7 +222,7 @@ void ParamTraits<ppapi::proxy::PPBFlash_DrawGlyphs_Params>::Write( // static bool ParamTraits<ppapi::proxy::PPBFlash_DrawGlyphs_Params>::Read( const Message* m, - void** iter, + PickleIterator* iter, param_type* r) { return ParamTraits<PP_Instance>::Read(m, iter, &r->instance) && @@ -265,7 +267,7 @@ void ParamTraits<ppapi::PPB_FileRef_CreateInfo>::Write(Message* m, // static bool ParamTraits<ppapi::PPB_FileRef_CreateInfo>::Read(const Message* m, - void** iter, + PickleIterator* iter, param_type* r) { return ParamTraits<ppapi::HostResource>::Read(m, iter, &r->resource) && @@ -296,7 +298,7 @@ void ParamTraits<ppapi::proxy::PPBURLLoader_UpdateProgress_Params>::Write( // static bool ParamTraits<ppapi::proxy::PPBURLLoader_UpdateProgress_Params>::Read( const Message* m, - void** iter, + PickleIterator* iter, param_type* r) { return ParamTraits<PP_Instance>::Read(m, iter, &r->instance) && @@ -324,7 +326,7 @@ void ParamTraits<ppapi::proxy::SerializedDirEntry>::Write(Message* m, // static bool ParamTraits<ppapi::proxy::SerializedDirEntry>::Read(const Message* m, - void** iter, + PickleIterator* iter, param_type* r) { return ParamTraits<std::string>::Read(m, iter, &r->name) && ParamTraits<bool>::Read(m, iter, &r->is_dir); @@ -354,7 +356,7 @@ void ParamTraits<ppapi::proxy::SerializedFontDescription>::Write( // static bool ParamTraits<ppapi::proxy::SerializedFontDescription>::Read( const Message* m, - void** iter, + PickleIterator* iter, param_type* r) { return ParamTraits<ppapi::proxy::SerializedVar>::Read(m, iter, &r->face) && @@ -384,7 +386,7 @@ void ParamTraits<ppapi::HostResource>::Write(Message* m, // static bool ParamTraits<ppapi::HostResource>::Read(const Message* m, - void** iter, + PickleIterator* iter, param_type* r) { PP_Instance instance; PP_Resource resource; @@ -410,7 +412,7 @@ void ParamTraits<ppapi::proxy::SerializedVar>::Write(Message* m, // static bool ParamTraits<ppapi::proxy::SerializedVar>::Read(const Message* m, - void** iter, + PickleIterator* iter, param_type* r) { return r->ReadFromMessage(m, iter); } @@ -431,7 +433,7 @@ void ParamTraits< std::vector<ppapi::proxy::SerializedVar> >::Write( // static bool ParamTraits< std::vector<ppapi::proxy::SerializedVar> >::Read( const Message* m, - void** iter, + PickleIterator* iter, param_type* r) { return ReadVectorWithoutCopy(m, iter, r); } @@ -453,7 +455,7 @@ void ParamTraits< std::vector<ppapi::PPB_FileRef_CreateInfo> >::Write( // static bool ParamTraits< std::vector<ppapi::PPB_FileRef_CreateInfo> >::Read( const Message* m, - void** iter, + PickleIterator* iter, param_type* r) { return ReadVectorWithoutCopy(m, iter, r); } @@ -475,7 +477,7 @@ void ParamTraits<ppapi::proxy::SerializedFlashMenu>::Write( // static bool ParamTraits<ppapi::proxy::SerializedFlashMenu>::Read(const Message* m, - void** iter, + PickleIterator* iter, param_type* r) { return r->ReadFromMessage(m, iter); } diff --git a/ppapi/proxy/ppapi_param_traits.h b/ppapi/proxy/ppapi_param_traits.h index 63121f0..40e4e5b 100644 --- a/ppapi/proxy/ppapi_param_traits.h +++ b/ppapi/proxy/ppapi_param_traits.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -42,7 +42,7 @@ template<> struct ParamTraits<PP_Bool> { typedef PP_Bool param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -50,7 +50,7 @@ template<> struct ParamTraits<PP_FileInfo> { typedef PP_FileInfo param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -58,7 +58,7 @@ template <> struct PPAPI_PROXY_EXPORT ParamTraits<PP_NetAddress_Private> { typedef PP_NetAddress_Private param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* p); + static bool Read(const Message* m, PickleIterator* iter, param_type* p); static void Log(const param_type& p, std::string* l); }; @@ -66,7 +66,7 @@ template<> struct ParamTraits<PP_ObjectProperty> { typedef PP_ObjectProperty param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -74,7 +74,7 @@ template<> struct ParamTraits<ppapi::proxy::PPBFlash_DrawGlyphs_Params> { typedef ppapi::proxy::PPBFlash_DrawGlyphs_Params param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -82,7 +82,7 @@ template<> struct ParamTraits<ppapi::PPB_FileRef_CreateInfo> { typedef ppapi::PPB_FileRef_CreateInfo param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -90,7 +90,7 @@ template<> struct ParamTraits<ppapi::proxy::PPBURLLoader_UpdateProgress_Params> { typedef ppapi::proxy::PPBURLLoader_UpdateProgress_Params param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -98,7 +98,7 @@ template<> struct ParamTraits<ppapi::proxy::SerializedDirEntry> { typedef ppapi::proxy::SerializedDirEntry param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -106,7 +106,7 @@ template<> struct ParamTraits<ppapi::proxy::SerializedFontDescription> { typedef ppapi::proxy::SerializedFontDescription param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -114,7 +114,7 @@ template<> struct ParamTraits<ppapi::HostResource> { typedef ppapi::HostResource param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -122,7 +122,7 @@ template<> struct ParamTraits<ppapi::proxy::SerializedVar> { typedef ppapi::proxy::SerializedVar param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -130,7 +130,7 @@ template<> struct ParamTraits< std::vector<ppapi::proxy::SerializedVar> > { typedef std::vector<ppapi::proxy::SerializedVar> param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -138,7 +138,7 @@ template<> struct ParamTraits< std::vector<ppapi::PPB_FileRef_CreateInfo> > { typedef std::vector<ppapi::PPB_FileRef_CreateInfo> param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -146,7 +146,7 @@ template<> struct ParamTraits<ppapi::proxy::SerializedFlashMenu> { typedef ppapi::proxy::SerializedFlashMenu param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; diff --git a/ppapi/proxy/serialized_flash_menu.cc b/ppapi/proxy/serialized_flash_menu.cc index c29f9c1..2784485 100644 --- a/ppapi/proxy/serialized_flash_menu.cc +++ b/ppapi/proxy/serialized_flash_menu.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -19,7 +19,7 @@ const int kMaxMenuDepth = 2; bool CheckMenu(int depth, const PP_Flash_Menu* menu); void FreeMenu(const PP_Flash_Menu* menu); void WriteMenu(IPC::Message* m, const PP_Flash_Menu* menu); -PP_Flash_Menu* ReadMenu(int depth, const IPC::Message* m, void** iter); +PP_Flash_Menu* ReadMenu(int depth, const IPC::Message* m, PickleIterator* iter); bool CheckMenuItem(int depth, const PP_Flash_MenuItem* item) { if (item->type == PP_FLASH_MENUITEM_TYPE_SUBMENU) @@ -77,7 +77,7 @@ void FreeMenu(const PP_Flash_Menu* menu) { bool ReadMenuItem(int depth, const IPC::Message* m, - void** iter, + PickleIterator* iter, PP_Flash_MenuItem* menu_item) { uint32_t type; if (!m->ReadUInt32(iter, &type)) @@ -105,7 +105,9 @@ bool ReadMenuItem(int depth, return true; } -PP_Flash_Menu* ReadMenu(int depth, const IPC::Message* m, void** iter) { +PP_Flash_Menu* ReadMenu(int depth, + const IPC::Message* m, + PickleIterator* iter) { if (depth > kMaxMenuDepth) return NULL; ++depth; @@ -158,7 +160,8 @@ void SerializedFlashMenu::WriteToMessage(IPC::Message* m) const { WriteMenu(m, pp_menu_); } -bool SerializedFlashMenu::ReadFromMessage(const IPC::Message* m, void** iter) { +bool SerializedFlashMenu::ReadFromMessage(const IPC::Message* m, + PickleIterator* iter) { DCHECK(!pp_menu_); pp_menu_ = ReadMenu(0, m, iter); if (!pp_menu_) diff --git a/ppapi/proxy/serialized_flash_menu.h b/ppapi/proxy/serialized_flash_menu.h index 4be22bf..f7ad6b6 100644 --- a/ppapi/proxy/serialized_flash_menu.h +++ b/ppapi/proxy/serialized_flash_menu.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -12,6 +12,8 @@ #include "base/memory/scoped_ptr.h" #include "ppapi/proxy/ppapi_proxy_export.h" +class PickleIterator; + struct PP_Flash_Menu; namespace IPC { @@ -31,7 +33,7 @@ class PPAPI_PROXY_EXPORT SerializedFlashMenu { const PP_Flash_Menu* pp_menu() const { return pp_menu_; } void WriteToMessage(IPC::Message* m) const; - bool ReadFromMessage(const IPC::Message* m, void** iter); + bool ReadFromMessage(const IPC::Message* m, PickleIterator* iter); private: const PP_Flash_Menu* pp_menu_; diff --git a/ppapi/proxy/serialized_var.cc b/ppapi/proxy/serialized_var.cc index eb20333..7b2a8e3 100644 --- a/ppapi/proxy/serialized_var.cc +++ b/ppapi/proxy/serialized_var.cc @@ -147,7 +147,8 @@ void SerializedVar::Inner::WriteToMessage(IPC::Message* m) const { } } -bool SerializedVar::Inner::ReadFromMessage(const IPC::Message* m, void** iter) { +bool SerializedVar::Inner::ReadFromMessage(const IPC::Message* m, + PickleIterator* iter) { #ifndef NDEBUG // We should only deserialize something once or will end up with leaked // references. diff --git a/ppapi/proxy/serialized_var.h b/ppapi/proxy/serialized_var.h index 28b7c8b..ffcf0da 100644 --- a/ppapi/proxy/serialized_var.h +++ b/ppapi/proxy/serialized_var.h @@ -14,6 +14,8 @@ #include "ppapi/c/pp_var.h" #include "ppapi/proxy/ppapi_proxy_export.h" +class PickleIterator; + namespace IPC { class Message; } @@ -72,7 +74,7 @@ class PPAPI_PROXY_EXPORT SerializedVar { void WriteToMessage(IPC::Message* m) const { inner_->WriteToMessage(m); } - bool ReadFromMessage(const IPC::Message* m, void** iter) { + bool ReadFromMessage(const IPC::Message* m, PickleIterator* iter) { return inner_->ReadFromMessage(m, iter); } @@ -106,7 +108,7 @@ class PPAPI_PROXY_EXPORT SerializedVar { void ForceSetVarValueForTest(PP_Var value); void WriteToMessage(IPC::Message* m) const; - bool ReadFromMessage(const IPC::Message* m, void** iter); + bool ReadFromMessage(const IPC::Message* m, PickleIterator* iter); // Sets the cleanup mode. See the CleanupMode enum below. These functions // are not just a simple setter in order to require that the appropriate diff --git a/ui/base/clipboard/clipboard_unittest.cc b/ui/base/clipboard/clipboard_unittest.cc index f00d4fd..c586d51 100644 --- a/ui/base/clipboard/clipboard_unittest.cc +++ b/ui/base/clipboard/clipboard_unittest.cc @@ -445,7 +445,7 @@ TEST_F(ClipboardTest, DataTest) { ASSERT_FALSE(output.empty()); Pickle read_pickle(output.data(), output.size()); - void* iter = NULL; + PickleIterator iter(read_pickle); std::string unpickled_string; ASSERT_TRUE(read_pickle.ReadString(&iter, &unpickled_string)); EXPECT_EQ(payload, unpickled_string); @@ -482,7 +482,7 @@ TEST_F(ClipboardTest, MultipleDataTest) { ASSERT_FALSE(output2.empty()); Pickle read_pickle2(output2.data(), output2.size()); - void* iter2 = NULL; + PickleIterator iter2(read_pickle2); std::string unpickled_string2; ASSERT_TRUE(read_pickle2.ReadString(&iter2, &unpickled_string2)); EXPECT_EQ(payload2, unpickled_string2); @@ -504,7 +504,7 @@ TEST_F(ClipboardTest, MultipleDataTest) { ASSERT_FALSE(output1.empty()); Pickle read_pickle1(output1.data(), output1.size()); - void* iter1 = NULL; + PickleIterator iter1(read_pickle1); std::string unpickled_string1; ASSERT_TRUE(read_pickle1.ReadString(&iter1, &unpickled_string1)); EXPECT_EQ(payload1, unpickled_string1); diff --git a/ui/base/clipboard/custom_data_helper.cc b/ui/base/clipboard/custom_data_helper.cc index 88abf0f..5200de8 100644 --- a/ui/base/clipboard/custom_data_helper.cc +++ b/ui/base/clipboard/custom_data_helper.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -19,24 +19,20 @@ namespace { class SkippablePickle : public Pickle { public: SkippablePickle(const void* data, size_t data_len); - bool SkipString16(void** iter); + bool SkipString16(PickleIterator* iter); }; SkippablePickle::SkippablePickle(const void* data, size_t data_len) : Pickle(reinterpret_cast<const char*>(data), data_len) { } -bool SkippablePickle::SkipString16(void** iter) { +bool SkippablePickle::SkipString16(PickleIterator* iter) { DCHECK(iter); int len; if (!ReadLength(iter, &len)) return false; - if (!IteratorHasRoomFor(*iter, len * sizeof(char16))) - return false; - - UpdateIter(iter, len * sizeof(char16)); - return true; + return iter->SkipBytes(len * sizeof(char16)); } } // namespace @@ -45,7 +41,7 @@ void ReadCustomDataTypes(const void* data, size_t data_length, std::vector<string16>* types) { SkippablePickle pickle(data, data_length); - void* iter = NULL; + PickleIterator iter(pickle); size_t size = 0; if (!pickle.ReadSize(&iter, &size)) @@ -71,7 +67,7 @@ void ReadCustomDataForType(const void* data, const string16& type, string16* result) { SkippablePickle pickle(data, data_length); - void* iter = NULL; + PickleIterator iter(pickle); size_t size = 0; if (!pickle.ReadSize(&iter, &size)) @@ -94,7 +90,7 @@ void ReadCustomDataIntoMap(const void* data, size_t data_length, std::map<string16, string16>* result) { Pickle pickle(reinterpret_cast<const char*>(data), data_length); - void* iter = NULL; + PickleIterator iter(pickle); size_t size = 0; if (!pickle.ReadSize(&iter, &size)) diff --git a/ui/base/dragdrop/gtk_dnd_util.cc b/ui/base/dragdrop/gtk_dnd_util.cc index d70aac8..71d6923 100644 --- a/ui/base/dragdrop/gtk_dnd_util.cc +++ b/ui/base/dragdrop/gtk_dnd_util.cc @@ -216,7 +216,7 @@ bool ExtractNamedURL(GtkSelectionData* selection_data, reinterpret_cast<const char*>( gtk_selection_data_get_data(selection_data)), gtk_selection_data_get_length(selection_data)); - void* iter = NULL; + PickleIterator iter(data); std::string title_utf8, url_utf8; if (!data.ReadString(&iter, &title_utf8) || !data.ReadString(&iter, &url_utf8)) { diff --git a/ui/base/dragdrop/os_exchange_data_win_unittest.cc b/ui/base/dragdrop/os_exchange_data_win_unittest.cc index 42b5daf..abc67c7 100644 --- a/ui/base/dragdrop/os_exchange_data_win_unittest.cc +++ b/ui/base/dragdrop/os_exchange_data_win_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -350,11 +350,11 @@ TEST(OSExchangeDataTest, TestPickledData) { Pickle restored_pickle; EXPECT_TRUE(copy.GetPickledData(test_cf, &restored_pickle)); - void* p_iterator = NULL; + PickleIterator iterator(restored_pickle); int value; - EXPECT_TRUE(restored_pickle.ReadInt(&p_iterator, &value)); + EXPECT_TRUE(restored_pickle.ReadInt(&iterator, &value)); EXPECT_EQ(1, value); - EXPECT_TRUE(restored_pickle.ReadInt(&p_iterator, &value)); + EXPECT_TRUE(restored_pickle.ReadInt(&iterator, &value)); EXPECT_EQ(2, value); } diff --git a/webkit/fileapi/file_system_directory_database.cc b/webkit/fileapi/file_system_directory_database.cc index 88152e2..217b98f 100644 --- a/webkit/fileapi/file_system_directory_database.cc +++ b/webkit/fileapi/file_system_directory_database.cc @@ -47,7 +47,7 @@ bool PickleFromFileInfo( bool FileInfoFromPickle( const Pickle& pickle, fileapi::FileSystemDirectoryDatabase::FileInfo* info) { - void* iter = NULL; + PickleIterator iter(pickle); std::string data_path; std::string name; int64 internal_time; diff --git a/webkit/fileapi/file_system_usage_cache.cc b/webkit/fileapi/file_system_usage_cache.cc index 46bbdff..18d13c7 100644 --- a/webkit/fileapi/file_system_usage_cache.cc +++ b/webkit/fileapi/file_system_usage_cache.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -131,7 +131,7 @@ int64 FileSystemUsageCache::Read(const FilePath& usage_file_path, file_util::ReadFile(usage_file_path, buffer, kUsageFileSize)) return -1; Pickle read_pickle(buffer, kUsageFileSize); - void* iter = NULL; + PickleIterator iter(read_pickle); int64 fs_usage; if (!read_pickle.ReadBytes(&iter, &header, kUsageFileHeaderSize) || diff --git a/webkit/glue/glue_serialize.cc b/webkit/glue/glue_serialize.cc index 04a4ac4..606ff61 100644 --- a/webkit/glue/glue_serialize.cc +++ b/webkit/glue/glue_serialize.cc @@ -32,16 +32,16 @@ namespace webkit_glue { namespace { struct SerializeObject { - SerializeObject() : iter(NULL), version(0) {} + SerializeObject() : version(0) {} SerializeObject(const char* data, int len) - : pickle(data, len), iter(NULL), version(0) {} + : pickle(data, len), version(0) { iter = PickleIterator(pickle); } std::string GetAsString() { return std::string(static_cast<const char*>(pickle.data()), pickle.size()); } Pickle pickle; - mutable void* iter; + mutable PickleIterator iter; mutable int version; }; diff --git a/webkit/glue/npruntime_util.cc b/webkit/glue/npruntime_util.cc index a408770e..4c448ae 100644 --- a/webkit/glue/npruntime_util.cc +++ b/webkit/glue/npruntime_util.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -26,22 +26,22 @@ bool SerializeNPIdentifier(NPIdentifier identifier, Pickle* pickle) { return pickle->WriteInt(number); } -bool DeserializeNPIdentifier(const Pickle& pickle, void** pickle_iter, +bool DeserializeNPIdentifier(PickleIterator* pickle_iter, NPIdentifier* identifier) { bool is_string; - if (!pickle.ReadBool(pickle_iter, &is_string)) + if (!pickle_iter->ReadBool(&is_string)) return false; if (is_string) { const char* data; int data_len; - if (!pickle.ReadData(pickle_iter, &data, &data_len)) + if (!pickle_iter->ReadData(&data, &data_len)) return false; DCHECK_EQ((static_cast<size_t>(data_len)), strlen(data) + 1); *identifier = WebBindings::getStringIdentifier(data); } else { int number; - if (!pickle.ReadInt(pickle_iter, &number)) + if (!pickle_iter->ReadInt(&number)) return false; *identifier = WebBindings::getIntIdentifier(number); } diff --git a/webkit/glue/npruntime_util.h b/webkit/glue/npruntime_util.h index 586aab1..401f771 100644 --- a/webkit/glue/npruntime_util.h +++ b/webkit/glue/npruntime_util.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,14 +9,14 @@ #include "webkit/glue/webkit_glue_export.h" class Pickle; +class PickleIterator; namespace webkit_glue { // Efficiently serialize/deserialize a NPIdentifier WEBKIT_GLUE_EXPORT bool SerializeNPIdentifier(NPIdentifier identifier, Pickle* pickle); -WEBKIT_GLUE_EXPORT bool DeserializeNPIdentifier(const Pickle& pickle, - void** pickle_iter, +WEBKIT_GLUE_EXPORT bool DeserializeNPIdentifier(PickleIterator* pickle_iter, NPIdentifier* identifier); } // namespace webkit_glue diff --git a/webkit/glue/webcursor.cc b/webkit/glue/webcursor.cc index 292ca0d..94c2781 100644 --- a/webkit/glue/webcursor.cc +++ b/webkit/glue/webcursor.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -70,18 +70,18 @@ void WebCursor::GetCursorInfo(WebCursorInfo* cursor_info) const { #endif } -bool WebCursor::Deserialize(const Pickle* pickle, void** iter) { +bool WebCursor::Deserialize(PickleIterator* iter) { int type, hotspot_x, hotspot_y, size_x, size_y, data_len; const char* data; // Leave |this| unmodified unless we are going to return success. - if (!pickle->ReadInt(iter, &type) || - !pickle->ReadInt(iter, &hotspot_x) || - !pickle->ReadInt(iter, &hotspot_y) || - !pickle->ReadLength(iter, &size_x) || - !pickle->ReadLength(iter, &size_y) || - !pickle->ReadData(iter, &data, &data_len)) + if (!iter->ReadInt(&type) || + !iter->ReadInt(&hotspot_x) || + !iter->ReadInt(&hotspot_y) || + !iter->ReadLength(&size_x) || + !iter->ReadLength(&size_y) || + !iter->ReadData(&data, &data_len)) return false; // Ensure the size is sane, and there is enough data. @@ -111,7 +111,7 @@ bool WebCursor::Deserialize(const Pickle* pickle, void** iter) { } } } - return DeserializePlatformData(pickle, iter); + return DeserializePlatformData(iter); } bool WebCursor::Serialize(Pickle* pickle) const { diff --git a/webkit/glue/webcursor.h b/webkit/glue/webcursor.h index 0461a3c..0dfddcf 100644 --- a/webkit/glue/webcursor.h +++ b/webkit/glue/webcursor.h @@ -30,6 +30,7 @@ struct Cursor; #endif class Pickle; +class PickleIterator; namespace WebKit { class WebImage; @@ -55,7 +56,7 @@ class WEBKIT_GLUE_EXPORT WebCursor { void GetCursorInfo(WebKit::WebCursorInfo* cursor_info) const; // Serialization / De-serialization - bool Deserialize(const Pickle* pickle, void** iter); + bool Deserialize(PickleIterator* iter); bool Serialize(Pickle* pickle) const; // Returns true if GetCustomCursor should be used to allocate a platform @@ -114,7 +115,7 @@ class WEBKIT_GLUE_EXPORT WebCursor { // Platform specific Serialization / De-serialization bool SerializePlatformData(Pickle* pickle) const; - bool DeserializePlatformData(const Pickle* pickle, void** iter); + bool DeserializePlatformData(PickleIterator* iter); // Returns true if the platform data in the current cursor object // matches that of the cursor passed in. diff --git a/webkit/glue/webcursor_android.cc b/webkit/glue/webcursor_android.cc index 774133b..54a8a1d 100644 --- a/webkit/glue/webcursor_android.cc +++ b/webkit/glue/webcursor_android.cc @@ -14,7 +14,7 @@ bool WebCursor::SerializePlatformData(Pickle* pickle) const { return true; } -bool WebCursor::DeserializePlatformData(const Pickle* pickle, void** iter) { +bool WebCursor::DeserializePlatformData(PickleIterator* iter) { return true; } diff --git a/webkit/glue/webcursor_aura.cc b/webkit/glue/webcursor_aura.cc index 7610aff..08719c1 100644 --- a/webkit/glue/webcursor_aura.cc +++ b/webkit/glue/webcursor_aura.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -113,7 +113,7 @@ bool WebCursor::SerializePlatformData(Pickle* pickle) const { return true; } -bool WebCursor::DeserializePlatformData(const Pickle* pickle, void** iter) { +bool WebCursor::DeserializePlatformData(PickleIterator* iter) { return true; } diff --git a/webkit/glue/webcursor_gtk.cc b/webkit/glue/webcursor_gtk.cc index d46d6e2..e9b4a12 100644 --- a/webkit/glue/webcursor_gtk.cc +++ b/webkit/glue/webcursor_gtk.cc @@ -199,7 +199,7 @@ bool WebCursor::SerializePlatformData(Pickle* pickle) const { return true; } -bool WebCursor::DeserializePlatformData(const Pickle* pickle, void** iter) { +bool WebCursor::DeserializePlatformData(PickleIterator* iter) { return true; } diff --git a/webkit/glue/webcursor_mac.mm b/webkit/glue/webcursor_mac.mm index fe65480..1e72e0b 100644 --- a/webkit/glue/webcursor_mac.mm +++ b/webkit/glue/webcursor_mac.mm @@ -493,7 +493,7 @@ bool WebCursor::SerializePlatformData(Pickle* pickle) const { return true; } -bool WebCursor::DeserializePlatformData(const Pickle* pickle, void** iter) { +bool WebCursor::DeserializePlatformData(PickleIterator* iter) { return true; } diff --git a/webkit/glue/webcursor_unittest.cc b/webkit/glue/webcursor_unittest.cc index 00f2760..830905b 100644 --- a/webkit/glue/webcursor_unittest.cc +++ b/webkit/glue/webcursor_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -26,8 +26,8 @@ TEST(WebCursorTest, OKCursorSerialization) { ok_custom_pickle.WriteUInt32(0); // Custom Windows message. ok_custom_pickle.WriteUInt32(0); - void* iter = NULL; - EXPECT_TRUE(custom_cursor.Deserialize(&ok_custom_pickle, &iter)); + PickleIterator iter(ok_custom_pickle); + EXPECT_TRUE(custom_cursor.Deserialize(&iter)); #if defined(TOOLKIT_USES_GTK) // On GTK+ using platforms, we should get a real native GdkCursor object back @@ -51,8 +51,8 @@ TEST(WebCursorTest, BrokenCursorSerialization) { // Data len not including enough data for a 1x1 image. short_custom_pickle.WriteInt(3); short_custom_pickle.WriteUInt32(0); - void* iter = NULL; - EXPECT_FALSE(custom_cursor.Deserialize(&short_custom_pickle, &iter)); + PickleIterator iter(short_custom_pickle); + EXPECT_FALSE(custom_cursor.Deserialize(&iter)); // This custom cursor has enough data but is too big. Pickle large_custom_pickle; @@ -68,8 +68,8 @@ TEST(WebCursorTest, BrokenCursorSerialization) { large_custom_pickle.WriteInt(kTooBigSize * 4); for (int i = 0; i < kTooBigSize; ++i) large_custom_pickle.WriteUInt32(0); - iter = NULL; - EXPECT_FALSE(custom_cursor.Deserialize(&large_custom_pickle, &iter)); + iter = PickleIterator(large_custom_pickle); + EXPECT_FALSE(custom_cursor.Deserialize(&iter)); // This custom cursor uses negative lengths. Pickle neg_custom_pickle; @@ -85,8 +85,8 @@ TEST(WebCursorTest, BrokenCursorSerialization) { neg_custom_pickle.WriteUInt32(0); // Custom Windows message. neg_custom_pickle.WriteUInt32(0); - iter = NULL; - EXPECT_FALSE(custom_cursor.Deserialize(&neg_custom_pickle, &iter)); + iter = PickleIterator(neg_custom_pickle); + EXPECT_FALSE(custom_cursor.Deserialize(&iter)); } #if defined(OS_WIN) @@ -97,8 +97,8 @@ TEST(WebCursorTest, WindowsCursorConversion) { win32_custom_cursor.InitFromExternalCursor( reinterpret_cast<HCURSOR>(1000)); EXPECT_TRUE(win32_custom_cursor.Serialize(&win32_custom_pickle)); - void* iter = NULL; - EXPECT_TRUE(custom_cursor.Deserialize(&win32_custom_pickle, &iter)); + PickleIterator iter(win32_custom_pickle); + EXPECT_TRUE(custom_cursor.Deserialize(&iter)); EXPECT_EQ(reinterpret_cast<HCURSOR>(1000), custom_cursor.GetCursor(NULL)); } #endif // OS_WIN @@ -121,8 +121,8 @@ TEST(WebCursorTest, ClampHotspot) { ok_custom_pickle.WriteUInt32(0); // Custom Windows message. ok_custom_pickle.WriteUInt32(0); - void* iter = NULL; - ASSERT_TRUE(custom_cursor.Deserialize(&ok_custom_pickle, &iter)); + PickleIterator iter(ok_custom_pickle); + ASSERT_TRUE(custom_cursor.Deserialize(&iter)); // Convert to WebCursorInfo, make sure the hotspot got clamped. WebCursorInfo info; @@ -154,8 +154,8 @@ TEST(WebCursorTest, EmptyImage) { // Make sure we can read this on all platforms; it is technicaally a valid // cursor. - void* iter = NULL; - ASSERT_TRUE(custom_cursor.Deserialize(&broken_cursor_pickle, &iter)); + PickleIterator iter(broken_cursor_pickle); + ASSERT_TRUE(custom_cursor.Deserialize(&iter)); #if defined(TOOLKIT_USES_GTK) // On GTK+ using platforms, we make sure that we get NULL back from this diff --git a/webkit/glue/webcursor_win.cc b/webkit/glue/webcursor_win.cc index 4d8e520..9b334a8 100644 --- a/webkit/glue/webcursor_win.cc +++ b/webkit/glue/webcursor_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -216,8 +216,8 @@ bool WebCursor::SerializePlatformData(Pickle* pickle) const { return pickle->WriteUInt32(reinterpret_cast<uint32>(external_cursor_)); } -bool WebCursor::DeserializePlatformData(const Pickle* pickle, void** iter) { - return pickle->ReadUInt32(iter, reinterpret_cast<uint32*>(&external_cursor_)); +bool WebCursor::DeserializePlatformData(PickleIterator* iter) { + return iter->ReadUInt32(reinterpret_cast<uint32*>(&external_cursor_)); } bool WebCursor::IsPlatformDataEqual(const WebCursor& other) const { |