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
This commit is contained in:
base
chrome
browser
automation
bookmarks
extensions
execute_code_in_tab_function.ccextension_browser_actions_api.ccextension_messages_browsertest.ccextension_page_actions_module.ccextension_page_capture_api.ccextension_tabs_module.cc
importer
password_manager
sessions
base_session_service.cccompress_data_helper.cccompress_data_helper.hcompress_data_helper_unittest.ccsession_service.cc
ui
views
extensions
visitedlink
common
automation_messages.ccautomation_messages.hcommon_param_traits.cccommon_param_traits.hcommon_param_traits_unittest.cccontent_settings_pattern.cccontent_settings_pattern.h
extensions
extension_messages.ccextension_messages.hextension_unpacker.ccuser_script.ccuser_script.huser_script_unittest.cc
render_messages.ccrender_messages.hrenderer
extensions
test
chrome_frame
content
browser
common
child_process_sandbox_support_impl_linux.ccclipboard_messages.ccclipboard_messages.hfont_config_ipc_linux.cc
indexed_db
mac
pepper_file_messages.ccpepper_file_messages.hresource_dispatcher.ccssl_status_serialization.ccppapi_plugin
public
renderer
test
crypto
gpu/ipc
ipc
ipc_channel_posix.ccipc_fuzzing_tests.ccipc_logging.ccipc_message.ccipc_message.hipc_message_unittest.ccipc_message_utils.ccipc_message_utils.hipc_message_utils_impl.hipc_send_fds_test.ccipc_sync_message.ccipc_sync_message.hipc_tests.ccparam_traits_macros.hparam_traits_read_macros.h
net
base
x509_certificate.ccx509_certificate.hx509_certificate_mac.ccx509_certificate_nss.ccx509_certificate_openssl.ccx509_certificate_unittest.ccx509_certificate_win.cc
http
http_response_headers.cchttp_response_headers.hhttp_response_headers_unittest.cchttp_response_info.cchttp_vary_data.cchttp_vary_data.h
socket
ppapi/proxy
ppapi_param_traits.ccppapi_param_traits.hserialized_flash_menu.ccserialized_flash_menu.hserialized_var.ccserialized_var.h
ui/base
clipboard
dragdrop
webkit
@ -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
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
||||
|
342
base/pickle.cc
342
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;
|
||||
|
156
base/pickle.h
156
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__
|
||||
|
@ -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));
|
||||
int bytes = sizeof(int) * 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));
|
||||
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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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_;
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
|
@ -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()));
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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)) {
|
||||
|
@ -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.)
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
|
@ -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;
|
||||
|
@ -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_)))
|
||||
|
@ -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());
|
||||
|
@ -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))
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
|
@ -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());
|
||||
|
@ -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_);
|
||||
}
|
||||
|
@ -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_; }
|
||||
|
@ -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) &&
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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)) {
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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))
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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.";
|
||||
|
@ -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) ||
|
||||
|
@ -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) &&
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
|
@ -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";
|
||||
|
@ -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) &&
|
||||
|
@ -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();
|
||||
|
@ -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) ||
|
||||
|
@ -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);
|
||||
};
|
||||
|
@ -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) &&
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
|
@ -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))
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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() {}
|
||||
|
@ -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_));
|
||||
|
@ -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_));
|
||||
|
@ -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());
|
||||
|
||||
|
@ -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) &&
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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))
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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))
|
||||
|
@ -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
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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) &&
|
||||
|
@ -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_);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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); \
|
||||
}; \
|
||||
}
|
||||
|
@ -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; \
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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))
|
||||
|
@ -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))
|
||||
|
@ -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))
|
||||
|
@ -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);
|
||||
|
@ -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))
|
||||
|
@ -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))
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user