diff options
author | rockot <rockot@chromium.org> | 2016-02-03 12:20:16 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-03 20:21:49 +0000 |
commit | 502c94ff1a9f99b5c4ecfe700415cc4ed14228dd (patch) | |
tree | 260521d2640e580c11a54d24781ef0ebc32baee3 | |
parent | 26c9117edc07280155c69c7fab04729af46a79eb (diff) | |
download | chromium_src-502c94ff1a9f99b5c4ecfe700415cc4ed14228dd.zip chromium_src-502c94ff1a9f99b5c4ecfe700415cc4ed14228dd.tar.gz chromium_src-502c94ff1a9f99b5c4ecfe700415cc4ed14228dd.tar.bz2 |
IPC::Message -> base::Pickle
This changes consumers of IPC::Message to generally refer
refer to base::Pickle instead when performing serialization
and deserialization operations. The few specific instances
where the IPC::Message interface (Read/WriteAttachent) is
needed can safely be static_cast'd, as IPC::Message is the
only public subclass of base::Pickle.
The purpose of this change is to facilitate the transition
to Mojo IPC, as we've trained the Mojo bindings layer to
use existing ParamTraits<T> parameterized over base::Pickle.
To support this base::Pickle has had some stub interfaces
added for WriteAttachment and ReadAttachment, along with a
Pickle::Attachment.
A follow-up patch will add sizing traits to the standard
IPC_STRUCT macros, enabling the majority of Chrome IPC
structs to be carried over Mojo message pipes as-is.
BUG=577685
R=jam@chromium.org
Review URL: https://codereview.chromium.org/1659003003
Cr-Commit-Position: refs/heads/master@{#373323}
84 files changed, 1067 insertions, 808 deletions
diff --git a/base/pickle.cc b/base/pickle.cc index d83391b..8aa9f62 100644 --- a/base/pickle.cc +++ b/base/pickle.cc @@ -208,6 +208,10 @@ bool PickleIterator::ReadBytes(const char** data, int length) { return true; } +Pickle::Attachment::Attachment() {} + +Pickle::Attachment::~Attachment() {} + // Payload is uint32_t aligned. Pickle::Pickle() @@ -322,6 +326,19 @@ void Pickle::Reserve(size_t length) { Resize(capacity_after_header_ * 2 + new_size); } +bool Pickle::WriteAttachment(scoped_refptr<Attachment> attachment) { + return false; +} + +bool Pickle::ReadAttachment(base::PickleIterator* iter, + scoped_refptr<Attachment>* attachment) const { + return false; +} + +bool Pickle::HasAttachments() const { + return false; +} + void Pickle::Resize(size_t new_capacity) { CHECK_NE(capacity_after_header_, kCapacityReadOnly); capacity_after_header_ = bits::Align(new_capacity, kPayloadUnit); diff --git a/base/pickle.h b/base/pickle.h index 02bc432..e50fd68 100644 --- a/base/pickle.h +++ b/base/pickle.h @@ -14,9 +14,14 @@ #include "base/compiler_specific.h" #include "base/gtest_prod_util.h" #include "base/logging.h" +#include "base/memory/ref_counted.h" #include "base/strings/string16.h" #include "base/strings/string_piece.h" +#if defined(OS_POSIX) +#include "base/files/file.h" +#endif + namespace base { class Pickle; @@ -123,6 +128,21 @@ class BASE_EXPORT PickleIterator { // class BASE_EXPORT Pickle { public: + // Auxiliary data attached to a Pickle. Pickle must be subclassed along with + // this interface in order to provide a concrete implementation of support + // for attachments. The base Pickle implementation does not accept + // attachments. + class BASE_EXPORT Attachment : public RefCountedThreadSafe<Attachment> { + public: + Attachment(); + + protected: + friend class RefCountedThreadSafe<Attachment>; + virtual ~Attachment(); + + DISALLOW_COPY_AND_ASSIGN(Attachment); + }; + // Initialize a Pickle object using the default header size. Pickle(); @@ -206,6 +226,19 @@ class BASE_EXPORT Pickle { // known size. See also WriteData. bool WriteBytes(const void* data, int length); + // WriteAttachment appends |attachment| to the pickle. It returns + // false iff the set is full or if the Pickle implementation does not support + // attachments. + virtual bool WriteAttachment(scoped_refptr<Attachment> attachment); + + // ReadAttachment parses an attachment given the parsing state |iter| and + // writes it to |*attachment|. It returns true on success. + virtual bool ReadAttachment(base::PickleIterator* iter, + scoped_refptr<Attachment>* attachment) const; + + // Indicates whether the pickle has any attachments. + virtual bool HasAttachments() const; + // Reserves space for upcoming writes when multiple writes will be made and // their sizes are computed in advance. It can be significantly faster to call // Reserve() before calling WriteFoo() multiple times. diff --git a/chrome/common/cast_messages.cc b/chrome/common/cast_messages.cc index a67c4b5..9cbbb11 100644 --- a/chrome/common/cast_messages.cc +++ b/chrome/common/cast_messages.cc @@ -6,13 +6,14 @@ namespace IPC { -void ParamTraits<media::cast::RtpTimeTicks>::Write(Message* m, +void ParamTraits<media::cast::RtpTimeTicks>::Write(base::Pickle* m, const param_type& p) { ParamTraits<uint64_t>::Write(m, p.SerializeForIPC()); } -bool ParamTraits<media::cast::RtpTimeTicks>::Read( - const Message* m, base::PickleIterator* iter, param_type* r) { +bool ParamTraits<media::cast::RtpTimeTicks>::Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r) { uint64_t serialized = UINT64_C(0); if (ParamTraits<uint64_t>::Read(m, iter, &serialized)) { *r = param_type::DeserializeForIPC(serialized); diff --git a/chrome/common/cast_messages.h b/chrome/common/cast_messages.h index 4d6b8f4..f4db986 100644 --- a/chrome/common/cast_messages.h +++ b/chrome/common/cast_messages.h @@ -21,8 +21,10 @@ namespace IPC { template<> struct ParamTraits<media::cast::RtpTimeTicks> { using param_type = media::cast::RtpTimeTicks; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; diff --git a/chrome/common/content_settings_pattern_serializer.cc b/chrome/common/content_settings_pattern_serializer.cc index af36d567..2e1ba34 100644 --- a/chrome/common/content_settings_pattern_serializer.cc +++ b/chrome/common/content_settings_pattern_serializer.cc @@ -10,14 +10,14 @@ // static void ContentSettingsPatternSerializer::WriteToMessage( const ContentSettingsPattern& pattern, - IPC::Message* m) { + base::Pickle* m) { IPC::WriteParam(m, pattern.is_valid_); IPC::WriteParam(m, pattern.parts_); } // static bool ContentSettingsPatternSerializer::ReadFromMessage( - const IPC::Message* m, + const base::Pickle* m, base::PickleIterator* iter, ContentSettingsPattern* pattern) { DCHECK(pattern); diff --git a/chrome/common/content_settings_pattern_serializer.h b/chrome/common/content_settings_pattern_serializer.h index be724a7..a48591d 100644 --- a/chrome/common/content_settings_pattern_serializer.h +++ b/chrome/common/content_settings_pattern_serializer.h @@ -8,22 +8,19 @@ #include "base/macros.h" namespace base { +class Pickle; class PickleIterator; } -namespace IPC { -class Message; -} - class ContentSettingsPattern; class ContentSettingsPatternSerializer { public: // Serializes the pattern to an IPC message. static void WriteToMessage(const ContentSettingsPattern& pattern, - IPC::Message* m); + base::Pickle* m); // Deserializes the pattern from the IPC message. - static bool ReadFromMessage(const IPC::Message* m, + static bool ReadFromMessage(const base::Pickle* m, base::PickleIterator* iter, ContentSettingsPattern* pattern); diff --git a/chrome/common/render_messages.cc b/chrome/common/render_messages.cc index 1573a2c..d108f42 100644 --- a/chrome/common/render_messages.cc +++ b/chrome/common/render_messages.cc @@ -9,12 +9,13 @@ namespace IPC { void ParamTraits<ContentSettingsPattern>::Write( - Message* m, const ContentSettingsPattern& pattern) { + base::Pickle* m, + const ContentSettingsPattern& pattern) { ContentSettingsPatternSerializer::WriteToMessage(pattern, m); } bool ParamTraits<ContentSettingsPattern>::Read( - const Message* m, + const base::Pickle* m, base::PickleIterator* iter, ContentSettingsPattern* pattern) { return ContentSettingsPatternSerializer::ReadFromMessage(m, iter, pattern); diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index 662b61a..5551665 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -49,8 +49,10 @@ namespace IPC { template <> struct ParamTraits<ContentSettingsPattern> { typedef ContentSettingsPattern param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; diff --git a/chrome/common/safe_browsing/ipc_protobuf_message_macros.h b/chrome/common/safe_browsing/ipc_protobuf_message_macros.h index 4f14c79..db17241 100644 --- a/chrome/common/safe_browsing/ipc_protobuf_message_macros.h +++ b/chrome/common/safe_browsing/ipc_protobuf_message_macros.h @@ -31,23 +31,24 @@ #include <string> -#define IPC_PROTOBUF_MESSAGE_TRAITS_BEGIN(message_name) \ - namespace IPC { \ - template <> \ - struct IPC_MESSAGE_EXPORT ParamTraits<message_name> { \ - typedef message_name param_type; \ - static void Write(Message* m, const param_type& p); \ - static bool Read(const Message* m, base::PickleIterator* iter, \ - param_type* p); \ - static void Log(const param_type& p, std::string* l); \ - \ - private: \ - template <class P> \ - static bool ReadParamF(const Message* m, \ - base::PickleIterator* iter, \ - param_type* p, \ - void (param_type::*setter_function)(P)); \ - }; \ +#define IPC_PROTOBUF_MESSAGE_TRAITS_BEGIN(message_name) \ + namespace IPC { \ + template <> \ + struct IPC_MESSAGE_EXPORT ParamTraits<message_name> { \ + typedef message_name param_type; \ + static void Write(base::Pickle* m, const param_type& p); \ + static bool Read(const base::Pickle* m, \ + base::PickleIterator* iter, \ + param_type* p); \ + static void Log(const param_type& p, std::string* l); \ + \ + private: \ + template <class P> \ + static bool ReadParamF(const base::Pickle* m, \ + base::PickleIterator* iter, \ + param_type* p, \ + void (param_type::*setter_function)(P)); \ + }; \ } // namespace IPC #define IPC_PROTOBUF_MESSAGE_TRAITS_OPTIONAL_FUNDAMENTAL_MEMBER(name) diff --git a/chrome/common/safe_browsing/protobuf_message_param_traits.h b/chrome/common/safe_browsing/protobuf_message_param_traits.h index f78dfec..a935584 100644 --- a/chrome/common/safe_browsing/protobuf_message_param_traits.h +++ b/chrome/common/safe_browsing/protobuf_message_param_traits.h @@ -20,13 +20,13 @@ template <class Element> struct ParamTraits<google::protobuf::RepeatedPtrField<Element>> { typedef google::protobuf::RepeatedPtrField<Element> param_type; - static void Write(Message* m, const param_type& p) { + static void Write(base::Pickle* m, const param_type& p) { WriteParam(m, p.size()); for (const auto& element : p) WriteParam(m, element); } - static bool Read(const Message* m, + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* p) { int size; diff --git a/chrome/common/safe_browsing/protobuf_message_read_macros.h b/chrome/common/safe_browsing/protobuf_message_read_macros.h index aba946f..9c7720d 100644 --- a/chrome/common/safe_browsing/protobuf_message_read_macros.h +++ b/chrome/common/safe_browsing/protobuf_message_read_macros.h @@ -15,21 +15,19 @@ #undef IPC_PROTOBUF_MESSAGE_TRAITS_REPEATED_COMPLEX_MEMBER #undef IPC_PROTOBUF_MESSAGE_TRAITS_END -#define IPC_PROTOBUF_MESSAGE_TRAITS_BEGIN(message_name) \ - template <class P> \ - bool ParamTraits<message_name>::ReadParamF( \ - const Message* m, base::PickleIterator* iter, param_type* p, \ - void (param_type::*setter_function)(P)) { \ - P value; \ - if (!ReadParam(m, iter, &value)) \ - return false; \ - (p->*setter_function)(value); \ - return true; \ - } \ - bool ParamTraits<message_name>::Read(const Message* m, \ - base::PickleIterator* iter, \ - param_type* p) { - +#define IPC_PROTOBUF_MESSAGE_TRAITS_BEGIN(message_name) \ + template <class P> \ + bool ParamTraits<message_name>::ReadParamF( \ + const base::Pickle* m, base::PickleIterator* iter, param_type* p, \ + void (param_type::*setter_function)(P)) { \ + P value; \ + if (!ReadParam(m, iter, &value)) \ + return false; \ + (p->*setter_function)(value); \ + return true; \ + } \ + bool ParamTraits<message_name>::Read( \ + const base::Pickle* m, base::PickleIterator* iter, param_type* p) { #define IPC_PROTOBUF_MESSAGE_TRAITS_OPTIONAL_FUNDAMENTAL_MEMBER(name) \ { \ bool is_present; \ diff --git a/chrome/common/safe_browsing/protobuf_message_write_macros.h b/chrome/common/safe_browsing/protobuf_message_write_macros.h index 2b8a51c..578d23b 100644 --- a/chrome/common/safe_browsing/protobuf_message_write_macros.h +++ b/chrome/common/safe_browsing/protobuf_message_write_macros.h @@ -16,7 +16,7 @@ #undef IPC_PROTOBUF_MESSAGE_TRAITS_END #define IPC_PROTOBUF_MESSAGE_TRAITS_BEGIN(message_name) \ - void ParamTraits<message_name>::Write(Message* m, const param_type& p) { + void ParamTraits<message_name>::Write(base::Pickle* m, const param_type& p) { #define IPC_PROTOBUF_MESSAGE_TRAITS_OPTIONAL_COMPLEX_MEMBER \ IPC_PROTOBUF_MESSAGE_TRAITS_OPTIONAL_FUNDAMENTAL_MEMBER #define IPC_PROTOBUF_MESSAGE_TRAITS_OPTIONAL_FUNDAMENTAL_MEMBER(name) \ diff --git a/chromecast/common/media/cma_param_traits.cc b/chromecast/common/media/cma_param_traits.cc index 4c15ac8..f27043d 100644 --- a/chromecast/common/media/cma_param_traits.cc +++ b/chromecast/common/media/cma_param_traits.cc @@ -30,7 +30,8 @@ IPC_ENUM_TRAITS_MAX_VALUE(media::VideoPixelFormat, media::PIXEL_FORMAT_MAX) namespace IPC { void ParamTraits<media::AudioDecoderConfig>::Write( - Message* m, const media::AudioDecoderConfig& p) { + base::Pickle* m, + const media::AudioDecoderConfig& p) { WriteParam(m, p.codec()); WriteParam(m, p.sample_format()); WriteParam(m, p.channel_layout()); @@ -40,7 +41,7 @@ void ParamTraits<media::AudioDecoderConfig>::Write( } bool ParamTraits<media::AudioDecoderConfig>::Read( - const Message* m, + const base::Pickle* m, base::PickleIterator* iter, media::AudioDecoderConfig* r) { media::AudioCodec codec; @@ -65,7 +66,8 @@ void ParamTraits<media::AudioDecoderConfig>::Log( } void ParamTraits<media::VideoDecoderConfig>::Write( - Message* m, const media::VideoDecoderConfig& p) { + base::Pickle* m, + const media::VideoDecoderConfig& p) { WriteParam(m, p.codec()); WriteParam(m, p.profile()); WriteParam(m, p.format()); @@ -78,7 +80,7 @@ void ParamTraits<media::VideoDecoderConfig>::Write( } bool ParamTraits<media::VideoDecoderConfig>::Read( - const Message* m, + const base::Pickle* m, base::PickleIterator* iter, media::VideoDecoderConfig* r) { media::VideoCodec codec; diff --git a/chromecast/common/media/cma_param_traits.h b/chromecast/common/media/cma_param_traits.h index 106012b..c8609a5 100644 --- a/chromecast/common/media/cma_param_traits.h +++ b/chromecast/common/media/cma_param_traits.h @@ -17,16 +17,20 @@ namespace IPC { template <> struct ParamTraits<media::AudioDecoderConfig> { typedef media::AudioDecoderConfig param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct ParamTraits<media::VideoDecoderConfig> { typedef media::VideoDecoderConfig param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; diff --git a/components/network_hints/common/network_hints_messages.cc b/components/network_hints/common/network_hints_messages.cc index 82eaf6e..27d035d 100644 --- a/components/network_hints/common/network_hints_messages.cc +++ b/components/network_hints/common/network_hints_messages.cc @@ -10,12 +10,13 @@ namespace IPC { void ParamTraits<network_hints::LookupRequest>::Write( - Message* m, const network_hints::LookupRequest& request) { + base::Pickle* m, + const network_hints::LookupRequest& request) { IPC::WriteParam(m, request.hostname_list); } bool ParamTraits<network_hints::LookupRequest>::Read( - const Message* m, + const base::Pickle* m, base::PickleIterator* iter, network_hints::LookupRequest* request) { // Verify the hostname limits after deserialization success. diff --git a/components/network_hints/common/network_hints_messages.h b/components/network_hints/common/network_hints_messages.h index 8613061..fb037db 100644 --- a/components/network_hints/common/network_hints_messages.h +++ b/components/network_hints/common/network_hints_messages.h @@ -20,8 +20,10 @@ namespace IPC { template <> struct ParamTraits<network_hints::LookupRequest> { typedef network_hints::LookupRequest param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; diff --git a/content/child/plugin_param_traits.cc b/content/child/plugin_param_traits.cc index 903936a..0bc61686 100644 --- a/content/child/plugin_param_traits.cc +++ b/content/child/plugin_param_traits.cc @@ -36,7 +36,7 @@ using content::NPVariant_Param; namespace IPC { -void ParamTraits<NPVariant_Param>::Write(Message* m, const param_type& p) { +void ParamTraits<NPVariant_Param>::Write(base::Pickle* m, const param_type& p) { WriteParam(m, static_cast<int>(p.type)); if (p.type == content::NPVARIANT_PARAM_BOOL) { WriteParam(m, p.bool_value); @@ -61,7 +61,7 @@ void ParamTraits<NPVariant_Param>::Write(Message* m, const param_type& p) { } } -bool ParamTraits<NPVariant_Param>::Read(const Message* m, +bool ParamTraits<NPVariant_Param>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { int type; @@ -112,11 +112,12 @@ void ParamTraits<NPVariant_Param>::Log(const param_type& p, std::string* l) { l->append(")"); } -void ParamTraits<NPIdentifier_Param>::Write(Message* m, const param_type& p) { +void ParamTraits<NPIdentifier_Param>::Write(base::Pickle* m, + const param_type& p) { content::SerializeNPIdentifier(p.identifier, m); } -bool ParamTraits<NPIdentifier_Param>::Read(const Message* m, +bool ParamTraits<NPIdentifier_Param>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { return content::DeserializeNPIdentifier(iter, &r->identifier); diff --git a/content/child/plugin_param_traits.h b/content/child/plugin_param_traits.h index 03628c9..f95968b 100644 --- a/content/child/plugin_param_traits.h +++ b/content/child/plugin_param_traits.h @@ -69,16 +69,20 @@ namespace IPC { template <> struct ParamTraits<content::NPVariant_Param> { typedef content::NPVariant_Param param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct ParamTraits<content::NPIdentifier_Param> { typedef content::NPIdentifier_Param param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; diff --git a/content/common/cc_messages.cc b/content/common/cc_messages.cc index 7072946..ff1bfc4 100644 --- a/content/common/cc_messages.cc +++ b/content/common/cc_messages.cc @@ -19,8 +19,8 @@ namespace IPC { -void ParamTraits<cc::FilterOperation>::Write( - Message* m, const param_type& p) { +void ParamTraits<cc::FilterOperation>::Write(base::Pickle* m, + const param_type& p) { WriteParam(m, p.type()); switch (p.type()) { case cc::FilterOperation::GRAYSCALE: @@ -57,7 +57,7 @@ void ParamTraits<cc::FilterOperation>::Write( } } -bool ParamTraits<cc::FilterOperation>::Read(const Message* m, +bool ParamTraits<cc::FilterOperation>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { cc::FilterOperation::FilterType type; @@ -184,15 +184,15 @@ void ParamTraits<cc::FilterOperation>::Log( l->append(")"); } -void ParamTraits<cc::FilterOperations>::Write( - Message* m, const param_type& p) { +void ParamTraits<cc::FilterOperations>::Write(base::Pickle* m, + const param_type& p) { WriteParam(m, p.size()); for (std::size_t i = 0; i < p.size(); ++i) { WriteParam(m, p.at(i)); } } -bool ParamTraits<cc::FilterOperations>::Read(const Message* m, +bool ParamTraits<cc::FilterOperations>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { size_t count; @@ -219,8 +219,8 @@ void ParamTraits<cc::FilterOperations>::Log( l->append(")"); } -void ParamTraits<skia::RefPtr<SkImageFilter> >::Write( - Message* m, const param_type& p) { +void ParamTraits<skia::RefPtr<SkImageFilter>>::Write(base::Pickle* m, + const param_type& p) { SkImageFilter* filter = p.get(); if (filter) { skia::RefPtr<SkData> data = @@ -231,7 +231,7 @@ void ParamTraits<skia::RefPtr<SkImageFilter> >::Write( } } -bool ParamTraits<skia::RefPtr<SkImageFilter>>::Read(const Message* m, +bool ParamTraits<skia::RefPtr<SkImageFilter>>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { const char* data = 0; @@ -255,8 +255,7 @@ void ParamTraits<skia::RefPtr<SkImageFilter> >::Log( l->append(")"); } -void ParamTraits<gfx::Transform>::Write( - Message* m, const param_type& p) { +void ParamTraits<gfx::Transform>::Write(base::Pickle* m, const param_type& p) { #ifdef SK_MSCALAR_IS_FLOAT float column_major_data[16]; p.matrix().asColMajorf(column_major_data); @@ -267,7 +266,7 @@ void ParamTraits<gfx::Transform>::Write( m->WriteBytes(&column_major_data, sizeof(SkMScalar) * 16); } -bool ParamTraits<gfx::Transform>::Read(const Message* m, +bool ParamTraits<gfx::Transform>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { const char* column_major_data; @@ -296,8 +295,7 @@ void ParamTraits<gfx::Transform>::Log( l->append(") "); } -void ParamTraits<cc::RenderPass>::Write( - Message* m, const param_type& p) { +void ParamTraits<cc::RenderPass>::Write(base::Pickle* m, const param_type& p) { WriteParam(m, p.id); WriteParam(m, p.output_rect); WriteParam(m, p.damage_rect); @@ -390,7 +388,7 @@ static size_t ReserveSizeForRenderPassWrite(const cc::RenderPass& p) { } template <typename QuadType> -static cc::DrawQuad* ReadDrawQuad(const Message* m, +static cc::DrawQuad* ReadDrawQuad(const base::Pickle* m, base::PickleIterator* iter, cc::RenderPass* render_pass) { QuadType* quad = render_pass->CreateAndAppendDrawQuad<QuadType>(); @@ -399,7 +397,7 @@ static cc::DrawQuad* ReadDrawQuad(const Message* m, return quad; } -bool ParamTraits<cc::RenderPass>::Read(const Message* m, +bool ParamTraits<cc::RenderPass>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* p) { cc::RenderPassId id; @@ -566,7 +564,7 @@ namespace { }; } -void ParamTraits<cc::CompositorFrame>::Write(Message* m, +void ParamTraits<cc::CompositorFrame>::Write(base::Pickle* m, const param_type& p) { WriteParam(m, p.metadata); if (p.delegated_frame_data) { @@ -581,7 +579,7 @@ void ParamTraits<cc::CompositorFrame>::Write(Message* m, } } -bool ParamTraits<cc::CompositorFrame>::Read(const Message* m, +bool ParamTraits<cc::CompositorFrame>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* p) { if (!ReadParam(m, iter, &p->metadata)) @@ -622,7 +620,7 @@ void ParamTraits<cc::CompositorFrame>::Log(const param_type& p, l->append(")"); } -void ParamTraits<cc::CompositorFrameAck>::Write(Message* m, +void ParamTraits<cc::CompositorFrameAck>::Write(base::Pickle* m, const param_type& p) { WriteParam(m, p.resources); if (p.gl_frame_data) { @@ -633,7 +631,7 @@ void ParamTraits<cc::CompositorFrameAck>::Write(Message* m, } } -bool ParamTraits<cc::CompositorFrameAck>::Read(const Message* m, +bool ParamTraits<cc::CompositorFrameAck>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* p) { if (!ReadParam(m, iter, &p->resources)) @@ -667,7 +665,7 @@ void ParamTraits<cc::CompositorFrameAck>::Log(const param_type& p, l->append(")"); } -void ParamTraits<cc::DelegatedFrameData>::Write(Message* m, +void ParamTraits<cc::DelegatedFrameData>::Write(base::Pickle* m, const param_type& p) { DCHECK_NE(0u, p.render_pass_list.size()); @@ -689,7 +687,7 @@ void ParamTraits<cc::DelegatedFrameData>::Write(Message* m, } } -bool ParamTraits<cc::DelegatedFrameData>::Read(const Message* m, +bool ParamTraits<cc::DelegatedFrameData>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* p) { if (!ReadParam(m, iter, &p->device_scale_factor)) @@ -748,7 +746,7 @@ void ParamTraits<cc::DelegatedFrameData>::Log(const param_type& p, l->append("])"); } -void ParamTraits<cc::DrawQuad::Resources>::Write(Message* m, +void ParamTraits<cc::DrawQuad::Resources>::Write(base::Pickle* m, const param_type& p) { DCHECK_LE(p.count, cc::DrawQuad::Resources::kMaxResourceIdCount); WriteParam(m, p.count); @@ -756,7 +754,7 @@ void ParamTraits<cc::DrawQuad::Resources>::Write(Message* m, WriteParam(m, p.ids[i]); } -bool ParamTraits<cc::DrawQuad::Resources>::Read(const Message* m, +bool ParamTraits<cc::DrawQuad::Resources>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* p) { if (!ReadParam(m, iter, &p->count)) @@ -789,7 +787,7 @@ void ParamTraits<cc::DrawQuad::Resources>::Log(const param_type& p, } void ParamTraits<cc::StreamVideoDrawQuad::OverlayResources>::Write( - Message* m, + base::Pickle* m, const param_type& p) { for (size_t i = 0; i < cc::DrawQuad::Resources::kMaxResourceIdCount; ++i) { WriteParam(m, p.size_in_pixels[i]); @@ -797,7 +795,7 @@ void ParamTraits<cc::StreamVideoDrawQuad::OverlayResources>::Write( } bool ParamTraits<cc::StreamVideoDrawQuad::OverlayResources>::Read( - const Message* m, + const base::Pickle* m, base::PickleIterator* iter, param_type* p) { for (size_t i = 0; i < cc::DrawQuad::Resources::kMaxResourceIdCount; ++i) { @@ -820,7 +818,7 @@ void ParamTraits<cc::StreamVideoDrawQuad::OverlayResources>::Log( } void ParamTraits<cc::TextureDrawQuad::OverlayResources>::Write( - Message* m, + base::Pickle* m, const param_type& p) { for (size_t i = 0; i < cc::DrawQuad::Resources::kMaxResourceIdCount; ++i) { WriteParam(m, p.size_in_pixels[i]); @@ -828,7 +826,7 @@ void ParamTraits<cc::TextureDrawQuad::OverlayResources>::Write( } bool ParamTraits<cc::TextureDrawQuad::OverlayResources>::Read( - const Message* m, + const base::Pickle* m, base::PickleIterator* iter, param_type* p) { for (size_t i = 0; i < cc::DrawQuad::Resources::kMaxResourceIdCount; ++i) { diff --git a/content/common/cc_messages.h b/content/common/cc_messages.h index 9f2e84e..e7358e6 100644 --- a/content/common/cc_messages.h +++ b/content/common/cc_messages.h @@ -48,88 +48,110 @@ namespace IPC { template <> struct ParamTraits<cc::FilterOperation> { typedef cc::FilterOperation param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct ParamTraits<cc::FilterOperations> { typedef cc::FilterOperations param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct ParamTraits<skia::RefPtr<SkImageFilter> > { typedef skia::RefPtr<SkImageFilter> param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct ParamTraits<gfx::Transform> { typedef gfx::Transform param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct CONTENT_EXPORT ParamTraits<cc::RenderPass> { typedef cc::RenderPass param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template<> struct CONTENT_EXPORT ParamTraits<cc::CompositorFrame> { typedef cc::CompositorFrame param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* p); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p); static void Log(const param_type& p, std::string* l); }; template<> struct CONTENT_EXPORT ParamTraits<cc::CompositorFrameAck> { typedef cc::CompositorFrameAck param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* p); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p); static void Log(const param_type& p, std::string* l); }; template<> struct CONTENT_EXPORT ParamTraits<cc::DelegatedFrameData> { typedef cc::DelegatedFrameData param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* p); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p); static void Log(const param_type& p, std::string* l); }; template <> struct CONTENT_EXPORT ParamTraits<cc::DrawQuad::Resources> { typedef cc::DrawQuad::Resources param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* p); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p); static void Log(const param_type& p, std::string* l); }; template <> struct CONTENT_EXPORT ParamTraits<cc::StreamVideoDrawQuad::OverlayResources> { typedef cc::StreamVideoDrawQuad::OverlayResources param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* p); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p); static void Log(const param_type& p, std::string* l); }; template <> struct CONTENT_EXPORT ParamTraits<cc::TextureDrawQuad::OverlayResources> { typedef cc::TextureDrawQuad::OverlayResources param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* p); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p); static void Log(const param_type& p, std::string* l); }; diff --git a/content/common/content_param_traits.cc b/content/common/content_param_traits.cc index 0c60380e..07e1a23 100644 --- a/content/common/content_param_traits.cc +++ b/content/common/content_param_traits.cc @@ -12,11 +12,12 @@ namespace IPC { -void ParamTraits<WebInputEventPointer>::Write(Message* m, const param_type& p) { +void ParamTraits<WebInputEventPointer>::Write(base::Pickle* m, + const param_type& p) { m->WriteData(reinterpret_cast<const char*>(p), p->size); } -bool ParamTraits<WebInputEventPointer>::Read(const Message* m, +bool ParamTraits<WebInputEventPointer>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { const char* data; diff --git a/content/common/content_param_traits.h b/content/common/content_param_traits.h index e90a14b..61107aa 100644 --- a/content/common/content_param_traits.h +++ b/content/common/content_param_traits.h @@ -27,12 +27,10 @@ namespace IPC { template <> struct ParamTraits<content::WebCursor> { typedef content::WebCursor param_type; - static void Write(Message* m, const param_type& p) { - p.Serialize(m); - } - static bool Read(const Message* m, + static void Write(base::Pickle* m, const param_type& p) { p.Serialize(m); } + static bool Read(const base::Pickle* m, base::PickleIterator* iter, - param_type* r) { + param_type* r) { return r->Deserialize(iter); } static void Log(const param_type& p, std::string* l) { @@ -44,9 +42,11 @@ typedef const blink::WebInputEvent* WebInputEventPointer; template <> struct ParamTraits<WebInputEventPointer> { typedef WebInputEventPointer param_type; - static void Write(Message* m, const param_type& p); + static void Write(base::Pickle* m, const param_type& p); // Note: upon read, the event has the lifetime of the message. - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; diff --git a/content/common/gamepad_param_traits.cc b/content/common/gamepad_param_traits.cc index 095154d..5a343fa 100644 --- a/content/common/gamepad_param_traits.cc +++ b/content/common/gamepad_param_traits.cc @@ -33,13 +33,11 @@ void LogWebUCharString( namespace IPC { -void ParamTraits<WebGamepad>::Write( - Message* m, - const WebGamepad& p) { +void ParamTraits<WebGamepad>::Write(base::Pickle* m, const WebGamepad& p) { m->WriteData(reinterpret_cast<const char*>(&p), sizeof(WebGamepad)); } -bool ParamTraits<WebGamepad>::Read(const Message* m, +bool ParamTraits<WebGamepad>::Read(const base::Pickle* m, base::PickleIterator* iter, WebGamepad* p) { int length; diff --git a/content/common/gamepad_param_traits.h b/content/common/gamepad_param_traits.h index 212c306..99576803 100644 --- a/content/common/gamepad_param_traits.h +++ b/content/common/gamepad_param_traits.h @@ -10,6 +10,7 @@ #include "ipc/ipc_param_traits.h" namespace base { +class Pickle; class PickleIterator; } @@ -22,8 +23,8 @@ class Message; template <> struct ParamTraits<blink::WebGamepad> { typedef blink::WebGamepad param_type; - static void Write(Message* m, const blink::WebGamepad& p); - static bool Read(const Message* m, + static void Write(base::Pickle* m, const blink::WebGamepad& p); + static bool Read(const base::Pickle* m, base::PickleIterator* iter, blink::WebGamepad* p); static void Log(const blink::WebGamepad& p, std::string* l); diff --git a/content/common/indexed_db/indexed_db_param_traits.cc b/content/common/indexed_db/indexed_db_param_traits.cc index 9ca0cec..c684e9f 100644 --- a/content/common/indexed_db/indexed_db_param_traits.cc +++ b/content/common/indexed_db/indexed_db_param_traits.cc @@ -30,7 +30,7 @@ using blink::WebIDBKeyTypeString; namespace IPC { -void ParamTraits<IndexedDBKey>::Write(Message* m, const param_type& p) { +void ParamTraits<IndexedDBKey>::Write(base::Pickle* m, const param_type& p) { WriteParam(m, static_cast<int>(p.type())); switch (p.type()) { case WebIDBKeyTypeArray: @@ -58,7 +58,7 @@ void ParamTraits<IndexedDBKey>::Write(Message* m, const param_type& p) { } } -bool ParamTraits<IndexedDBKey>::Read(const Message* m, +bool ParamTraits<IndexedDBKey>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { int type; @@ -153,7 +153,8 @@ void ParamTraits<IndexedDBKey>::Log(const param_type& p, std::string* l) { l->append(")"); } -void ParamTraits<IndexedDBKeyPath>::Write(Message* m, const param_type& p) { +void ParamTraits<IndexedDBKeyPath>::Write(base::Pickle* m, + const param_type& p) { WriteParam(m, static_cast<int>(p.type())); switch (p.type()) { case WebIDBKeyPathTypeArray: @@ -170,7 +171,7 @@ void ParamTraits<IndexedDBKeyPath>::Write(Message* m, const param_type& p) { } } -bool ParamTraits<IndexedDBKeyPath>::Read(const Message* m, +bool ParamTraits<IndexedDBKeyPath>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { int type; @@ -230,14 +231,15 @@ void ParamTraits<IndexedDBKeyPath>::Log(const param_type& p, std::string* l) { l->append(")"); } -void ParamTraits<IndexedDBKeyRange>::Write(Message* m, const param_type& p) { +void ParamTraits<IndexedDBKeyRange>::Write(base::Pickle* m, + const param_type& p) { WriteParam(m, p.lower()); WriteParam(m, p.upper()); WriteParam(m, p.lower_open()); WriteParam(m, p.upper_open()); } -bool ParamTraits<IndexedDBKeyRange>::Read(const Message* m, +bool ParamTraits<IndexedDBKeyRange>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { IndexedDBKey lower; diff --git a/content/common/indexed_db/indexed_db_param_traits.h b/content/common/indexed_db/indexed_db_param_traits.h index 8f6eeb2..e11b283 100644 --- a/content/common/indexed_db/indexed_db_param_traits.h +++ b/content/common/indexed_db/indexed_db_param_traits.h @@ -21,24 +21,30 @@ namespace IPC { template <> struct ParamTraits<content::IndexedDBKey> { typedef content::IndexedDBKey param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct ParamTraits<content::IndexedDBKeyRange> { typedef content::IndexedDBKeyRange param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct ParamTraits<content::IndexedDBKeyPath> { typedef content::IndexedDBKeyPath param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; diff --git a/content/common/input/input_param_traits.cc b/content/common/input/input_param_traits.cc index 0402f43..80a68ad 100644 --- a/content/common/input/input_param_traits.cc +++ b/content/common/input/input_param_traits.cc @@ -17,7 +17,7 @@ namespace IPC { namespace { template <typename GestureType> scoped_ptr<content::SyntheticGestureParams> ReadGestureParams( - const Message* m, + const base::Pickle* m, base::PickleIterator* iter) { scoped_ptr<GestureType> gesture_params(new GestureType); if (!ReadParam(m, iter, gesture_params.get())) @@ -27,7 +27,7 @@ scoped_ptr<content::SyntheticGestureParams> ReadGestureParams( } } // namespace -void ParamTraits<content::ScopedWebInputEvent>::Write(Message* m, +void ParamTraits<content::ScopedWebInputEvent>::Write(base::Pickle* m, const param_type& p) { bool valid_web_event = !!p; WriteParam(m, valid_web_event); @@ -35,7 +35,7 @@ void ParamTraits<content::ScopedWebInputEvent>::Write(Message* m, WriteParam(m, static_cast<WebInputEventPointer>(p.get())); } -bool ParamTraits<content::ScopedWebInputEvent>::Read(const Message* m, +bool ParamTraits<content::ScopedWebInputEvent>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* p) { bool valid_web_event = false; @@ -55,7 +55,7 @@ void ParamTraits<content::ScopedWebInputEvent>::Log(const param_type& p, LogParam(static_cast<WebInputEventPointer>(p.get()), l); } -void ParamTraits<content::SyntheticGesturePacket>::Write(Message* m, +void ParamTraits<content::SyntheticGesturePacket>::Write(base::Pickle* m, const param_type& p) { DCHECK(p.gesture_params()); WriteParam(m, p.gesture_params()->GetGestureType()); @@ -80,7 +80,7 @@ void ParamTraits<content::SyntheticGesturePacket>::Write(Message* m, } bool ParamTraits<content::SyntheticGesturePacket>::Read( - const Message* m, + const base::Pickle* m, base::PickleIterator* iter, param_type* p) { content::SyntheticGestureParams::GestureType gesture_type; diff --git a/content/common/input/input_param_traits.h b/content/common/input/input_param_traits.h index 9f5b1ce..1c204c3 100644 --- a/content/common/input/input_param_traits.h +++ b/content/common/input/input_param_traits.h @@ -18,16 +18,20 @@ namespace IPC { template <> struct CONTENT_EXPORT ParamTraits<content::ScopedWebInputEvent> { typedef content::ScopedWebInputEvent param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template<> struct CONTENT_EXPORT ParamTraits<content::SyntheticGesturePacket> { typedef content::SyntheticGesturePacket param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; diff --git a/content/common/mac/attributed_string_coder.h b/content/common/mac/attributed_string_coder.h index 971088e..6976d4e 100644 --- a/content/common/mac/attributed_string_coder.h +++ b/content/common/mac/attributed_string_coder.h @@ -21,6 +21,11 @@ class NSAttributedString; class NSDictionary; #endif +namespace base { +class Pickle; +class PickleIterator; +} + namespace mac { // This class will serialize the font information of an NSAttributedString so @@ -100,16 +105,20 @@ namespace IPC { 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, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; 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, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; diff --git a/content/common/mac/attributed_string_coder.mm b/content/common/mac/attributed_string_coder.mm index 85ceeb3..f8fa6b0 100644 --- a/content/common/mac/attributed_string_coder.mm +++ b/content/common/mac/attributed_string_coder.mm @@ -122,13 +122,14 @@ namespace IPC { using mac::AttributedStringCoder; void ParamTraits<AttributedStringCoder::EncodedString>::Write( - Message* m, const param_type& p) { + base::Pickle* m, + const param_type& p) { WriteParam(m, p.string()); WriteParam(m, p.attributes()); } bool ParamTraits<AttributedStringCoder::EncodedString>::Read( - const Message* m, + const base::Pickle* m, base::PickleIterator* iter, param_type* p) { bool success = true; @@ -147,13 +148,14 @@ void ParamTraits<AttributedStringCoder::EncodedString>::Log( } void ParamTraits<AttributedStringCoder::FontAttribute>::Write( - Message* m, const param_type& p) { + base::Pickle* m, + const param_type& p) { WriteParam(m, p.font_descriptor()); WriteParam(m, p.effective_range()); } bool ParamTraits<AttributedStringCoder::FontAttribute>::Read( - const Message* m, + const base::Pickle* m, base::PickleIterator* iter, param_type* p) { bool success = true; diff --git a/content/common/media/media_param_traits.cc b/content/common/media/media_param_traits.cc index 5d5020c..2ceeba4 100644 --- a/content/common/media/media_param_traits.cc +++ b/content/common/media/media_param_traits.cc @@ -19,7 +19,7 @@ using media::VideoCaptureFormat; namespace IPC { -void ParamTraits<AudioParameters>::Write(Message* m, +void ParamTraits<AudioParameters>::Write(base::Pickle* m, const AudioParameters& p) { WriteParam(m, p.format()); WriteParam(m, p.channel_layout()); @@ -31,7 +31,7 @@ void ParamTraits<AudioParameters>::Write(Message* m, WriteParam(m, p.mic_positions()); } -bool ParamTraits<AudioParameters>::Read(const Message* m, +bool ParamTraits<AudioParameters>::Read(const base::Pickle* m, base::PickleIterator* iter, AudioParameters* r) { AudioParameters::Format format; @@ -63,7 +63,7 @@ void ParamTraits<AudioParameters>::Log(const AudioParameters& p, l->append(base::StringPrintf("<AudioParameters>")); } -void ParamTraits<VideoCaptureFormat>::Write(Message* m, +void ParamTraits<VideoCaptureFormat>::Write(base::Pickle* m, const VideoCaptureFormat& p) { WriteParam(m, p.frame_size); WriteParam(m, p.frame_rate); @@ -71,7 +71,7 @@ void ParamTraits<VideoCaptureFormat>::Write(Message* m, WriteParam(m, p.pixel_storage); } -bool ParamTraits<VideoCaptureFormat>::Read(const Message* m, +bool ParamTraits<VideoCaptureFormat>::Read(const base::Pickle* m, base::PickleIterator* iter, VideoCaptureFormat* r) { if (!ReadParam(m, iter, &r->frame_size) || diff --git a/content/common/media/media_param_traits.h b/content/common/media/media_param_traits.h index f035b40..70675ed 100644 --- a/content/common/media/media_param_traits.h +++ b/content/common/media/media_param_traits.h @@ -19,16 +19,20 @@ namespace IPC { template <> struct CONTENT_EXPORT ParamTraits<media::AudioParameters> { typedef media::AudioParameters param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct CONTENT_EXPORT ParamTraits<media::VideoCaptureFormat> { typedef media::VideoCaptureFormat param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; diff --git a/content/common/resource_messages.cc b/content/common/resource_messages.cc index da92b97..2c0cbe1 100644 --- a/content/common/resource_messages.cc +++ b/content/common/resource_messages.cc @@ -9,8 +9,9 @@ namespace IPC { -void ParamTraits<scoped_refptr<net::HttpResponseHeaders> >::Write( - Message* m, const param_type& p) { +void ParamTraits<scoped_refptr<net::HttpResponseHeaders>>::Write( + base::Pickle* m, + const param_type& p) { WriteParam(m, p.get() != NULL); if (p.get()) { // Do not disclose Set-Cookie headers over IPC. @@ -19,7 +20,7 @@ void ParamTraits<scoped_refptr<net::HttpResponseHeaders> >::Write( } bool ParamTraits<scoped_refptr<net::HttpResponseHeaders>>::Read( - const Message* m, + const base::Pickle* m, base::PickleIterator* iter, param_type* r) { bool has_object; @@ -35,7 +36,8 @@ void ParamTraits<scoped_refptr<net::HttpResponseHeaders> >::Log( l->append("<HttpResponseHeaders>"); } -void ParamTraits<storage::DataElement>::Write(Message* m, const param_type& p) { +void ParamTraits<storage::DataElement>::Write(base::Pickle* m, + const param_type& p) { WriteParam(m, static_cast<int>(p.type())); switch (p.type()) { case storage::DataElement::TYPE_BYTES: { @@ -77,7 +79,7 @@ void ParamTraits<storage::DataElement>::Write(Message* m, const param_type& p) { } } -bool ParamTraits<storage::DataElement>::Read(const Message* m, +bool ParamTraits<storage::DataElement>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { int type; @@ -160,8 +162,9 @@ void ParamTraits<storage::DataElement>::Log(const param_type& p, l->append("<storage::DataElement>"); } -void ParamTraits<scoped_refptr<content::ResourceDevToolsInfo> >::Write( - Message* m, const param_type& p) { +void ParamTraits<scoped_refptr<content::ResourceDevToolsInfo>>::Write( + base::Pickle* m, + const param_type& p) { WriteParam(m, p.get() != NULL); if (p.get()) { WriteParam(m, p->http_status_code); @@ -174,7 +177,7 @@ void ParamTraits<scoped_refptr<content::ResourceDevToolsInfo> >::Write( } bool ParamTraits<scoped_refptr<content::ResourceDevToolsInfo>>::Read( - const Message* m, + const base::Pickle* m, base::PickleIterator* iter, param_type* r) { bool has_object; @@ -203,8 +206,8 @@ void ParamTraits<scoped_refptr<content::ResourceDevToolsInfo> >::Log( l->append(")"); } -void ParamTraits<net::LoadTimingInfo>::Write( - Message* m, const param_type& p) { +void ParamTraits<net::LoadTimingInfo>::Write(base::Pickle* m, + const param_type& p) { WriteParam(m, p.socket_log_id); WriteParam(m, p.socket_reused); WriteParam(m, p.request_start_time.is_null()); @@ -225,7 +228,7 @@ void ParamTraits<net::LoadTimingInfo>::Write( WriteParam(m, p.receive_headers_end); } -bool ParamTraits<net::LoadTimingInfo>::Read(const Message* m, +bool ParamTraits<net::LoadTimingInfo>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { bool has_no_times; @@ -288,8 +291,8 @@ void ParamTraits<net::LoadTimingInfo>::Log(const param_type& p, l->append(")"); } -void ParamTraits<scoped_refptr<content::ResourceRequestBody> >::Write( - Message* m, +void ParamTraits<scoped_refptr<content::ResourceRequestBody>>::Write( + base::Pickle* m, const param_type& p) { WriteParam(m, p.get() != NULL); if (p.get()) { @@ -299,7 +302,7 @@ void ParamTraits<scoped_refptr<content::ResourceRequestBody> >::Write( } bool ParamTraits<scoped_refptr<content::ResourceRequestBody>>::Read( - const Message* m, + const base::Pickle* m, base::PickleIterator* iter, param_type* r) { bool has_object; diff --git a/content/common/resource_messages.h b/content/common/resource_messages.h index a6bf171..40e9f2f 100644 --- a/content/common/resource_messages.h +++ b/content/common/resource_messages.h @@ -39,40 +39,50 @@ namespace IPC { 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, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct CONTENT_EXPORT ParamTraits<storage::DataElement> { typedef storage::DataElement param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct ParamTraits<scoped_refptr<content::ResourceDevToolsInfo> > { typedef scoped_refptr<content::ResourceDevToolsInfo> param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct ParamTraits<net::LoadTimingInfo> { typedef net::LoadTimingInfo param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct ParamTraits<scoped_refptr<content::ResourceRequestBody> > { typedef scoped_refptr<content::ResourceRequestBody> param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; diff --git a/content/public/common/common_param_traits.cc b/content/public/common/common_param_traits.cc index f953fa3..6a937c6 100644 --- a/content/public/common/common_param_traits.cc +++ b/content/public/common/common_param_traits.cc @@ -15,7 +15,7 @@ namespace IPC { -void ParamTraits<GURL>::Write(Message* m, const GURL& p) { +void ParamTraits<GURL>::Write(base::Pickle* m, const GURL& p) { if (p.possibly_invalid_spec().length() > content::kMaxURLChars) { m->WriteString(std::string()); return; @@ -36,7 +36,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, +bool ParamTraits<GURL>::Read(const base::Pickle* m, base::PickleIterator* iter, GURL* p) { std::string s; @@ -56,14 +56,14 @@ void ParamTraits<GURL>::Log(const GURL& p, std::string* l) { l->append(p.spec()); } -void ParamTraits<url::Origin>::Write(Message* m, const url::Origin& p) { +void ParamTraits<url::Origin>::Write(base::Pickle* m, const url::Origin& p) { WriteParam(m, p.unique()); WriteParam(m, p.scheme()); WriteParam(m, p.host()); WriteParam(m, p.port()); } -bool ParamTraits<url::Origin>::Read(const Message* m, +bool ParamTraits<url::Origin>::Read(const base::Pickle* m, base::PickleIterator* iter, url::Origin* p) { bool unique; @@ -93,12 +93,13 @@ void ParamTraits<url::Origin>::Log(const url::Origin& p, std::string* l) { l->append(p.Serialize()); } -void ParamTraits<net::HostPortPair>::Write(Message* m, const param_type& p) { +void ParamTraits<net::HostPortPair>::Write(base::Pickle* m, + const param_type& p) { WriteParam(m, p.host()); WriteParam(m, p.port()); } -bool ParamTraits<net::HostPortPair>::Read(const Message* m, +bool ParamTraits<net::HostPortPair>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { std::string host; @@ -115,12 +116,12 @@ void ParamTraits<net::HostPortPair>::Log(const param_type& p, std::string* l) { l->append(p.ToString()); } -void ParamTraits<net::IPEndPoint>::Write(Message* m, const param_type& p) { +void ParamTraits<net::IPEndPoint>::Write(base::Pickle* m, const param_type& p) { WriteParam(m, p.address()); WriteParam(m, p.port()); } -bool ParamTraits<net::IPEndPoint>::Read(const Message* m, +bool ParamTraits<net::IPEndPoint>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* p) { net::IPAddressNumber address; @@ -140,11 +141,11 @@ void ParamTraits<net::IPEndPoint>::Log(const param_type& p, std::string* l) { LogParam("IPEndPoint:" + p.ToString(), l); } -void ParamTraits<net::IPAddress>::Write(Message* m, const param_type& p) { +void ParamTraits<net::IPAddress>::Write(base::Pickle* m, const param_type& p) { WriteParam(m, p.bytes()); } -bool ParamTraits<net::IPAddress>::Read(const Message* m, +bool ParamTraits<net::IPAddress>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* p) { std::vector<uint8_t> bytes; @@ -163,12 +164,12 @@ void ParamTraits<net::IPAddress>::Log(const param_type& p, std::string* l) { LogParam("IPAddress:" + (p.empty() ? "(empty)" : p.ToString()), l); } -void ParamTraits<content::PageState>::Write( - Message* m, const param_type& p) { +void ParamTraits<content::PageState>::Write(base::Pickle* m, + const param_type& p) { WriteParam(m, p.ToEncodedData()); } -bool ParamTraits<content::PageState>::Read(const Message* m, +bool ParamTraits<content::PageState>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { std::string data; diff --git a/content/public/common/common_param_traits.h b/content/public/common/common_param_traits.h index e3f5142..5f55f13 100644 --- a/content/public/common/common_param_traits.h +++ b/content/public/common/common_param_traits.h @@ -47,62 +47,75 @@ namespace IPC { 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, base::PickleIterator* iter, param_type* p); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p); static void Log(const param_type& p, std::string* l); }; template <> struct CONTENT_EXPORT ParamTraits<url::Origin> { typedef url::Origin param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* p); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p); static void Log(const param_type& p, std::string* l); }; 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, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct CONTENT_EXPORT ParamTraits<net::IPEndPoint> { typedef net::IPEndPoint param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* p); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p); static void Log(const param_type& p, std::string* l); }; template <> struct CONTENT_EXPORT ParamTraits<net::IPAddress> { typedef net::IPAddress param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* p); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p); static void Log(const param_type& p, std::string* l); }; template <> struct CONTENT_EXPORT ParamTraits<content::PageState> { typedef content::PageState param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* p); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p); static void Log(const param_type& p, std::string* l); }; template <> struct ParamTraits<gfx::NativeWindow> { typedef gfx::NativeWindow param_type; - static void Write(Message* m, const param_type& p) { + static void Write(base::Pickle* m, const param_type& p) { #if defined(OS_WIN) m->WriteUInt32(base::win::HandleToUint32(p)); #else m->WriteData(reinterpret_cast<const char*>(&p), sizeof(p)); #endif } - static bool Read(const Message* m, base::PickleIterator* iter, + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, param_type* r) { #if defined(OS_WIN) return iter->ReadUInt32(reinterpret_cast<uint32_t*>(r)); diff --git a/device/bluetooth/bluetooth_uuid.cc b/device/bluetooth/bluetooth_uuid.cc index 89c1ac6..7a275e5 100644 --- a/device/bluetooth/bluetooth_uuid.cc +++ b/device/bluetooth/bluetooth_uuid.cc @@ -96,12 +96,12 @@ void PrintTo(const BluetoothUUID& uuid, std::ostream* out) { } // namespace device -void IPC::ParamTraits<device::BluetoothUUID>::Write(Message* m, +void IPC::ParamTraits<device::BluetoothUUID>::Write(base::Pickle* m, const param_type& p) { m->WriteString(p.canonical_value()); } -bool IPC::ParamTraits<device::BluetoothUUID>::Read(const Message* m, +bool IPC::ParamTraits<device::BluetoothUUID>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { std::string value; diff --git a/device/bluetooth/bluetooth_uuid.h b/device/bluetooth/bluetooth_uuid.h index 5d7cdd2..f36e8b5 100644 --- a/device/bluetooth/bluetooth_uuid.h +++ b/device/bluetooth/bluetooth_uuid.h @@ -11,6 +11,7 @@ #include "ipc/ipc_param_traits.h" namespace base { +class Pickle; class PickleIterator; } // namespace base @@ -110,8 +111,10 @@ class Message; template <> struct DEVICE_BLUETOOTH_EXPORT ParamTraits<device::BluetoothUUID> { typedef device::BluetoothUUID param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; diff --git a/extensions/common/extension_messages.cc b/extensions/common/extension_messages.cc index 15bc121..5cccc11 100644 --- a/extensions/common/extension_messages.cc +++ b/extensions/common/extension_messages.cc @@ -92,11 +92,11 @@ namespace IPC { template <> struct ParamTraits<Manifest::Location> { typedef Manifest::Location param_type; - static void Write(Message* m, const param_type& p) { + static void Write(base::Pickle* m, const param_type& p) { int val = static_cast<int>(p); WriteParam(m, val); } - static bool Read(const Message* m, + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* p) { int val = 0; @@ -112,12 +112,12 @@ struct ParamTraits<Manifest::Location> { } }; -void ParamTraits<URLPattern>::Write(Message* m, const param_type& p) { +void ParamTraits<URLPattern>::Write(base::Pickle* m, const param_type& p) { WriteParam(m, p.valid_schemes()); WriteParam(m, p.GetAsString()); } -bool ParamTraits<URLPattern>::Read(const Message* m, +bool ParamTraits<URLPattern>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* p) { int valid_schemes; @@ -141,11 +141,11 @@ void ParamTraits<URLPattern>::Log(const param_type& p, std::string* l) { LogParam(p.GetAsString(), l); } -void ParamTraits<URLPatternSet>::Write(Message* m, const param_type& p) { +void ParamTraits<URLPatternSet>::Write(base::Pickle* m, const param_type& p) { WriteParam(m, p.patterns()); } -bool ParamTraits<URLPatternSet>::Read(const Message* m, +bool ParamTraits<URLPatternSet>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* p) { std::set<URLPattern> patterns; @@ -162,12 +162,12 @@ void ParamTraits<URLPatternSet>::Log(const param_type& p, std::string* l) { LogParam(p.patterns(), l); } -void ParamTraits<APIPermission::ID>::Write( - Message* m, const param_type& p) { +void ParamTraits<APIPermission::ID>::Write(base::Pickle* m, + const param_type& p) { WriteParam(m, static_cast<int>(p)); } -bool ParamTraits<APIPermission::ID>::Read(const Message* m, +bool ParamTraits<APIPermission::ID>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* p) { int api_id = -2; @@ -183,8 +183,8 @@ void ParamTraits<APIPermission::ID>::Log( LogParam(static_cast<int>(p), l); } -void ParamTraits<APIPermissionSet>::Write( - Message* m, const param_type& p) { +void ParamTraits<APIPermissionSet>::Write(base::Pickle* m, + const param_type& p) { APIPermissionSet::const_iterator it = p.begin(); const APIPermissionSet::const_iterator end = p.end(); WriteParam(m, p.size()); @@ -194,7 +194,7 @@ void ParamTraits<APIPermissionSet>::Write( } } -bool ParamTraits<APIPermissionSet>::Read(const Message* m, +bool ParamTraits<APIPermissionSet>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { size_t size; @@ -221,8 +221,8 @@ void ParamTraits<APIPermissionSet>::Log( LogParam(p.map(), l); } -void ParamTraits<ManifestPermissionSet>::Write( - Message* m, const param_type& p) { +void ParamTraits<ManifestPermissionSet>::Write(base::Pickle* m, + const param_type& p) { ManifestPermissionSet::const_iterator it = p.begin(); const ManifestPermissionSet::const_iterator end = p.end(); WriteParam(m, p.size()); @@ -232,7 +232,7 @@ void ParamTraits<ManifestPermissionSet>::Write( } } -bool ParamTraits<ManifestPermissionSet>::Read(const Message* m, +bool ParamTraits<ManifestPermissionSet>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { size_t size; @@ -257,13 +257,12 @@ void ParamTraits<ManifestPermissionSet>::Log( LogParam(p.map(), l); } -void ParamTraits<HostID>::Write( - Message* m, const param_type& p) { +void ParamTraits<HostID>::Write(base::Pickle* m, const param_type& p) { WriteParam(m, p.type()); WriteParam(m, p.id()); } -bool ParamTraits<HostID>::Read(const Message* m, +bool ParamTraits<HostID>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { HostID::HostType type; @@ -282,7 +281,7 @@ void ParamTraits<HostID>::Log( LogParam(p.id(), l); } -void ParamTraits<ExtensionMsg_PermissionSetStruct>::Write(Message* m, +void ParamTraits<ExtensionMsg_PermissionSetStruct>::Write(base::Pickle* m, const param_type& p) { WriteParam(m, p.apis); WriteParam(m, p.manifest_permissions); @@ -291,7 +290,7 @@ void ParamTraits<ExtensionMsg_PermissionSetStruct>::Write(Message* m, } bool ParamTraits<ExtensionMsg_PermissionSetStruct>::Read( - const Message* m, + const base::Pickle* m, base::PickleIterator* iter, param_type* p) { return ReadParam(m, iter, &p->apis) && @@ -308,7 +307,7 @@ void ParamTraits<ExtensionMsg_PermissionSetStruct>::Log(const param_type& p, LogParam(p.scriptable_hosts, l); } -void ParamTraits<ExtensionMsg_Loaded_Params>::Write(Message* m, +void ParamTraits<ExtensionMsg_Loaded_Params>::Write(base::Pickle* m, const param_type& p) { WriteParam(m, p.location); WriteParam(m, p.path); @@ -318,7 +317,7 @@ void ParamTraits<ExtensionMsg_Loaded_Params>::Write(Message* m, WriteParam(m, p.withheld_permissions); } -bool ParamTraits<ExtensionMsg_Loaded_Params>::Read(const Message* m, +bool ParamTraits<ExtensionMsg_Loaded_Params>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* p) { p->manifest.reset(new base::DictionaryValue()); diff --git a/extensions/common/extension_messages.h b/extensions/common/extension_messages.h index 2e025ac..5125941 100644 --- a/extensions/common/extension_messages.h +++ b/extensions/common/extension_messages.h @@ -304,64 +304,80 @@ namespace IPC { template <> struct ParamTraits<URLPattern> { typedef URLPattern param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* p); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p); static void Log(const param_type& p, std::string* l); }; template <> struct ParamTraits<extensions::URLPatternSet> { typedef extensions::URLPatternSet param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* p); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p); static void Log(const param_type& p, std::string* l); }; template <> struct ParamTraits<extensions::APIPermission::ID> { typedef extensions::APIPermission::ID param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* p); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p); static void Log(const param_type& p, std::string* l); }; template <> struct ParamTraits<extensions::APIPermissionSet> { typedef extensions::APIPermissionSet param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct ParamTraits<extensions::ManifestPermissionSet> { typedef extensions::ManifestPermissionSet param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct ParamTraits<HostID> { typedef HostID param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct ParamTraits<ExtensionMsg_PermissionSetStruct> { typedef ExtensionMsg_PermissionSetStruct param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* p); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p); static void Log(const param_type& p, std::string* l); }; 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, base::PickleIterator* iter, param_type* p); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p); static void Log(const param_type& p, std::string* l); }; diff --git a/extensions/common/permissions/api_permission.cc b/extensions/common/permissions/api_permission.cc index 89eaea5..77a1317 100644 --- a/extensions/common/permissions/api_permission.cc +++ b/extensions/common/permissions/api_permission.cc @@ -69,9 +69,9 @@ class SimpleAPIPermission : public APIPermission { return new SimpleAPIPermission(info()); } - void Write(IPC::Message* m) const override {} + void Write(base::Pickle* m) const override {} - bool Read(const IPC::Message* m, base::PickleIterator* iter) override { + bool Read(const base::Pickle* m, base::PickleIterator* iter) override { return true; } diff --git a/extensions/common/permissions/api_permission.h b/extensions/common/permissions/api_permission.h index 5d46ce9..0b6f1a3 100644 --- a/extensions/common/permissions/api_permission.h +++ b/extensions/common/permissions/api_permission.h @@ -324,10 +324,10 @@ class APIPermission { // IPC functions // Writes this into the given IPC message |m|. - virtual void Write(IPC::Message* m) const = 0; + virtual void Write(base::Pickle* m) const = 0; // Reads from the given IPC message |m|. - virtual bool Read(const IPC::Message* m, base::PickleIterator* iter) = 0; + virtual bool Read(const base::Pickle* m, base::PickleIterator* iter) = 0; // Logs this permission. virtual void Log(std::string* log) const = 0; diff --git a/extensions/common/permissions/manifest_permission.cc b/extensions/common/permissions/manifest_permission.cc index a3ba98e..9742138 100644 --- a/extensions/common/permissions/manifest_permission.cc +++ b/extensions/common/permissions/manifest_permission.cc @@ -27,14 +27,14 @@ bool ManifestPermission::Equal(const ManifestPermission* rhs) const { return ToValue()->Equals(rhs->ToValue().get()); } -void ManifestPermission::Write(IPC::Message* m) const { +void ManifestPermission::Write(base::Pickle* m) const { base::ListValue singleton; base::Value* value = ToValue().release(); singleton.Append(value); IPC::WriteParam(m, singleton); } -bool ManifestPermission::Read(const IPC::Message* m, +bool ManifestPermission::Read(const base::Pickle* m, base::PickleIterator* iter) { base::ListValue singleton; if (!IPC::ReadParam(m, iter, &singleton)) diff --git a/extensions/common/permissions/manifest_permission.h b/extensions/common/permissions/manifest_permission.h index 67c41d5..db8f07c 100644 --- a/extensions/common/permissions/manifest_permission.h +++ b/extensions/common/permissions/manifest_permission.h @@ -69,10 +69,10 @@ class ManifestPermission { // IPC functions // Writes this into the given IPC message |m|. - void Write(IPC::Message* m) const; + void Write(base::Pickle* m) const; // Reads from the given IPC message |m|. - bool Read(const IPC::Message* m, base::PickleIterator* iter); + bool Read(const base::Pickle* m, base::PickleIterator* iter); // Logs this permission. void Log(std::string* log) const; diff --git a/extensions/common/permissions/set_disjunction_permission.h b/extensions/common/permissions/set_disjunction_permission.h index 1e124ab..0e97e9d 100644 --- a/extensions/common/permissions/set_disjunction_permission.h +++ b/extensions/common/permissions/set_disjunction_permission.h @@ -147,11 +147,9 @@ class SetDisjunctionPermission : public APIPermission { return scoped_ptr<base::Value>(list); } - void Write(IPC::Message* m) const override { - IPC::WriteParam(m, data_set_); - } + void Write(base::Pickle* m) const override { IPC::WriteParam(m, data_set_); } - bool Read(const IPC::Message* m, base::PickleIterator* iter) override { + bool Read(const base::Pickle* m, base::PickleIterator* iter) override { return IPC::ReadParam(m, iter, &data_set_); } diff --git a/extensions/common/permissions/settings_override_permission.cc b/extensions/common/permissions/settings_override_permission.cc index 7756c5e..43765d2 100644 --- a/extensions/common/permissions/settings_override_permission.cc +++ b/extensions/common/permissions/settings_override_permission.cc @@ -84,9 +84,9 @@ APIPermission* SettingsOverrideAPIPermission::Intersect( return new SettingsOverrideAPIPermission(info(), setting_value_); } -void SettingsOverrideAPIPermission::Write(IPC::Message* m) const {} +void SettingsOverrideAPIPermission::Write(base::Pickle* m) const {} -bool SettingsOverrideAPIPermission::Read(const IPC::Message* m, +bool SettingsOverrideAPIPermission::Read(const base::Pickle* m, base::PickleIterator* iter) { return true; } diff --git a/extensions/common/permissions/settings_override_permission.h b/extensions/common/permissions/settings_override_permission.h index 32dc8b3..81a2730 100644 --- a/extensions/common/permissions/settings_override_permission.h +++ b/extensions/common/permissions/settings_override_permission.h @@ -33,8 +33,8 @@ class SettingsOverrideAPIPermission : public APIPermission { APIPermission* Diff(const APIPermission* rhs) const override; APIPermission* Union(const APIPermission* rhs) const override; APIPermission* Intersect(const APIPermission* rhs) const override; - void Write(IPC::Message* m) const override; - bool Read(const IPC::Message* m, base::PickleIterator* iter) override; + void Write(base::Pickle* m) const override; + bool Read(const base::Pickle* m, base::PickleIterator* iter) override; void Log(std::string* log) const override; private: diff --git a/gpu/ipc/gpu_command_buffer_traits.cc b/gpu/ipc/gpu_command_buffer_traits.cc index 7580774..eecc137 100644 --- a/gpu/ipc/gpu_command_buffer_traits.cc +++ b/gpu/ipc/gpu_command_buffer_traits.cc @@ -31,17 +31,17 @@ namespace IPC { namespace IPC { -void ParamTraits<gpu::CommandBuffer::State> ::Write(Message* m, - const param_type& p) { +void ParamTraits<gpu::CommandBuffer::State>::Write(base::Pickle* m, + const param_type& p) { WriteParam(m, p.get_offset); WriteParam(m, p.token); WriteParam(m, p.error); WriteParam(m, p.generation); } -bool ParamTraits<gpu::CommandBuffer::State> ::Read(const Message* m, - base::PickleIterator* iter, - param_type* p) { +bool ParamTraits<gpu::CommandBuffer::State>::Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p) { if (ReadParam(m, iter, &p->get_offset) && ReadParam(m, iter, &p->token) && ReadParam(m, iter, &p->error) && @@ -57,7 +57,7 @@ void ParamTraits<gpu::CommandBuffer::State> ::Log(const param_type& p, l->append("<CommandBuffer::State>"); } -void ParamTraits<gpu::SyncToken>::Write(Message* m, const param_type& p) { +void ParamTraits<gpu::SyncToken>::Write(base::Pickle* m, const param_type& p) { DCHECK(!p.HasData() || p.verified_flush()); WriteParam(m, p.verified_flush()); @@ -66,7 +66,7 @@ void ParamTraits<gpu::SyncToken>::Write(Message* m, const param_type& p) { WriteParam(m, p.release_count()); } -bool ParamTraits<gpu::SyncToken>::Read(const Message* m, +bool ParamTraits<gpu::SyncToken>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* p) { bool verified_flush = false; @@ -99,13 +99,13 @@ void ParamTraits<gpu::SyncToken>::Log(const param_type& p, std::string* l) { static_cast<unsigned long long>(p.release_count())); } -void ParamTraits<gpu::Mailbox>::Write(Message* m, const param_type& p) { +void ParamTraits<gpu::Mailbox>::Write(base::Pickle* m, const param_type& p) { m->WriteBytes(p.name, sizeof(p.name)); } -bool ParamTraits<gpu::Mailbox> ::Read(const Message* m, - base::PickleIterator* iter, - param_type* p) { +bool ParamTraits<gpu::Mailbox>::Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p) { const char* bytes = NULL; if (!iter->ReadBytes(&bytes, sizeof(p->name))) return false; @@ -119,15 +119,16 @@ void ParamTraits<gpu::Mailbox>::Log(const param_type& p, std::string* l) { *l += base::StringPrintf("%02x", p.name[i]); } -void ParamTraits<gpu::MailboxHolder>::Write(Message* m, const param_type& p) { +void ParamTraits<gpu::MailboxHolder>::Write(base::Pickle* m, + const param_type& p) { WriteParam(m, p.mailbox); WriteParam(m, p.sync_token); WriteParam(m, p.texture_target); } -bool ParamTraits<gpu::MailboxHolder> ::Read(const Message* m, - base::PickleIterator* iter, - param_type* p) { +bool ParamTraits<gpu::MailboxHolder>::Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p) { if (!ReadParam(m, iter, &p->mailbox) || !ReadParam(m, iter, &p->sync_token) || !ReadParam(m, iter, &p->texture_target)) return false; @@ -140,14 +141,14 @@ void ParamTraits<gpu::MailboxHolder>::Log(const param_type& p, std::string* l) { *l += base::StringPrintf(":%04x@", p.texture_target); } -void ParamTraits<gpu::ValueState>::Write(Message* m, const param_type& p) { +void ParamTraits<gpu::ValueState>::Write(base::Pickle* m, const param_type& p) { m->WriteData(reinterpret_cast<const char*>(&p), sizeof(gpu::ValueState)); } -bool ParamTraits<gpu::ValueState> ::Read(const Message* m, - base::PickleIterator* iter, - param_type* p) { +bool ParamTraits<gpu::ValueState>::Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p) { int length; const char* data = NULL; if (!iter->ReadData(&data, &length) || length != sizeof(gpu::ValueState)) diff --git a/gpu/ipc/gpu_command_buffer_traits.h b/gpu/ipc/gpu_command_buffer_traits.h index b726f7e..f66a8cf 100644 --- a/gpu/ipc/gpu_command_buffer_traits.h +++ b/gpu/ipc/gpu_command_buffer_traits.h @@ -22,40 +22,50 @@ namespace IPC { 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, base::PickleIterator* iter, param_type* p); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p); static void Log(const param_type& p, std::string* l); }; template <> struct GPU_EXPORT ParamTraits<gpu::SyncToken> { typedef gpu::SyncToken param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* p); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p); static void Log(const param_type& p, std::string* l); }; template<> struct GPU_EXPORT ParamTraits<gpu::Mailbox> { typedef gpu::Mailbox param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* p); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p); static void Log(const param_type& p, std::string* l); }; template <> struct GPU_EXPORT ParamTraits<gpu::MailboxHolder> { typedef gpu::MailboxHolder param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* p); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p); static void Log(const param_type& p, std::string* l); }; template <> struct GPU_EXPORT ParamTraits<gpu::ValueState> { typedef gpu::ValueState param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* p); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p); static void Log(const param_type& p, std::string* l); }; diff --git a/ipc/handle_win.cc b/ipc/handle_win.cc index f964c83..60fa54c 100644 --- a/ipc/handle_win.cc +++ b/ipc/handle_win.cc @@ -21,7 +21,7 @@ HandleWin::HandleWin(const HANDLE& handle, Permissions permissions) : handle_(handle), permissions_(permissions) {} // static -void ParamTraits<HandleWin>::Write(Message* m, const param_type& p) { +void ParamTraits<HandleWin>::Write(base::Pickle* m, const param_type& p) { scoped_refptr<IPC::internal::HandleAttachmentWin> attachment( new IPC::internal::HandleAttachmentWin(p.get_handle(), p.get_permissions())); @@ -30,16 +30,18 @@ void ParamTraits<HandleWin>::Write(Message* m, const param_type& p) { } // static -bool ParamTraits<HandleWin>::Read(const Message* m, +bool ParamTraits<HandleWin>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { - scoped_refptr<MessageAttachment> attachment; - if (!m->ReadAttachment(iter, &attachment)) + scoped_refptr<base::Pickle::Attachment> base_attachment; + if (!m->ReadAttachment(iter, &base_attachment)) return false; + MessageAttachment* attachment = + static_cast<MessageAttachment*>(base_attachment.get()); if (attachment->GetType() != MessageAttachment::TYPE_BROKERABLE_ATTACHMENT) return false; BrokerableAttachment* brokerable_attachment = - static_cast<BrokerableAttachment*>(attachment.get()); + static_cast<BrokerableAttachment*>(attachment); if (brokerable_attachment->GetBrokerableType() != BrokerableAttachment::WIN_HANDLE) { return false; diff --git a/ipc/handle_win.h b/ipc/handle_win.h index 38cddae..2fb5b54 100644 --- a/ipc/handle_win.h +++ b/ipc/handle_win.h @@ -13,6 +13,7 @@ #include "ipc/ipc_param_traits.h" namespace base { +class Pickle; class PickleIterator; } // namespace base @@ -56,8 +57,10 @@ class IPC_EXPORT HandleWin { template <> struct IPC_EXPORT ParamTraits<HandleWin> { typedef HandleWin param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* p); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p); static void Log(const param_type& p, std::string* l); }; diff --git a/ipc/ipc_channel_proxy_unittest_messages.h b/ipc/ipc_channel_proxy_unittest_messages.h index 20405ed..288ce53 100644 --- a/ipc/ipc_channel_proxy_unittest_messages.h +++ b/ipc/ipc_channel_proxy_unittest_messages.h @@ -17,8 +17,10 @@ namespace IPC { template <> struct ParamTraits<BadType> { - static void Write(Message* m, const BadType& p) {} - static bool Read(const Message* m, base::PickleIterator* iter, BadType* r) { + static void Write(base::Pickle* m, const BadType& p) {} + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + BadType* r) { return false; } static void Log(const BadType& p, std::string* l) {} diff --git a/ipc/ipc_message.cc b/ipc/ipc_message.cc index 71f7299..289f08d 100644 --- a/ipc/ipc_message.cc +++ b/ipc/ipc_message.cc @@ -240,11 +240,13 @@ bool Message::AddPlaceholderBrokerableAttachmentWithId( return attachment_set()->AddAttachment(attachment); } -bool Message::WriteAttachment(scoped_refptr<MessageAttachment> attachment) { +bool Message::WriteAttachment( + scoped_refptr<base::Pickle::Attachment> attachment) { bool brokerable; size_t index; - bool success = - attachment_set()->AddAttachment(attachment, &index, &brokerable); + bool success = attachment_set()->AddAttachment( + make_scoped_refptr(static_cast<MessageAttachment*>(attachment.get())), + &index, &brokerable); DCHECK(success); // Write the type of descriptor. @@ -264,7 +266,7 @@ bool Message::WriteAttachment(scoped_refptr<MessageAttachment> attachment) { bool Message::ReadAttachment( base::PickleIterator* iter, - scoped_refptr<MessageAttachment>* attachment) const { + scoped_refptr<base::Pickle::Attachment>* attachment) const { bool brokerable; if (!iter->ReadBool(&brokerable)) return false; diff --git a/ipc/ipc_message.h b/ipc/ipc_message.h index a6c641d..56c3a46 100644 --- a/ipc/ipc_message.h +++ b/ipc/ipc_message.h @@ -221,13 +221,15 @@ class IPC_EXPORT Message : public base::Pickle { // WriteAttachment appends |attachment| to the end of the set. It returns // false iff the set is full. - bool WriteAttachment(scoped_refptr<MessageAttachment> attachment); + bool WriteAttachment( + scoped_refptr<base::Pickle::Attachment> attachment) override; // ReadAttachment parses an attachment given the parsing state |iter| and // writes it to |*attachment|. It returns true on success. - bool ReadAttachment(base::PickleIterator* iter, - scoped_refptr<MessageAttachment>* attachment) const; + bool ReadAttachment( + base::PickleIterator* iter, + scoped_refptr<base::Pickle::Attachment>* attachment) const override; // Returns true if there are any attachment in this message. - bool HasAttachments() const; + bool HasAttachments() const override; // Returns true if there are any MojoHandleAttachments in this message. bool HasMojoHandles() const; // Whether the message has any brokerable attachments. diff --git a/ipc/ipc_message_attachment.h b/ipc/ipc_message_attachment.h index dda0630..7f7137d 100644 --- a/ipc/ipc_message_attachment.h +++ b/ipc/ipc_message_attachment.h @@ -8,6 +8,7 @@ #include "base/files/file.h" #include "base/macros.h" #include "base/memory/ref_counted.h" +#include "base/pickle.h" #include "build/build_config.h" #include "ipc/ipc_export.h" @@ -15,8 +16,7 @@ namespace IPC { // Auxiliary data sent with |Message|. This can be a platform file descriptor // or a mojo |MessagePipe|. |GetType()| returns the type of the subclass. -class IPC_EXPORT MessageAttachment - : public base::RefCountedThreadSafe<MessageAttachment> { +class IPC_EXPORT MessageAttachment : public base::Pickle::Attachment { public: enum Type { TYPE_PLATFORM_FILE, // The instance is |PlatformFileAttachment|. @@ -33,7 +33,7 @@ class IPC_EXPORT MessageAttachment protected: friend class base::RefCountedThreadSafe<MessageAttachment>; MessageAttachment(); - virtual ~MessageAttachment(); + ~MessageAttachment() override; DISALLOW_COPY_AND_ASSIGN(MessageAttachment); }; diff --git a/ipc/ipc_message_utils.cc b/ipc/ipc_message_utils.cc index 277c2ff..6c829c2 100644 --- a/ipc/ipc_message_utils.cc +++ b/ipc/ipc_message_utils.cc @@ -67,12 +67,12 @@ void LogBytes(const std::vector<CharType>& data, std::string* out) { #endif } -bool ReadValue(const Message* m, +bool ReadValue(const base::Pickle* m, base::PickleIterator* iter, base::Value** value, int recursion); -void WriteValue(Message* m, const base::Value* value, int recursion) { +void WriteValue(base::Pickle* m, const base::Value* value, int recursion) { bool result; if (recursion > kMaxRecursionDepth) { LOG(WARNING) << "Max recursion depth hit in WriteValue."; @@ -145,7 +145,7 @@ void WriteValue(Message* m, const base::Value* value, int recursion) { // Helper for ReadValue that reads a DictionaryValue into a pre-allocated // object. -bool ReadDictionaryValue(const Message* m, +bool ReadDictionaryValue(const base::Pickle* m, base::PickleIterator* iter, base::DictionaryValue* value, int recursion) { @@ -167,7 +167,7 @@ bool ReadDictionaryValue(const Message* m, // Helper for ReadValue that reads a ReadListValue into a pre-allocated // object. -bool ReadListValue(const Message* m, +bool ReadListValue(const base::Pickle* m, base::PickleIterator* iter, base::ListValue* value, int recursion) { @@ -185,7 +185,7 @@ bool ReadListValue(const Message* m, return true; } -bool ReadValue(const Message* m, +bool ReadValue(const base::Pickle* m, base::PickleIterator* iter, base::Value** value, int recursion) { @@ -278,13 +278,13 @@ void ParamTraits<bool>::Log(const param_type& p, std::string* l) { l->append(p ? "true" : "false"); } -void ParamTraits<signed char>::Write(Message* m, const param_type& p) { +void ParamTraits<signed char>::Write(base::Pickle* m, const param_type& p) { m->WriteBytes(&p, sizeof(param_type)); } -bool ParamTraits<signed char>::Read(const Message* m, - base::PickleIterator* iter, - param_type* r) { +bool ParamTraits<signed char>::Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r) { const char* data; if (!iter->ReadBytes(&data, sizeof(param_type))) return false; @@ -296,11 +296,11 @@ void ParamTraits<signed char>::Log(const param_type& p, std::string* l) { l->append(base::IntToString(p)); } -void ParamTraits<unsigned char>::Write(Message* m, const param_type& p) { +void ParamTraits<unsigned char>::Write(base::Pickle* m, const param_type& p) { m->WriteBytes(&p, sizeof(param_type)); } -bool ParamTraits<unsigned char>::Read(const Message* m, +bool ParamTraits<unsigned char>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { const char* data; @@ -314,11 +314,11 @@ void ParamTraits<unsigned char>::Log(const param_type& p, std::string* l) { l->append(base::UintToString(p)); } -void ParamTraits<unsigned short>::Write(Message* m, const param_type& p) { +void ParamTraits<unsigned short>::Write(base::Pickle* m, const param_type& p) { m->WriteBytes(&p, sizeof(param_type)); } -bool ParamTraits<unsigned short>::Read(const Message* m, +bool ParamTraits<unsigned short>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { const char* data; @@ -360,11 +360,11 @@ void ParamTraits<float>::Log(const param_type& p, std::string* l) { l->append(base::StringPrintf("%e", p)); } -void ParamTraits<double>::Write(Message* m, const param_type& p) { +void ParamTraits<double>::Write(base::Pickle* m, const param_type& p) { m->WriteBytes(reinterpret_cast<const char*>(&p), sizeof(param_type)); } -bool ParamTraits<double>::Read(const Message* m, +bool ParamTraits<double>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { const char *data; @@ -389,7 +389,8 @@ void ParamTraits<base::string16>::Log(const param_type& p, std::string* l) { l->append(base::UTF16ToUTF8(p)); } -void ParamTraits<std::vector<char> >::Write(Message* m, const param_type& p) { +void ParamTraits<std::vector<char>>::Write(base::Pickle* m, + const param_type& p) { if (p.empty()) { m->WriteData(NULL, 0); } else { @@ -397,7 +398,7 @@ void ParamTraits<std::vector<char> >::Write(Message* m, const param_type& p) { } } -bool ParamTraits<std::vector<char>>::Read(const Message* m, +bool ParamTraits<std::vector<char>>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { const char *data; @@ -414,8 +415,8 @@ void ParamTraits<std::vector<char> >::Log(const param_type& p, std::string* l) { LogBytes(p, l); } -void ParamTraits<std::vector<unsigned char> >::Write(Message* m, - const param_type& p) { +void ParamTraits<std::vector<unsigned char>>::Write(base::Pickle* m, + const param_type& p) { if (p.empty()) { m->WriteData(NULL, 0); } else { @@ -424,7 +425,7 @@ void ParamTraits<std::vector<unsigned char> >::Write(Message* m, } } -bool ParamTraits<std::vector<unsigned char>>::Read(const Message* m, +bool ParamTraits<std::vector<unsigned char>>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { const char *data; @@ -442,7 +443,8 @@ void ParamTraits<std::vector<unsigned char> >::Log(const param_type& p, LogBytes(p, l); } -void ParamTraits<std::vector<bool> >::Write(Message* m, const param_type& p) { +void ParamTraits<std::vector<bool>>::Write(base::Pickle* m, + const param_type& p) { WriteParam(m, static_cast<int>(p.size())); // Cast to bool below is required because libc++'s // vector<bool>::const_reference is different from bool, and we want to avoid @@ -451,7 +453,7 @@ void ParamTraits<std::vector<bool> >::Write(Message* m, const param_type& p) { WriteParam(m, static_cast<bool>(p[i])); } -bool ParamTraits<std::vector<bool>>::Read(const Message* m, +bool ParamTraits<std::vector<bool>>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { int size; @@ -477,13 +479,13 @@ void ParamTraits<std::vector<bool> >::Log(const param_type& p, std::string* l) { } void ParamTraits<BrokerableAttachment::AttachmentId>::Write( - Message* m, + base::Pickle* m, const param_type& p) { m->WriteBytes(p.nonce, BrokerableAttachment::kNonceSize); } bool ParamTraits<BrokerableAttachment::AttachmentId>::Read( - const Message* m, + const base::Pickle* m, base::PickleIterator* iter, param_type* r) { const char* data; @@ -498,12 +500,12 @@ void ParamTraits<BrokerableAttachment::AttachmentId>::Log(const param_type& p, l->append(base::HexEncode(p.nonce, BrokerableAttachment::kNonceSize)); } -void ParamTraits<base::DictionaryValue>::Write(Message* m, +void ParamTraits<base::DictionaryValue>::Write(base::Pickle* m, const param_type& p) { WriteValue(m, &p, 0); } -bool ParamTraits<base::DictionaryValue>::Read(const Message* m, +bool ParamTraits<base::DictionaryValue>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { int type; @@ -521,7 +523,8 @@ void ParamTraits<base::DictionaryValue>::Log(const param_type& p, } #if defined(OS_POSIX) -void ParamTraits<base::FileDescriptor>::Write(Message* m, const param_type& p) { +void ParamTraits<base::FileDescriptor>::Write(base::Pickle* m, + const param_type& p) { const bool valid = p.fd >= 0; WriteParam(m, valid); @@ -538,7 +541,7 @@ void ParamTraits<base::FileDescriptor>::Write(Message* m, const param_type& p) { } } -bool ParamTraits<base::FileDescriptor>::Read(const Message* m, +bool ParamTraits<base::FileDescriptor>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { *r = base::FileDescriptor(); @@ -551,11 +554,13 @@ bool ParamTraits<base::FileDescriptor>::Read(const Message* m, if (!valid) return true; - scoped_refptr<MessageAttachment> attachment; + scoped_refptr<base::Pickle::Attachment> attachment; if (!m->ReadAttachment(iter, &attachment)) return false; - *r = base::FileDescriptor(attachment->TakePlatformFile(), true); + *r = base::FileDescriptor( + static_cast<MessageAttachment*>(attachment.get())->TakePlatformFile(), + true); return true; } @@ -570,7 +575,7 @@ void ParamTraits<base::FileDescriptor>::Log(const param_type& p, #endif // defined(OS_POSIX) #if defined(OS_MACOSX) && !defined(OS_IOS) -void ParamTraits<base::SharedMemoryHandle>::Write(Message* m, +void ParamTraits<base::SharedMemoryHandle>::Write(base::Pickle* m, const param_type& p) { m->WriteInt(p.GetType()); @@ -595,7 +600,7 @@ void ParamTraits<base::SharedMemoryHandle>::Write(Message* m, } } -bool ParamTraits<base::SharedMemoryHandle>::Read(const Message* m, +bool ParamTraits<base::SharedMemoryHandle>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { base::SharedMemoryHandle::TypeWireFormat type; @@ -658,7 +663,7 @@ void ParamTraits<base::SharedMemoryHandle>::Log(const param_type& p, } #elif defined(OS_WIN) -void ParamTraits<base::SharedMemoryHandle>::Write(Message* m, +void ParamTraits<base::SharedMemoryHandle>::Write(base::Pickle* m, const param_type& p) { m->WriteBool(p.NeedsBrokering()); @@ -675,7 +680,7 @@ void ParamTraits<base::SharedMemoryHandle>::Write(Message* m, } } -bool ParamTraits<base::SharedMemoryHandle>::Read(const Message* m, +bool ParamTraits<base::SharedMemoryHandle>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { bool needs_brokering; @@ -707,11 +712,11 @@ void ParamTraits<base::SharedMemoryHandle>::Log(const param_type& p, } #endif // defined(OS_MACOSX) && !defined(OS_IOS) -void ParamTraits<base::FilePath>::Write(Message* m, const param_type& p) { +void ParamTraits<base::FilePath>::Write(base::Pickle* m, const param_type& p) { p.WriteToPickle(m); } -bool ParamTraits<base::FilePath>::Read(const Message* m, +bool ParamTraits<base::FilePath>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { return r->ReadFromPickle(iter); @@ -721,11 +726,11 @@ void ParamTraits<base::FilePath>::Log(const param_type& p, std::string* l) { ParamTraits<base::FilePath::StringType>::Log(p.value(), l); } -void ParamTraits<base::ListValue>::Write(Message* m, const param_type& p) { +void ParamTraits<base::ListValue>::Write(base::Pickle* m, const param_type& p) { WriteValue(m, &p, 0); } -bool ParamTraits<base::ListValue>::Read(const Message* m, +bool ParamTraits<base::ListValue>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { int type; @@ -741,13 +746,13 @@ void ParamTraits<base::ListValue>::Log(const param_type& p, std::string* l) { l->append(json); } -void ParamTraits<base::NullableString16>::Write(Message* m, +void ParamTraits<base::NullableString16>::Write(base::Pickle* m, const param_type& p) { WriteParam(m, p.string()); WriteParam(m, p.is_null()); } -bool ParamTraits<base::NullableString16>::Read(const Message* m, +bool ParamTraits<base::NullableString16>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { base::string16 string; @@ -769,7 +774,7 @@ void ParamTraits<base::NullableString16>::Log(const param_type& p, l->append(")"); } -void ParamTraits<base::File::Info>::Write(Message* m, +void ParamTraits<base::File::Info>::Write(base::Pickle* m, const param_type& p) { WriteParam(m, p.size); WriteParam(m, p.is_directory); @@ -778,7 +783,7 @@ void ParamTraits<base::File::Info>::Write(Message* m, WriteParam(m, p.creation_time.ToDoubleT()); } -bool ParamTraits<base::File::Info>::Read(const Message* m, +bool ParamTraits<base::File::Info>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* p) { double last_modified, last_accessed, creation_time; @@ -809,11 +814,11 @@ void ParamTraits<base::File::Info>::Log(const param_type& p, l->append(")"); } -void ParamTraits<base::Time>::Write(Message* m, const param_type& p) { +void ParamTraits<base::Time>::Write(base::Pickle* m, const param_type& p) { ParamTraits<int64_t>::Write(m, p.ToInternalValue()); } -bool ParamTraits<base::Time>::Read(const Message* m, +bool ParamTraits<base::Time>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { int64_t value; @@ -827,11 +832,11 @@ void ParamTraits<base::Time>::Log(const param_type& p, std::string* l) { ParamTraits<int64_t>::Log(p.ToInternalValue(), l); } -void ParamTraits<base::TimeDelta>::Write(Message* m, const param_type& p) { +void ParamTraits<base::TimeDelta>::Write(base::Pickle* m, const param_type& p) { ParamTraits<int64_t>::Write(m, p.ToInternalValue()); } -bool ParamTraits<base::TimeDelta>::Read(const Message* m, +bool ParamTraits<base::TimeDelta>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { int64_t value; @@ -846,11 +851,11 @@ void ParamTraits<base::TimeDelta>::Log(const param_type& p, std::string* l) { ParamTraits<int64_t>::Log(p.ToInternalValue(), l); } -void ParamTraits<base::TimeTicks>::Write(Message* m, const param_type& p) { +void ParamTraits<base::TimeTicks>::Write(base::Pickle* m, const param_type& p) { ParamTraits<int64_t>::Write(m, p.ToInternalValue()); } -bool ParamTraits<base::TimeTicks>::Read(const Message* m, +bool ParamTraits<base::TimeTicks>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { int64_t value; @@ -865,7 +870,8 @@ void ParamTraits<base::TimeTicks>::Log(const param_type& p, std::string* l) { ParamTraits<int64_t>::Log(p.ToInternalValue(), l); } -void ParamTraits<IPC::ChannelHandle>::Write(Message* m, const param_type& p) { +void ParamTraits<IPC::ChannelHandle>::Write(base::Pickle* m, + const param_type& p) { #if defined(OS_WIN) // On Windows marshalling pipe handle is not supported. DCHECK(p.pipe.handle == NULL); @@ -876,7 +882,7 @@ void ParamTraits<IPC::ChannelHandle>::Write(Message* m, const param_type& p) { #endif } -bool ParamTraits<IPC::ChannelHandle>::Read(const Message* m, +bool ParamTraits<IPC::ChannelHandle>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { return ReadParam(m, iter, &r->name) @@ -896,7 +902,7 @@ void ParamTraits<IPC::ChannelHandle>::Log(const param_type& p, l->append(")"); } -void ParamTraits<LogData>::Write(Message* m, const param_type& p) { +void ParamTraits<LogData>::Write(base::Pickle* m, const param_type& p) { WriteParam(m, p.channel); WriteParam(m, p.routing_id); WriteParam(m, p.type); @@ -908,7 +914,7 @@ void ParamTraits<LogData>::Write(Message* m, const param_type& p) { WriteParam(m, p.params); } -bool ParamTraits<LogData>::Read(const Message* m, +bool ParamTraits<LogData>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { return @@ -927,7 +933,7 @@ void ParamTraits<LogData>::Log(const param_type& p, std::string* l) { // Doesn't make sense to implement this! } -void ParamTraits<Message>::Write(Message* m, const Message& p) { +void ParamTraits<Message>::Write(base::Pickle* m, const Message& p) { #if defined(OS_POSIX) // We don't serialize the file descriptors in the nested message, so there // better not be any. @@ -950,7 +956,7 @@ void ParamTraits<Message>::Write(Message* m, const Message& p) { m->WriteData(p.payload(), static_cast<uint32_t>(p.payload_size())); } -bool ParamTraits<Message>::Read(const Message* m, +bool ParamTraits<Message>::Read(const base::Pickle* m, base::PickleIterator* iter, Message* r) { uint32_t routing_id, type, flags; @@ -975,11 +981,11 @@ void ParamTraits<Message>::Log(const Message& p, std::string* l) { #if defined(OS_WIN) // Note that HWNDs/HANDLE/HCURSOR/HACCEL etc are always 32 bits, even on 64 // bit systems. That's why we use the Windows macros to convert to 32 bits. -void ParamTraits<HANDLE>::Write(Message* m, const param_type& p) { +void ParamTraits<HANDLE>::Write(base::Pickle* m, const param_type& p) { m->WriteInt(HandleToLong(p)); } -bool ParamTraits<HANDLE>::Read(const Message* m, +bool ParamTraits<HANDLE>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { int32_t temp; @@ -993,11 +999,11 @@ void ParamTraits<HANDLE>::Log(const param_type& p, std::string* l) { l->append(base::StringPrintf("0x%p", p)); } -void ParamTraits<LOGFONT>::Write(Message* m, const param_type& p) { +void ParamTraits<LOGFONT>::Write(base::Pickle* m, const param_type& p) { m->WriteData(reinterpret_cast<const char*>(&p), sizeof(LOGFONT)); } -bool ParamTraits<LOGFONT>::Read(const Message* m, +bool ParamTraits<LOGFONT>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { const char *data; @@ -1018,11 +1024,11 @@ void ParamTraits<LOGFONT>::Log(const param_type& p, std::string* l) { l->append(base::StringPrintf("<LOGFONT>")); } -void ParamTraits<MSG>::Write(Message* m, const param_type& p) { +void ParamTraits<MSG>::Write(base::Pickle* m, const param_type& p) { m->WriteData(reinterpret_cast<const char*>(&p), sizeof(MSG)); } -bool ParamTraits<MSG>::Read(const Message* m, +bool ParamTraits<MSG>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { const char *data; diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h index 69ea7cb..5654e75 100644 --- a/ipc/ipc_message_utils.h +++ b/ipc/ipc_message_utils.h @@ -100,14 +100,15 @@ struct NoParams { }; template <class P> -static inline void WriteParam(Message* m, const P& p) { +static inline void WriteParam(base::Pickle* m, const P& p) { typedef typename SimilarTypeTraits<P>::Type Type; ParamTraits<Type>::Write(m, static_cast<const Type& >(p)); } template <class P> -static inline bool WARN_UNUSED_RESULT -ReadParam(const Message* m, base::PickleIterator* iter, P* p) { +static inline bool WARN_UNUSED_RESULT ReadParam(const base::Pickle* m, + base::PickleIterator* iter, + P* p) { typedef typename SimilarTypeTraits<P>::Type Type; return ParamTraits<Type>::Read(m, iter, reinterpret_cast<Type* >(p)); } @@ -123,10 +124,8 @@ static inline void LogParam(const P& p, std::string* l) { template <> struct ParamTraits<bool> { typedef bool param_type; - static void Write(Message* m, const param_type& p) { - m->WriteBool(p); - } - static bool Read(const Message* m, + static void Write(base::Pickle* m, const param_type& p) { m->WriteBool(p); } + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { return iter->ReadBool(r); @@ -137,24 +136,28 @@ struct ParamTraits<bool> { template <> struct IPC_EXPORT ParamTraits<signed char> { typedef signed char param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct IPC_EXPORT ParamTraits<unsigned char> { typedef unsigned char param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; 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, + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); @@ -163,10 +166,8 @@ struct IPC_EXPORT ParamTraits<unsigned short> { template <> struct ParamTraits<int> { typedef int param_type; - static void Write(Message* m, const param_type& p) { - m->WriteInt(p); - } - static bool Read(const Message* m, + static void Write(base::Pickle* m, const param_type& p) { m->WriteInt(p); } + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { return iter->ReadInt(r); @@ -177,10 +178,8 @@ struct ParamTraits<int> { template <> struct ParamTraits<unsigned int> { typedef unsigned int param_type; - static void Write(Message* m, const param_type& p) { - m->WriteInt(p); - } - static bool Read(const Message* m, + static void Write(base::Pickle* m, const param_type& p) { m->WriteInt(p); } + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { return iter->ReadInt(reinterpret_cast<int*>(r)); @@ -191,10 +190,10 @@ struct ParamTraits<unsigned int> { template <> struct ParamTraits<long> { typedef long param_type; - static void Write(Message* m, const param_type& p) { + static void Write(base::Pickle* m, const param_type& p) { m->WriteLongUsingDangerousNonPortableLessPersistableForm(p); } - static bool Read(const Message* m, + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { return iter->ReadLong(r); @@ -205,10 +204,10 @@ struct ParamTraits<long> { template <> struct ParamTraits<unsigned long> { typedef unsigned long param_type; - static void Write(Message* m, const param_type& p) { + static void Write(base::Pickle* m, const param_type& p) { m->WriteLongUsingDangerousNonPortableLessPersistableForm(p); } - static bool Read(const Message* m, + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { return iter->ReadLong(reinterpret_cast<long*>(r)); @@ -219,10 +218,10 @@ struct ParamTraits<unsigned long> { template <> struct ParamTraits<long long> { typedef long long param_type; - static void Write(Message* m, const param_type& p) { + static void Write(base::Pickle* m, const param_type& p) { m->WriteInt64(static_cast<int64_t>(p)); } - static bool Read(const Message* m, + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { return iter->ReadInt64(reinterpret_cast<int64_t*>(r)); @@ -233,10 +232,8 @@ struct ParamTraits<long long> { template <> struct ParamTraits<unsigned long long> { typedef unsigned long long param_type; - static void Write(Message* m, const param_type& p) { - m->WriteInt64(p); - } - static bool Read(const Message* m, + static void Write(base::Pickle* m, const param_type& p) { m->WriteInt64(p); } + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { return iter->ReadInt64(reinterpret_cast<int64_t*>(r)); @@ -250,10 +247,8 @@ struct ParamTraits<unsigned long long> { template <> struct IPC_EXPORT ParamTraits<float> { typedef float param_type; - static void Write(Message* m, const param_type& p) { - m->WriteFloat(p); - } - static bool Read(const Message* m, + static void Write(base::Pickle* m, const param_type& p) { m->WriteFloat(p); } + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { return iter->ReadFloat(r); @@ -264,8 +259,8 @@ struct IPC_EXPORT ParamTraits<float> { template <> struct IPC_EXPORT ParamTraits<double> { typedef double param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); @@ -276,10 +271,8 @@ struct IPC_EXPORT ParamTraits<double> { template <> struct ParamTraits<std::string> { typedef std::string param_type; - static void Write(Message* m, const param_type& p) { - m->WriteString(p); - } - static bool Read(const Message* m, + static void Write(base::Pickle* m, const param_type& p) { m->WriteString(p); } + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { return iter->ReadString(r); @@ -290,10 +283,10 @@ struct ParamTraits<std::string> { template <> struct ParamTraits<base::string16> { typedef base::string16 param_type; - static void Write(Message* m, const param_type& p) { + static void Write(base::Pickle* m, const param_type& p) { m->WriteString16(p); } - static bool Read(const Message* m, + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { return iter->ReadString16(r); @@ -304,8 +297,8 @@ struct ParamTraits<base::string16> { template <> struct IPC_EXPORT ParamTraits<std::vector<char> > { typedef std::vector<char> param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message*, + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle*, base::PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); @@ -314,8 +307,8 @@ struct IPC_EXPORT ParamTraits<std::vector<char> > { template <> struct IPC_EXPORT ParamTraits<std::vector<unsigned char> > { typedef std::vector<unsigned char> param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); @@ -324,8 +317,8 @@ struct IPC_EXPORT ParamTraits<std::vector<unsigned char> > { template <> struct IPC_EXPORT ParamTraits<std::vector<bool> > { typedef std::vector<bool> param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); @@ -334,12 +327,12 @@ struct IPC_EXPORT ParamTraits<std::vector<bool> > { template <class P> struct ParamTraits<std::vector<P> > { typedef std::vector<P> param_type; - static void Write(Message* m, const param_type& p) { + static void Write(base::Pickle* m, const param_type& p) { WriteParam(m, static_cast<int>(p.size())); for (size_t i = 0; i < p.size(); i++) WriteParam(m, p[i]); } - static bool Read(const Message* m, + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { int size; @@ -368,13 +361,13 @@ struct ParamTraits<std::vector<P> > { template <class P> struct ParamTraits<std::set<P> > { typedef std::set<P> param_type; - static void Write(Message* m, const param_type& p) { + static void Write(base::Pickle* m, const param_type& p) { WriteParam(m, static_cast<int>(p.size())); typename param_type::const_iterator iter; for (iter = p.begin(); iter != p.end(); ++iter) WriteParam(m, *iter); } - static bool Read(const Message* m, + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { int size; @@ -396,7 +389,7 @@ struct ParamTraits<std::set<P> > { template <class K, class V, class C, class A> struct ParamTraits<std::map<K, V, C, A> > { typedef std::map<K, V, C, A> param_type; - static void Write(Message* m, const param_type& p) { + static void Write(base::Pickle* m, const param_type& p) { WriteParam(m, static_cast<int>(p.size())); typename param_type::const_iterator iter; for (iter = p.begin(); iter != p.end(); ++iter) { @@ -404,7 +397,7 @@ struct ParamTraits<std::map<K, V, C, A> > { WriteParam(m, iter->second); } } - static bool Read(const Message* m, + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { int size; @@ -428,11 +421,11 @@ struct ParamTraits<std::map<K, V, C, A> > { template <class A, class B> struct ParamTraits<std::pair<A, B> > { typedef std::pair<A, B> param_type; - static void Write(Message* m, const param_type& p) { + static void Write(base::Pickle* m, const param_type& p) { WriteParam(m, p.first); WriteParam(m, p.second); } - static bool Read(const Message* m, + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { return ReadParam(m, iter, &r->first) && ReadParam(m, iter, &r->second); @@ -450,8 +443,10 @@ struct ParamTraits<std::pair<A, B> > { template <> struct IPC_EXPORT ParamTraits<BrokerableAttachment::AttachmentId> { typedef BrokerableAttachment::AttachmentId param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -460,8 +455,8 @@ struct IPC_EXPORT ParamTraits<BrokerableAttachment::AttachmentId> { 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, + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); @@ -486,8 +481,8 @@ struct IPC_EXPORT ParamTraits<base::DictionaryValue> { 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, + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); @@ -498,8 +493,10 @@ struct IPC_EXPORT ParamTraits<base::FileDescriptor> { template <> struct IPC_EXPORT ParamTraits<base::SharedMemoryHandle> { typedef base::SharedMemoryHandle param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; #endif // (defined(OS_MACOSX) && !defined(OS_IOS)) || defined(OS_WIN) @@ -507,8 +504,8 @@ struct IPC_EXPORT ParamTraits<base::SharedMemoryHandle> { template <> struct IPC_EXPORT ParamTraits<base::FilePath> { typedef base::FilePath param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); @@ -517,8 +514,8 @@ struct IPC_EXPORT ParamTraits<base::FilePath> { 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, + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); @@ -527,8 +524,8 @@ struct IPC_EXPORT ParamTraits<base::ListValue> { template <> struct IPC_EXPORT ParamTraits<base::NullableString16> { typedef base::NullableString16 param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); @@ -537,8 +534,8 @@ struct IPC_EXPORT ParamTraits<base::NullableString16> { template <> struct IPC_EXPORT ParamTraits<base::File::Info> { typedef base::File::Info param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); @@ -559,8 +556,8 @@ struct SimilarTypeTraits<HWND> { 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, + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); @@ -569,8 +566,8 @@ struct IPC_EXPORT ParamTraits<base::Time> { 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, + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); @@ -579,8 +576,8 @@ struct IPC_EXPORT ParamTraits<base::TimeDelta> { 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, + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); @@ -589,9 +586,8 @@ struct IPC_EXPORT ParamTraits<base::TimeTicks> { template <> struct ParamTraits<base::Tuple<>> { typedef base::Tuple<> param_type; - static void Write(Message* m, const param_type& p) { - } - static bool Read(const Message* m, + static void Write(base::Pickle* m, const param_type& p) {} + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { return true; @@ -603,10 +599,10 @@ struct ParamTraits<base::Tuple<>> { template <class A> struct ParamTraits<base::Tuple<A>> { typedef base::Tuple<A> param_type; - static void Write(Message* m, const param_type& p) { + static void Write(base::Pickle* m, const param_type& p) { WriteParam(m, base::get<0>(p)); } - static bool Read(const Message* m, + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { return ReadParam(m, iter, &base::get<0>(*r)); @@ -619,11 +615,11 @@ struct ParamTraits<base::Tuple<A>> { template <class A, class B> struct ParamTraits<base::Tuple<A, B>> { typedef base::Tuple<A, B> param_type; - static void Write(Message* m, const param_type& p) { + static void Write(base::Pickle* m, const param_type& p) { WriteParam(m, base::get<0>(p)); WriteParam(m, base::get<1>(p)); } - static bool Read(const Message* m, + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { return (ReadParam(m, iter, &base::get<0>(*r)) && @@ -639,12 +635,12 @@ struct ParamTraits<base::Tuple<A, B>> { template <class A, class B, class C> struct ParamTraits<base::Tuple<A, B, C>> { typedef base::Tuple<A, B, C> param_type; - static void Write(Message* m, const param_type& p) { + static void Write(base::Pickle* m, const param_type& p) { WriteParam(m, base::get<0>(p)); WriteParam(m, base::get<1>(p)); WriteParam(m, base::get<2>(p)); } - static bool Read(const Message* m, + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { return (ReadParam(m, iter, &base::get<0>(*r)) && @@ -663,13 +659,13 @@ struct ParamTraits<base::Tuple<A, B, C>> { template <class A, class B, class C, class D> struct ParamTraits<base::Tuple<A, B, C, D>> { typedef base::Tuple<A, B, C, D> param_type; - static void Write(Message* m, const param_type& p) { + static void Write(base::Pickle* m, const param_type& p) { WriteParam(m, base::get<0>(p)); WriteParam(m, base::get<1>(p)); WriteParam(m, base::get<2>(p)); WriteParam(m, base::get<3>(p)); } - static bool Read(const Message* m, + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { return (ReadParam(m, iter, &base::get<0>(*r)) && @@ -691,14 +687,14 @@ struct ParamTraits<base::Tuple<A, B, C, D>> { template <class A, class B, class C, class D, class E> struct ParamTraits<base::Tuple<A, B, C, D, E>> { typedef base::Tuple<A, B, C, D, E> param_type; - static void Write(Message* m, const param_type& p) { + static void Write(base::Pickle* m, const param_type& p) { WriteParam(m, base::get<0>(p)); WriteParam(m, base::get<1>(p)); WriteParam(m, base::get<2>(p)); WriteParam(m, base::get<3>(p)); WriteParam(m, base::get<4>(p)); } - static bool Read(const Message* m, + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { return (ReadParam(m, iter, &base::get<0>(*r)) && @@ -723,12 +719,12 @@ struct ParamTraits<base::Tuple<A, B, C, D, E>> { template<class P> struct ParamTraits<ScopedVector<P> > { typedef ScopedVector<P> param_type; - static void Write(Message* m, const param_type& p) { + static void Write(base::Pickle* m, const param_type& p) { WriteParam(m, static_cast<int>(p.size())); for (size_t i = 0; i < p.size(); i++) WriteParam(m, *p[i]); } - static bool Read(const Message* m, + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { int size = 0; @@ -756,12 +752,12 @@ struct ParamTraits<ScopedVector<P> > { template <class P, size_t stack_capacity> struct ParamTraits<base::StackVector<P, stack_capacity> > { typedef base::StackVector<P, stack_capacity> param_type; - static void Write(Message* m, const param_type& p) { + static void Write(base::Pickle* m, const param_type& p) { WriteParam(m, static_cast<int>(p->size())); for (size_t i = 0; i < p->size(); i++) WriteParam(m, p[i]); } - static bool Read(const Message* m, + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { int size; @@ -796,7 +792,7 @@ struct ParamTraits<base::SmallMap<NormalMap, kArraySize, EqualKey, MapInit> > { typedef base::SmallMap<NormalMap, kArraySize, EqualKey, MapInit> param_type; typedef typename param_type::key_type K; typedef typename param_type::data_type V; - static void Write(Message* m, const param_type& p) { + static void Write(base::Pickle* m, const param_type& p) { WriteParam(m, static_cast<int>(p.size())); typename param_type::const_iterator iter; for (iter = p.begin(); iter != p.end(); ++iter) { @@ -804,7 +800,7 @@ struct ParamTraits<base::SmallMap<NormalMap, kArraySize, EqualKey, MapInit> > { WriteParam(m, iter->second); } } - static bool Read(const Message* m, + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { int size; @@ -828,13 +824,13 @@ struct ParamTraits<base::SmallMap<NormalMap, kArraySize, EqualKey, MapInit> > { template <class P> struct ParamTraits<scoped_ptr<P> > { typedef scoped_ptr<P> param_type; - static void Write(Message* m, const param_type& p) { + static void Write(base::Pickle* m, const param_type& p) { bool valid = !!p; WriteParam(m, valid); if (valid) WriteParam(m, *p); } - static bool Read(const Message* m, + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { bool valid = false; @@ -869,8 +865,8 @@ struct ParamTraits<scoped_ptr<P> > { 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, + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); @@ -879,8 +875,8 @@ struct IPC_EXPORT ParamTraits<IPC::ChannelHandle> { 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, + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); @@ -888,8 +884,8 @@ struct IPC_EXPORT ParamTraits<LogData> { template <> struct IPC_EXPORT ParamTraits<Message> { - static void Write(Message* m, const Message& p); - static bool Read(const Message* m, + static void Write(base::Pickle* m, const Message& p); + static bool Read(const base::Pickle* m, base::PickleIterator* iter, Message* r); static void Log(const Message& p, std::string* l); @@ -901,8 +897,8 @@ struct IPC_EXPORT ParamTraits<Message> { template <> struct IPC_EXPORT ParamTraits<HANDLE> { typedef HANDLE param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); @@ -911,8 +907,8 @@ struct IPC_EXPORT ParamTraits<HANDLE> { template <> struct IPC_EXPORT ParamTraits<LOGFONT> { typedef LOGFONT param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); @@ -921,8 +917,8 @@ struct IPC_EXPORT ParamTraits<LOGFONT> { template <> struct IPC_EXPORT ParamTraits<MSG> { typedef MSG param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); diff --git a/ipc/mach_port_mac.cc b/ipc/mach_port_mac.cc index 51a5bd7..9375d72 100644 --- a/ipc/mach_port_mac.cc +++ b/ipc/mach_port_mac.cc @@ -12,7 +12,7 @@ namespace IPC { // static -void ParamTraits<MachPortMac>::Write(Message* m, const param_type& p) { +void ParamTraits<MachPortMac>::Write(base::Pickle* m, const param_type& p) { if (!m->WriteAttachment( new IPC::internal::MachPortAttachmentMac(p.get_mach_port()))) { NOTREACHED(); @@ -20,16 +20,18 @@ void ParamTraits<MachPortMac>::Write(Message* m, const param_type& p) { } // static -bool ParamTraits<MachPortMac>::Read(const Message* m, +bool ParamTraits<MachPortMac>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { - scoped_refptr<MessageAttachment> attachment; - if (!m->ReadAttachment(iter, &attachment)) + scoped_refptr<base::Pickle::Attachment> base_attachment; + if (!m->ReadAttachment(iter, &base_attachment)) return false; + MessageAttachment* attachment = + static_cast<MessageAttachment*>(base_attachment.get()); if (attachment->GetType() != MessageAttachment::TYPE_BROKERABLE_ATTACHMENT) return false; BrokerableAttachment* brokerable_attachment = - static_cast<BrokerableAttachment*>(attachment.get()); + static_cast<BrokerableAttachment*>(attachment); if (brokerable_attachment->GetBrokerableType() != BrokerableAttachment::MACH_PORT) { return false; diff --git a/ipc/mach_port_mac.h b/ipc/mach_port_mac.h index 5c420c0f..b95a37b 100644 --- a/ipc/mach_port_mac.h +++ b/ipc/mach_port_mac.h @@ -71,8 +71,10 @@ class IPC_EXPORT MachPortMac { template <> struct IPC_EXPORT ParamTraits<MachPortMac> { typedef MachPortMac param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* p); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p); static void Log(const param_type& p, std::string* l); }; diff --git a/ipc/mojo/ipc_channel_mojo_unittest.cc b/ipc/mojo/ipc_channel_mojo_unittest.cc index b4f4154..e27ec5d 100644 --- a/ipc/mojo/ipc_channel_mojo_unittest.cc +++ b/ipc/mojo/ipc_channel_mojo_unittest.cc @@ -378,9 +378,10 @@ class HandleSendingHelper { static void ReadReceivedFile(const IPC::Message& message, base::PickleIterator* iter) { base::ScopedFD fd; - scoped_refptr<IPC::MessageAttachment> attachment; + scoped_refptr<base::Pickle::Attachment> attachment; EXPECT_TRUE(message.ReadAttachment(iter, &attachment)); - base::File file(attachment->TakePlatformFile()); + base::File file(static_cast<IPC::MessageAttachment*>(attachment.get()) + ->TakePlatformFile()); std::string content(GetSendingFileContent().size(), ' '); file.Read(0, &content[0], content.size()); EXPECT_EQ(content, GetSendingFileContent()); diff --git a/ipc/mojo/ipc_mojo_message_helper.cc b/ipc/mojo/ipc_mojo_message_helper.cc index 8b8344e..ae5e83a 100644 --- a/ipc/mojo/ipc_mojo_message_helper.cc +++ b/ipc/mojo/ipc_mojo_message_helper.cc @@ -12,7 +12,7 @@ namespace IPC { // static bool MojoMessageHelper::WriteMessagePipeTo( - Message* message, + base::Pickle* message, mojo::ScopedMessagePipeHandle handle) { message->WriteAttachment(new internal::MojoHandleAttachment( mojo::ScopedHandle::From(std::move(handle)))); @@ -21,17 +21,19 @@ bool MojoMessageHelper::WriteMessagePipeTo( // static bool MojoMessageHelper::ReadMessagePipeFrom( - const Message* message, + const base::Pickle* message, base::PickleIterator* iter, mojo::ScopedMessagePipeHandle* handle) { - scoped_refptr<MessageAttachment> attachment; + scoped_refptr<base::Pickle::Attachment> attachment; if (!message->ReadAttachment(iter, &attachment)) { LOG(ERROR) << "Failed to read attachment for message pipe."; return false; } - if (attachment->GetType() != MessageAttachment::TYPE_MOJO_HANDLE) { - LOG(ERROR) << "Unxpected attachment type:" << attachment->GetType(); + MessageAttachment::Type type = + static_cast<MessageAttachment*>(attachment.get())->GetType(); + if (type != MessageAttachment::TYPE_MOJO_HANDLE) { + LOG(ERROR) << "Unxpected attachment type:" << type; return false; } diff --git a/ipc/mojo/ipc_mojo_message_helper.h b/ipc/mojo/ipc_mojo_message_helper.h index 3dc840e..e0e44d0 100644 --- a/ipc/mojo/ipc_mojo_message_helper.h +++ b/ipc/mojo/ipc_mojo_message_helper.h @@ -14,9 +14,9 @@ namespace IPC { // Reads and writes |mojo::MessagePipe| from/to |Message|. class IPC_MOJO_EXPORT MojoMessageHelper { public: - static bool WriteMessagePipeTo(Message* message, + static bool WriteMessagePipeTo(base::Pickle* message, mojo::ScopedMessagePipeHandle handle); - static bool ReadMessagePipeFrom(const Message* message, + static bool ReadMessagePipeFrom(const base::Pickle* message, base::PickleIterator* iter, mojo::ScopedMessagePipeHandle* handle); diff --git a/ipc/param_traits_macros.h b/ipc/param_traits_macros.h index 317f312..7c4cc692 100644 --- a/ipc/param_traits_macros.h +++ b/ipc/param_traits_macros.h @@ -8,16 +8,17 @@ #include <string> // Traits generation for structs. -#define IPC_STRUCT_TRAITS_BEGIN(struct_name) \ - namespace IPC { \ - template <> \ - 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, base::PickleIterator* iter, \ - param_type* p); \ - static void Log(const param_type& p, std::string* l); \ - }; \ +#define IPC_STRUCT_TRAITS_BEGIN(struct_name) \ + namespace IPC { \ + template <> \ + struct IPC_MESSAGE_EXPORT ParamTraits<struct_name> { \ + typedef struct_name param_type; \ + static void Write(base::Pickle* m, const param_type& p); \ + static bool Read(const base::Pickle* m, \ + base::PickleIterator* iter, \ + param_type* p); \ + static void Log(const param_type& p, std::string* l); \ + }; \ } #define IPC_STRUCT_TRAITS_MEMBER(name) @@ -48,15 +49,16 @@ // Traits generation for enums. This macro may be redefined later. #define IPC_ENUM_TRAITS_VALIDATE(enum_name, validation_expression) \ - namespace IPC { \ - template <> \ - 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, base::PickleIterator* iter, \ - param_type* p); \ - static void Log(const param_type& p, std::string* l); \ - }; \ + namespace IPC { \ + template <> \ + struct IPC_MESSAGE_EXPORT ParamTraits<enum_name> { \ + typedef enum_name param_type; \ + static void Write(base::Pickle* m, const param_type& p); \ + static bool Read(const base::Pickle* m, \ + base::PickleIterator* iter, \ + param_type* p); \ + static void Log(const param_type& p, std::string* l); \ + }; \ } #endif // IPC_PARAM_TRAITS_MACROS_H_ diff --git a/ipc/param_traits_read_macros.h b/ipc/param_traits_read_macros.h index a66c89a..45e6352 100644 --- a/ipc/param_traits_read_macros.h +++ b/ipc/param_traits_read_macros.h @@ -22,25 +22,25 @@ #undef IPC_STRUCT_TRAITS_MEMBER #undef IPC_STRUCT_TRAITS_PARENT #undef IPC_STRUCT_TRAITS_END -#define IPC_STRUCT_TRAITS_BEGIN(struct_name) \ - bool ParamTraits<struct_name>:: \ - Read(const Message* m, base::PickleIterator* iter, param_type* p) { \ - return +#define IPC_STRUCT_TRAITS_BEGIN(struct_name) \ + bool ParamTraits<struct_name>::Read( \ + const base::Pickle* m, base::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) && #define IPC_STRUCT_TRAITS_END() 1; } #undef IPC_ENUM_TRAITS_VALIDATE -#define IPC_ENUM_TRAITS_VALIDATE(enum_name, validation_expression) \ - bool ParamTraits<enum_name>:: \ - Read(const Message* m, base::PickleIterator* iter, param_type* p) { \ - int value; \ - if (!iter->ReadInt(&value)) \ - return false; \ - if (!(validation_expression)) \ - return false; \ - *p = static_cast<param_type>(value); \ - return true; \ +#define IPC_ENUM_TRAITS_VALIDATE(enum_name, validation_expression) \ + bool ParamTraits<enum_name>::Read( \ + const base::Pickle* m, base::PickleIterator* iter, param_type* p) { \ + int value; \ + if (!iter->ReadInt(&value)) \ + return false; \ + if (!(validation_expression)) \ + return false; \ + *p = static_cast<param_type>(value); \ + return true; \ } #endif // IPC_PARAM_TRAITS_READ_MACROS_H_ diff --git a/ipc/param_traits_write_macros.h b/ipc/param_traits_write_macros.h index 81f915f..a1aca43 100644 --- a/ipc/param_traits_write_macros.h +++ b/ipc/param_traits_write_macros.h @@ -23,16 +23,17 @@ #undef IPC_STRUCT_TRAITS_PARENT #undef IPC_STRUCT_TRAITS_END #define IPC_STRUCT_TRAITS_BEGIN(struct_name) \ - void ParamTraits<struct_name>::Write(Message* m, const param_type& p) { + void ParamTraits<struct_name>::Write(base::Pickle* m, const param_type& p) { #define IPC_STRUCT_TRAITS_MEMBER(name) WriteParam(m, p.name); #define IPC_STRUCT_TRAITS_PARENT(type) ParamTraits<type>::Write(m, p); #define IPC_STRUCT_TRAITS_END() } #undef IPC_ENUM_TRAITS_VALIDATE #define IPC_ENUM_TRAITS_VALIDATE(enum_name, validation_expression) \ - void ParamTraits<enum_name>::Write(Message* m, const param_type& value) { \ - DCHECK(validation_expression); \ - m->WriteInt(static_cast<int>(value)); \ + void ParamTraits<enum_name>::Write(base::Pickle* m, \ + const param_type& value) { \ + DCHECK(validation_expression); \ + m->WriteInt(static_cast<int>(value)); \ } #endif // IPC_PARAM_TRAITS_WRITE_MACROS_H_ diff --git a/ppapi/proxy/nacl_message_scanner.cc b/ppapi/proxy/nacl_message_scanner.cc index 766bc8a..e8ca425c 100644 --- a/ppapi/proxy/nacl_message_scanner.cc +++ b/ppapi/proxy/nacl_message_scanner.cc @@ -55,7 +55,7 @@ struct ScanningResults { void WriteHandle(int handle_index, const SerializedHandle& handle, - IPC::Message* msg) { + base::Pickle* msg) { SerializedHandle::WriteHeader(handle.header(), msg); if (handle.type() != SerializedHandle::INVALID) { @@ -78,7 +78,7 @@ void ScanParam(const SerializedHandle& handle, ScanningResults* results) { } void HandleWriter(int* handle_index, - IPC::Message* m, + base::Pickle* m, const SerializedHandle& handle) { WriteHandle((*handle_index)++, handle, m); } diff --git a/ppapi/proxy/ppapi_param_traits.cc b/ppapi/proxy/ppapi_param_traits.cc index 57f8a9f..9d21eac 100644 --- a/ppapi/proxy/ppapi_param_traits.cc +++ b/ppapi/proxy/ppapi_param_traits.cc @@ -41,7 +41,7 @@ namespace { // The solution is to make a new object for each deserialized item, and then // add it to the vector one at a time. template <typename T> -bool ReadVectorWithoutCopy(const Message* m, +bool ReadVectorWithoutCopy(const base::Pickle* m, base::PickleIterator* iter, std::vector<T>* output) { // This part is just a copy of the the default ParamTraits vector Read(). @@ -67,8 +67,8 @@ bool ReadVectorWithoutCopy(const Message* m, // way as the "regular" IPC vector serializer does. But having the code here // saves us from having to copy this code into all ParamTraits that use the // ReadVectorWithoutCopy function for deserializing. -template<typename T> -void WriteVectorWithoutCopy(Message* m, const std::vector<T>& p) { +template <typename T> +void WriteVectorWithoutCopy(base::Pickle* m, const std::vector<T>& p) { WriteParam(m, static_cast<int>(p.size())); for (size_t i = 0; i < p.size(); i++) WriteParam(m, p[i]); @@ -79,12 +79,12 @@ void WriteVectorWithoutCopy(Message* m, const std::vector<T>& p) { // PP_Bool --------------------------------------------------------------------- // static -void ParamTraits<PP_Bool>::Write(Message* m, const param_type& p) { +void ParamTraits<PP_Bool>::Write(base::Pickle* m, const param_type& p) { WriteParam(m, PP_ToBool(p)); } // static -bool ParamTraits<PP_Bool>::Read(const Message* m, +bool ParamTraits<PP_Bool>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { // We specifically want to be strict here about what types of input we accept, @@ -104,7 +104,8 @@ void ParamTraits<PP_Bool>::Log(const param_type& p, std::string* l) { // PP_KeyInformation ------------------------------------------------------- // static -void ParamTraits<PP_KeyInformation>::Write(Message* m, const param_type& p) { +void ParamTraits<PP_KeyInformation>::Write(base::Pickle* m, + const param_type& p) { WriteParam(m, p.key_id_size); m->WriteBytes(p.key_id, static_cast<int>(p.key_id_size)); WriteParam(m, p.key_status); @@ -112,7 +113,7 @@ void ParamTraits<PP_KeyInformation>::Write(Message* m, const param_type& p) { } // static -bool ParamTraits<PP_KeyInformation>::Read(const Message* m, +bool ParamTraits<PP_KeyInformation>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* p) { uint32_t size; @@ -150,14 +151,14 @@ void ParamTraits<PP_KeyInformation>::Log(const param_type& p, std::string* l) { // PP_NetAddress_Private ------------------------------------------------------- // static -void ParamTraits<PP_NetAddress_Private>::Write(Message* m, +void ParamTraits<PP_NetAddress_Private>::Write(base::Pickle* m, const param_type& p) { WriteParam(m, p.size); m->WriteBytes(p.data, static_cast<int>(p.size)); } // static -bool ParamTraits<PP_NetAddress_Private>::Read(const Message* m, +bool ParamTraits<PP_NetAddress_Private>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* p) { uint16_t size; @@ -185,14 +186,14 @@ void ParamTraits<PP_NetAddress_Private>::Log(const param_type& p, // HostResource ---------------------------------------------------------------- // static -void ParamTraits<ppapi::HostResource>::Write(Message* m, +void ParamTraits<ppapi::HostResource>::Write(base::Pickle* m, const param_type& p) { WriteParam(m, p.instance()); WriteParam(m, p.host_resource()); } // static -bool ParamTraits<ppapi::HostResource>::Read(const Message* m, +bool ParamTraits<ppapi::HostResource>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { PP_Instance instance; @@ -211,13 +212,13 @@ void ParamTraits<ppapi::HostResource>::Log(const param_type& p, // SerializedVar --------------------------------------------------------------- // static -void ParamTraits<ppapi::proxy::SerializedVar>::Write(Message* m, +void ParamTraits<ppapi::proxy::SerializedVar>::Write(base::Pickle* m, const param_type& p) { p.WriteToMessage(m); } // static -bool ParamTraits<ppapi::proxy::SerializedVar>::Read(const Message* m, +bool ParamTraits<ppapi::proxy::SerializedVar>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { return r->ReadFromMessage(m, iter); @@ -230,15 +231,15 @@ void ParamTraits<ppapi::proxy::SerializedVar>::Log(const param_type& p, // std::vector<SerializedVar> -------------------------------------------------- -void ParamTraits< std::vector<ppapi::proxy::SerializedVar> >::Write( - Message* m, +void ParamTraits<std::vector<ppapi::proxy::SerializedVar>>::Write( + base::Pickle* m, const param_type& p) { WriteVectorWithoutCopy(m, p); } // static bool ParamTraits<std::vector<ppapi::proxy::SerializedVar>>::Read( - const Message* m, + const base::Pickle* m, base::PickleIterator* iter, param_type* r) { return ReadVectorWithoutCopy(m, iter, r); @@ -252,13 +253,13 @@ void ParamTraits< std::vector<ppapi::proxy::SerializedVar> >::Log( // ppapi::PpapiPermissions ----------------------------------------------------- -void ParamTraits<ppapi::PpapiPermissions>::Write(Message* m, +void ParamTraits<ppapi::PpapiPermissions>::Write(base::Pickle* m, const param_type& p) { WriteParam(m, p.GetBits()); } // static -bool ParamTraits<ppapi::PpapiPermissions>::Read(const Message* m, +bool ParamTraits<ppapi::PpapiPermissions>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { uint32_t bits; @@ -276,7 +277,7 @@ void ParamTraits<ppapi::PpapiPermissions>::Log(const param_type& p, // SerializedHandle ------------------------------------------------------------ // static -void ParamTraits<ppapi::proxy::SerializedHandle>::Write(Message* m, +void ParamTraits<ppapi::proxy::SerializedHandle>::Write(base::Pickle* m, const param_type& p) { ppapi::proxy::SerializedHandle::WriteHeader(p.header(), m); switch (p.type()) { @@ -295,7 +296,7 @@ void ParamTraits<ppapi::proxy::SerializedHandle>::Write(Message* m, // static bool ParamTraits<ppapi::proxy::SerializedHandle>::Read( - const Message* m, + const base::Pickle* m, base::PickleIterator* iter, param_type* r) { ppapi::proxy::SerializedHandle::Header header; @@ -342,7 +343,7 @@ void ParamTraits<ppapi::proxy::SerializedHandle>::Log(const param_type& p, // static void ParamTraits<ppapi::proxy::PPBURLLoader_UpdateProgress_Params>::Write( - Message* m, + base::Pickle* m, const param_type& p) { WriteParam(m, p.instance); WriteParam(m, p.resource); @@ -354,7 +355,7 @@ void ParamTraits<ppapi::proxy::PPBURLLoader_UpdateProgress_Params>::Write( // static bool ParamTraits<ppapi::proxy::PPBURLLoader_UpdateProgress_Params>::Read( - const Message* m, + const base::Pickle* m, base::PickleIterator* iter, param_type* r) { return ReadParam(m, iter, &r->instance) && ReadParam(m, iter, &r->resource) && @@ -374,7 +375,7 @@ void ParamTraits<ppapi::proxy::PPBURLLoader_UpdateProgress_Params>::Log( // PPBFlash_DrawGlyphs_Params -------------------------------------------------- // static void ParamTraits<ppapi::proxy::PPBFlash_DrawGlyphs_Params>::Write( - Message* m, + base::Pickle* m, const param_type& p) { WriteParam(m, p.instance); WriteParam(m, p.image_data); @@ -398,7 +399,7 @@ void ParamTraits<ppapi::proxy::PPBFlash_DrawGlyphs_Params>::Write( // static bool ParamTraits<ppapi::proxy::PPBFlash_DrawGlyphs_Params>::Read( - const Message* m, + const base::Pickle* m, base::PickleIterator* iter, param_type* r) { return ReadParam(m, iter, &r->instance) && @@ -429,7 +430,7 @@ void ParamTraits<ppapi::proxy::PPBFlash_DrawGlyphs_Params>::Log( // SerializedDirEntry ---------------------------------------------------------- // static -void ParamTraits<ppapi::proxy::SerializedDirEntry>::Write(Message* m, +void ParamTraits<ppapi::proxy::SerializedDirEntry>::Write(base::Pickle* m, const param_type& p) { WriteParam(m, p.name); WriteParam(m, p.is_dir); @@ -437,7 +438,7 @@ void ParamTraits<ppapi::proxy::SerializedDirEntry>::Write(Message* m, // static bool ParamTraits<ppapi::proxy::SerializedDirEntry>::Read( - const Message* m, + const base::Pickle* m, base::PickleIterator* iter, param_type* r) { return ReadParam(m, iter, &r->name) && ReadParam(m, iter, &r->is_dir); @@ -452,7 +453,7 @@ void ParamTraits<ppapi::proxy::SerializedDirEntry>::Log(const param_type& p, // static void ParamTraits<ppapi::proxy::SerializedFontDescription>::Write( - Message* m, + base::Pickle* m, const param_type& p) { WriteParam(m, p.face); WriteParam(m, p.family); @@ -466,7 +467,7 @@ void ParamTraits<ppapi::proxy::SerializedFontDescription>::Write( // static bool ParamTraits<ppapi::proxy::SerializedFontDescription>::Read( - const Message* m, + const base::Pickle* m, base::PickleIterator* iter, param_type* r) { return ReadParam(m, iter, &r->face) && ReadParam(m, iter, &r->family) && @@ -487,7 +488,7 @@ void ParamTraits<ppapi::proxy::SerializedFontDescription>::Log( // static void ParamTraits<ppapi::proxy::SerializedTrueTypeFontDesc>::Write( - Message* m, + base::Pickle* m, const param_type& p) { WriteParam(m, p.family); WriteParam(m, p.generic_family); @@ -499,7 +500,7 @@ void ParamTraits<ppapi::proxy::SerializedTrueTypeFontDesc>::Write( // static bool ParamTraits<ppapi::proxy::SerializedTrueTypeFontDesc>::Read( - const Message* m, + const base::Pickle* m, base::PickleIterator* iter, param_type* r) { return ReadParam(m, iter, &r->family) && @@ -518,14 +519,14 @@ void ParamTraits<ppapi::proxy::SerializedTrueTypeFontDesc>::Log( // ppapi::PepperFilePath ------------------------------------------------------- // static -void ParamTraits<ppapi::PepperFilePath>::Write(Message* m, +void ParamTraits<ppapi::PepperFilePath>::Write(base::Pickle* m, const param_type& p) { WriteParam(m, static_cast<unsigned>(p.domain())); WriteParam(m, p.path()); } // static -bool ParamTraits<ppapi::PepperFilePath>::Read(const Message* m, +bool ParamTraits<ppapi::PepperFilePath>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* p) { unsigned domain; @@ -554,14 +555,14 @@ void ParamTraits<ppapi::PepperFilePath>::Log(const param_type& p, // static void ParamTraits<ppapi::proxy::SerializedFlashMenu>::Write( - Message* m, + base::Pickle* m, const param_type& p) { p.WriteToMessage(m); } // static bool ParamTraits<ppapi::proxy::SerializedFlashMenu>::Read( - const Message* m, + const base::Pickle* m, base::PickleIterator* iter, param_type* r) { return r->ReadFromMessage(m, iter); @@ -577,14 +578,14 @@ void ParamTraits<ppapi::proxy::SerializedFlashMenu>::Log(const param_type& p, // static void ParamTraits<ppapi::PPB_X509Certificate_Fields>::Write( - Message* m, + base::Pickle* m, const param_type& p) { WriteParam(m, p.values_); } // static bool ParamTraits<ppapi::PPB_X509Certificate_Fields>::Read( - const Message* m, + const base::Pickle* m, base::PickleIterator* iter, param_type* r) { return ReadParam(m, iter, &(r->values_)); @@ -598,7 +599,7 @@ void ParamTraits<ppapi::PPB_X509Certificate_Fields>::Log(const param_type& p, // ppapi::SocketOptionData ----------------------------------------------------- // static -void ParamTraits<ppapi::SocketOptionData>::Write(Message* m, +void ParamTraits<ppapi::SocketOptionData>::Write(base::Pickle* m, const param_type& p) { ppapi::SocketOptionData::Type type = p.GetType(); WriteParam(m, static_cast<int32_t>(type)); @@ -631,7 +632,7 @@ void ParamTraits<ppapi::SocketOptionData>::Write(Message* m, } // static -bool ParamTraits<ppapi::SocketOptionData>::Read(const Message* m, +bool ParamTraits<ppapi::SocketOptionData>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { *r = ppapi::SocketOptionData(); @@ -675,7 +676,7 @@ void ParamTraits<ppapi::SocketOptionData>::Log(const param_type& p, // static void ParamTraits<ppapi::CompositorLayerData::Transform>::Write( - Message* m, + base::Pickle* m, const param_type& p) { for (size_t i = 0; i < arraysize(p.matrix); i++) WriteParam(m, p.matrix[i]); @@ -683,7 +684,7 @@ void ParamTraits<ppapi::CompositorLayerData::Transform>::Write( // static bool ParamTraits<ppapi::CompositorLayerData::Transform>::Read( - const Message* m, + const base::Pickle* m, base::PickleIterator* iter, param_type* r) { for (size_t i = 0; i < arraysize(r->matrix);i++) { diff --git a/ppapi/proxy/ppapi_param_traits.h b/ppapi/proxy/ppapi_param_traits.h index e3638b8..6996547 100644 --- a/ppapi/proxy/ppapi_param_traits.h +++ b/ppapi/proxy/ppapi_param_traits.h @@ -49,24 +49,30 @@ namespace IPC { template<> struct PPAPI_PROXY_EXPORT ParamTraits<PP_Bool> { typedef PP_Bool param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct PPAPI_PROXY_EXPORT ParamTraits<PP_NetAddress_Private> { typedef PP_NetAddress_Private param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* p); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p); static void Log(const param_type& p, std::string* l); }; template <> struct PPAPI_PROXY_EXPORT ParamTraits<PP_KeyInformation> { typedef PP_KeyInformation param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* p); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p); static void Log(const param_type& p, std::string* l); }; @@ -74,8 +80,10 @@ template<> struct PPAPI_PROXY_EXPORT ParamTraits< ppapi::proxy::PPBFlash_DrawGlyphs_Params> { typedef ppapi::proxy::PPBFlash_DrawGlyphs_Params param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -83,24 +91,30 @@ template<> struct PPAPI_PROXY_EXPORT ParamTraits< ppapi::proxy::PPBURLLoader_UpdateProgress_Params> { typedef ppapi::proxy::PPBURLLoader_UpdateProgress_Params param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template<> struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::proxy::SerializedDirEntry> { typedef ppapi::proxy::SerializedDirEntry param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template<> struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::proxy::SerializedFontDescription> { typedef ppapi::proxy::SerializedFontDescription param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -108,32 +122,40 @@ template<> struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::proxy::SerializedTrueTypeFontDesc> { typedef ppapi::proxy::SerializedTrueTypeFontDesc param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template<> struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::proxy::SerializedHandle> { typedef ppapi::proxy::SerializedHandle param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template<> struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::HostResource> { typedef ppapi::HostResource param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template<> struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::proxy::SerializedVar> { typedef ppapi::proxy::SerializedVar param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -141,16 +163,20 @@ template<> struct PPAPI_PROXY_EXPORT ParamTraits< std::vector<ppapi::proxy::SerializedVar> > { typedef std::vector<ppapi::proxy::SerializedVar> param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template<> struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::PpapiPermissions> { typedef ppapi::PpapiPermissions param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -158,16 +184,20 @@ struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::PpapiPermissions> { template <> struct ParamTraits<ppapi::PepperFilePath> { typedef ppapi::PepperFilePath param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* p); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p); static void Log(const param_type& p, std::string* l); }; template<> struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::proxy::SerializedFlashMenu> { typedef ppapi::proxy::SerializedFlashMenu param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; #endif // !defined(OS_NACL) && !defined(NACL_WIN64) @@ -175,24 +205,30 @@ struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::proxy::SerializedFlashMenu> { template<> struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::PPB_X509Certificate_Fields> { typedef ppapi::PPB_X509Certificate_Fields param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template<> struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::SocketOptionData> { typedef ppapi::SocketOptionData param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template<> struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::CompositorLayerData::Transform> { typedef ppapi::CompositorLayerData::Transform param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; diff --git a/ppapi/proxy/raw_var_data.cc b/ppapi/proxy/raw_var_data.cc index ae38d33..f4bcf96 100644 --- a/ppapi/proxy/raw_var_data.cc +++ b/ppapi/proxy/raw_var_data.cc @@ -173,7 +173,7 @@ PP_Var RawVarDataGraph::CreatePPVar(PP_Instance instance) { return graph[0]; } -void RawVarDataGraph::Write(IPC::Message* m, +void RawVarDataGraph::Write(base::Pickle* m, const HandleWriter& handle_writer) { // Write the size, followed by each node in the graph. m->WriteUInt32(static_cast<uint32_t>(data_.size())); @@ -184,7 +184,7 @@ void RawVarDataGraph::Write(IPC::Message* m, } // static -scoped_ptr<RawVarDataGraph> RawVarDataGraph::Read(const IPC::Message* m, +scoped_ptr<RawVarDataGraph> RawVarDataGraph::Read(const base::Pickle* m, base::PickleIterator* iter) { scoped_ptr<RawVarDataGraph> result(new RawVarDataGraph); uint32_t size = 0; @@ -283,9 +283,8 @@ void BasicRawVarData::PopulatePPVar(const PP_Var& var, const std::vector<PP_Var>& graph) { } -void BasicRawVarData::Write( - IPC::Message* m, - const HandleWriter& handle_writer) { +void BasicRawVarData::Write(base::Pickle* m, + const HandleWriter& handle_writer) { switch (var_.type) { case PP_VARTYPE_UNDEFINED: case PP_VARTYPE_NULL: @@ -311,7 +310,7 @@ void BasicRawVarData::Write( } bool BasicRawVarData::Read(PP_VarType type, - const IPC::Message* m, + const base::Pickle* m, base::PickleIterator* iter) { PP_Var result; result.type = type; @@ -377,13 +376,13 @@ void StringRawVarData::PopulatePPVar(const PP_Var& var, const std::vector<PP_Var>& graph) { } -void StringRawVarData::Write(IPC::Message* m, +void StringRawVarData::Write(base::Pickle* m, const HandleWriter& handle_writer) { m->WriteString(data_); } bool StringRawVarData::Read(PP_VarType type, - const IPC::Message* m, + const base::Pickle* m, base::PickleIterator* iter) { if (!iter->ReadString(&data_)) return false; @@ -482,9 +481,8 @@ void ArrayBufferRawVarData::PopulatePPVar(const PP_Var& var, const std::vector<PP_Var>& graph) { } -void ArrayBufferRawVarData::Write( - IPC::Message* m, - const HandleWriter& handle_writer) { +void ArrayBufferRawVarData::Write(base::Pickle* m, + const HandleWriter& handle_writer) { m->WriteInt(type_); switch (type_) { case ARRAY_BUFFER_SHMEM_HOST: @@ -500,7 +498,7 @@ void ArrayBufferRawVarData::Write( } bool ArrayBufferRawVarData::Read(PP_VarType type, - const IPC::Message* m, + const base::Pickle* m, base::PickleIterator* iter) { int shmem_type; if (!iter->ReadInt(&shmem_type)) @@ -572,7 +570,7 @@ void ArrayRawVarData::PopulatePPVar(const PP_Var& var, array_var->elements().push_back(ScopedPPVar(graph[children_[i]])); } -void ArrayRawVarData::Write(IPC::Message* m, +void ArrayRawVarData::Write(base::Pickle* m, const HandleWriter& handle_writer) { m->WriteUInt32(static_cast<uint32_t>(children_.size())); for (size_t i = 0; i < children_.size(); ++i) @@ -580,7 +578,7 @@ void ArrayRawVarData::Write(IPC::Message* m, } bool ArrayRawVarData::Read(PP_VarType type, - const IPC::Message* m, + const base::Pickle* m, base::PickleIterator* iter) { uint32_t size; if (!iter->ReadUInt32(&size)) @@ -635,9 +633,8 @@ void DictionaryRawVarData::PopulatePPVar(const PP_Var& var, } } -void DictionaryRawVarData::Write( - IPC::Message* m, - const HandleWriter& handle_writer) { +void DictionaryRawVarData::Write(base::Pickle* m, + const HandleWriter& handle_writer) { m->WriteUInt32(static_cast<uint32_t>(children_.size())); for (size_t i = 0; i < children_.size(); ++i) { m->WriteString(children_[i].first); @@ -646,7 +643,7 @@ void DictionaryRawVarData::Write( } bool DictionaryRawVarData::Read(PP_VarType type, - const IPC::Message* m, + const base::Pickle* m, base::PickleIterator* iter) { uint32_t size; if (!iter->ReadUInt32(&size)) @@ -712,7 +709,7 @@ void ResourceRawVarData::PopulatePPVar(const PP_Var& var, const std::vector<PP_Var>& graph) { } -void ResourceRawVarData::Write(IPC::Message* m, +void ResourceRawVarData::Write(base::Pickle* m, const HandleWriter& handle_writer) { m->WriteInt(static_cast<int>(pp_resource_)); m->WriteInt(pending_renderer_host_id_); @@ -723,7 +720,7 @@ void ResourceRawVarData::Write(IPC::Message* m, } bool ResourceRawVarData::Read(PP_VarType type, - const IPC::Message* m, + const base::Pickle* m, base::PickleIterator* iter) { int value; if (!iter->ReadInt(&value)) diff --git a/ppapi/proxy/raw_var_data.h b/ppapi/proxy/raw_var_data.h index 7e437e9..fec92e7 100644 --- a/ppapi/proxy/raw_var_data.h +++ b/ppapi/proxy/raw_var_data.h @@ -33,7 +33,7 @@ namespace proxy { class RawVarData; -typedef base::Callback<void(IPC::Message*, const SerializedHandle&)> +typedef base::Callback<void(base::Pickle*, const SerializedHandle&)> HandleWriter; // Contains the data associated with a graph of connected PP_Vars. Useful for @@ -70,10 +70,10 @@ class PPAPI_PROXY_EXPORT RawVarDataGraph { PP_Var CreatePPVar(PP_Instance instance); // Write the graph to a message using the given HandleWriter. - void Write(IPC::Message* m, const HandleWriter& handle_writer); + void Write(base::Pickle* m, const HandleWriter& handle_writer); // Create a RawVarDataGraph from the given message. - static scoped_ptr<RawVarDataGraph> Read(const IPC::Message* m, + static scoped_ptr<RawVarDataGraph> Read(const base::Pickle* m, base::PickleIterator* iter); // Returns a vector of SerializedHandles associated with this RawVarDataGraph. @@ -117,11 +117,10 @@ class RawVarData { const std::vector<PP_Var>& graph) = 0; // Writes the RawVarData to a message. - virtual void Write(IPC::Message* m, - const HandleWriter& handle_writer) = 0; + virtual void Write(base::Pickle* m, const HandleWriter& handle_writer) = 0; // Reads the RawVarData from a message. Returns true on success. virtual bool Read(PP_VarType type, - const IPC::Message* m, + const base::Pickle* m, base::PickleIterator* iter) = 0; // Returns a SerializedHandle associated with this RawVarData or NULL if none @@ -146,9 +145,9 @@ class BasicRawVarData : public RawVarData { PP_Var CreatePPVar(PP_Instance instance) override; void PopulatePPVar(const PP_Var& var, const std::vector<PP_Var>& graph) override; - void Write(IPC::Message* m, const HandleWriter& handle_writer) override; + void Write(base::Pickle* m, const HandleWriter& handle_writer) override; bool Read(PP_VarType type, - const IPC::Message* m, + const base::Pickle* m, base::PickleIterator* iter) override; private: @@ -167,9 +166,9 @@ class StringRawVarData : public RawVarData { PP_Var CreatePPVar(PP_Instance instance) override; void PopulatePPVar(const PP_Var& var, const std::vector<PP_Var>& graph) override; - void Write(IPC::Message* m, const HandleWriter& handle_writer) override; + void Write(base::Pickle* m, const HandleWriter& handle_writer) override; bool Read(PP_VarType type, - const IPC::Message* m, + const base::Pickle* m, base::PickleIterator* iter) override; private: @@ -196,9 +195,9 @@ class ArrayBufferRawVarData : public RawVarData { PP_Var CreatePPVar(PP_Instance instance) override; void PopulatePPVar(const PP_Var& var, const std::vector<PP_Var>& graph) override; - void Write(IPC::Message* m, const HandleWriter& handle_writer) override; + void Write(base::Pickle* m, const HandleWriter& handle_writer) override; bool Read(PP_VarType type, - const IPC::Message* m, + const base::Pickle* m, base::PickleIterator* iter) override; SerializedHandle* GetHandle() override; @@ -227,9 +226,9 @@ class ArrayRawVarData : public RawVarData { PP_Var CreatePPVar(PP_Instance instance) override; void PopulatePPVar(const PP_Var& var, const std::vector<PP_Var>& graph) override; - void Write(IPC::Message* m, const HandleWriter& handle_writer) override; + void Write(base::Pickle* m, const HandleWriter& handle_writer) override; bool Read(PP_VarType type, - const IPC::Message* m, + const base::Pickle* m, base::PickleIterator* iter) override; private: @@ -250,9 +249,9 @@ class DictionaryRawVarData : public RawVarData { PP_Var CreatePPVar(PP_Instance instance) override; void PopulatePPVar(const PP_Var& var, const std::vector<PP_Var>& graph) override; - void Write(IPC::Message* m, const HandleWriter& handle_writer) override; + void Write(base::Pickle* m, const HandleWriter& handle_writer) override; bool Read(PP_VarType type, - const IPC::Message* m, + const base::Pickle* m, base::PickleIterator* iter) override; private: @@ -276,9 +275,9 @@ class ResourceRawVarData : public RawVarData { PP_Var CreatePPVar(PP_Instance instance) override; void PopulatePPVar(const PP_Var& var, const std::vector<PP_Var>& graph) override; - void Write(IPC::Message* m, const HandleWriter& handle_writer) override; + void Write(base::Pickle* m, const HandleWriter& handle_writer) override; bool Read(PP_VarType type, - const IPC::Message* m, + const base::Pickle* m, base::PickleIterator* iter) override; private: diff --git a/ppapi/proxy/raw_var_data_unittest.cc b/ppapi/proxy/raw_var_data_unittest.cc index 1e68712..5985a5d 100644 --- a/ppapi/proxy/raw_var_data_unittest.cc +++ b/ppapi/proxy/raw_var_data_unittest.cc @@ -31,7 +31,7 @@ namespace proxy { namespace { -void DefaultHandleWriter(IPC::Message* m, const SerializedHandle& handle) { +void DefaultHandleWriter(base::Pickle* m, const SerializedHandle& handle) { IPC::ParamTraits<SerializedHandle>::Write(m, handle); } diff --git a/ppapi/proxy/resource_message_params.cc b/ppapi/proxy/resource_message_params.cc index 3e5e03b..9dd744a 100644 --- a/ppapi/proxy/resource_message_params.cc +++ b/ppapi/proxy/resource_message_params.cc @@ -40,26 +40,26 @@ ResourceMessageParams::ResourceMessageParams(PP_Resource resource, ResourceMessageParams::~ResourceMessageParams() { } -void ResourceMessageParams::Serialize(IPC::Message* msg) const { +void ResourceMessageParams::Serialize(base::Pickle* msg) const { WriteHeader(msg); WriteHandles(msg); } -bool ResourceMessageParams::Deserialize(const IPC::Message* msg, +bool ResourceMessageParams::Deserialize(const base::Pickle* msg, base::PickleIterator* iter) { return ReadHeader(msg, iter) && ReadHandles(msg, iter); } -void ResourceMessageParams::WriteHeader(IPC::Message* msg) const { +void ResourceMessageParams::WriteHeader(base::Pickle* msg) const { IPC::WriteParam(msg, pp_resource_); IPC::WriteParam(msg, sequence_); } -void ResourceMessageParams::WriteHandles(IPC::Message* msg) const { +void ResourceMessageParams::WriteHandles(base::Pickle* msg) const { IPC::WriteParam(msg, handles_->data()); } -bool ResourceMessageParams::ReadHeader(const IPC::Message* msg, +bool ResourceMessageParams::ReadHeader(const base::Pickle* msg, base::PickleIterator* iter) { DCHECK(handles_->data().empty()); handles_->set_should_close(true); @@ -67,7 +67,7 @@ bool ResourceMessageParams::ReadHeader(const IPC::Message* msg, IPC::ReadParam(msg, iter, &sequence_); } -bool ResourceMessageParams::ReadHandles(const IPC::Message* msg, +bool ResourceMessageParams::ReadHandles(const base::Pickle* msg, base::PickleIterator* iter) { return IPC::ReadParam(msg, iter, &handles_->data()); } @@ -151,12 +151,12 @@ ResourceMessageCallParams::ResourceMessageCallParams(PP_Resource resource, ResourceMessageCallParams::~ResourceMessageCallParams() { } -void ResourceMessageCallParams::Serialize(IPC::Message* msg) const { +void ResourceMessageCallParams::Serialize(base::Pickle* msg) const { ResourceMessageParams::Serialize(msg); IPC::WriteParam(msg, has_callback_); } -bool ResourceMessageCallParams::Deserialize(const IPC::Message* msg, +bool ResourceMessageCallParams::Deserialize(const base::Pickle* msg, base::PickleIterator* iter) { if (!ResourceMessageParams::Deserialize(msg, iter)) return false; @@ -177,7 +177,7 @@ ResourceMessageReplyParams::ResourceMessageReplyParams(PP_Resource resource, ResourceMessageReplyParams::~ResourceMessageReplyParams() { } -void ResourceMessageReplyParams::Serialize(IPC::Message* msg) const { +void ResourceMessageReplyParams::Serialize(base::Pickle* msg) const { // Rather than serialize all of ResourceMessageParams first, we serialize all // non-handle data first, then the handles. When transferring to NaCl on // Windows, we need to be able to translate Windows-style handles to POSIX- @@ -186,13 +186,13 @@ void ResourceMessageReplyParams::Serialize(IPC::Message* msg) const { WriteHandles(msg); } -bool ResourceMessageReplyParams::Deserialize(const IPC::Message* msg, +bool ResourceMessageReplyParams::Deserialize(const base::Pickle* msg, base::PickleIterator* iter) { return (ReadHeader(msg, iter) && IPC::ReadParam(msg, iter, &result_) && ReadHandles(msg, iter)); } -void ResourceMessageReplyParams::WriteReplyHeader(IPC::Message* msg) const { +void ResourceMessageReplyParams::WriteReplyHeader(base::Pickle* msg) const { WriteHeader(msg); IPC::WriteParam(msg, result_); } diff --git a/ppapi/proxy/resource_message_params.h b/ppapi/proxy/resource_message_params.h index 9e76d1e..098f781 100644 --- a/ppapi/proxy/resource_message_params.h +++ b/ppapi/proxy/resource_message_params.h @@ -75,16 +75,16 @@ class PPAPI_PROXY_EXPORT ResourceMessageParams { ResourceMessageParams(); ResourceMessageParams(PP_Resource resource, int32_t sequence); - virtual void Serialize(IPC::Message* msg) const; - virtual bool Deserialize(const IPC::Message* msg, base::PickleIterator* iter); + virtual void Serialize(base::Pickle* msg) const; + virtual bool Deserialize(const base::Pickle* msg, base::PickleIterator* iter); // Writes everything except the handles to |msg|. - void WriteHeader(IPC::Message* msg) const; + void WriteHeader(base::Pickle* msg) const; // Writes the handles to |msg|. - void WriteHandles(IPC::Message* msg) const; + void WriteHandles(base::Pickle* msg) const; // Matching deserialize helpers. - bool ReadHeader(const IPC::Message* msg, base::PickleIterator* iter); - bool ReadHandles(const IPC::Message* msg, base::PickleIterator* iter); + bool ReadHeader(const base::Pickle* msg, base::PickleIterator* iter); + bool ReadHandles(const base::Pickle* msg, base::PickleIterator* iter); private: class PPAPI_PROXY_EXPORT SerializedHandles @@ -147,8 +147,8 @@ class PPAPI_PROXY_EXPORT ResourceMessageCallParams void set_has_callback() { has_callback_ = true; } bool has_callback() const { return has_callback_; } - void Serialize(IPC::Message* msg) const override; - bool Deserialize(const IPC::Message* msg, + void Serialize(base::Pickle* msg) const override; + bool Deserialize(const base::Pickle* msg, base::PickleIterator* iter) override; private: @@ -166,12 +166,12 @@ class PPAPI_PROXY_EXPORT ResourceMessageReplyParams void set_result(int32_t r) { result_ = r; } int32_t result() const { return result_; } - void Serialize(IPC::Message* msg) const override; - bool Deserialize(const IPC::Message* msg, + void Serialize(base::Pickle* msg) const override; + bool Deserialize(const base::Pickle* msg, base::PickleIterator* iter) override; // Writes everything except the handles to |msg|. - void WriteReplyHeader(IPC::Message* msg) const; + void WriteReplyHeader(base::Pickle* msg) const; private: // Pepper "result code" for the callback. @@ -186,10 +186,9 @@ namespace IPC { template <> struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::proxy::ResourceMessageCallParams> { typedef ppapi::proxy::ResourceMessageCallParams param_type; - static void Write(Message* m, const param_type& p) { - p.Serialize(m); - } - static bool Read(const Message* m, base::PickleIterator* iter, + static void Write(base::Pickle* m, const param_type& p) { p.Serialize(m); } + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, param_type* r) { return r->Deserialize(m, iter); } @@ -200,10 +199,9 @@ ParamTraits<ppapi::proxy::ResourceMessageCallParams> { template <> struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::proxy::ResourceMessageReplyParams> { typedef ppapi::proxy::ResourceMessageReplyParams param_type; - static void Write(Message* m, const param_type& p) { - p.Serialize(m); - } - static bool Read(const Message* m, base::PickleIterator* iter, + static void Write(base::Pickle* m, const param_type& p) { p.Serialize(m); } + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, param_type* r) { return r->Deserialize(m, iter); } diff --git a/ppapi/proxy/serialized_flash_menu.cc b/ppapi/proxy/serialized_flash_menu.cc index 4791b06..b59fcc4 100644 --- a/ppapi/proxy/serialized_flash_menu.cc +++ b/ppapi/proxy/serialized_flash_menu.cc @@ -21,9 +21,9 @@ const uint32_t kMaxMenuEntries = 1000; bool CheckMenu(int depth, const PP_Flash_Menu* menu); void FreeMenu(const PP_Flash_Menu* menu); -void WriteMenu(IPC::Message* m, const PP_Flash_Menu* menu); +void WriteMenu(base::Pickle* m, const PP_Flash_Menu* menu); PP_Flash_Menu* ReadMenu(int depth, - const IPC::Message* m, + const base::Pickle* m, base::PickleIterator* iter); bool CheckMenuItem(int depth, const PP_Flash_MenuItem* item) { @@ -47,7 +47,7 @@ bool CheckMenu(int depth, const PP_Flash_Menu* menu) { return true; } -void WriteMenuItem(IPC::Message* m, const PP_Flash_MenuItem* menu_item) { +void WriteMenuItem(base::Pickle* m, const PP_Flash_MenuItem* menu_item) { PP_Flash_MenuItem_Type type = menu_item->type; m->WriteUInt32(type); m->WriteString(menu_item->name ? menu_item->name : ""); @@ -58,7 +58,7 @@ void WriteMenuItem(IPC::Message* m, const PP_Flash_MenuItem* menu_item) { WriteMenu(m, menu_item->submenu); } -void WriteMenu(IPC::Message* m, const PP_Flash_Menu* menu) { +void WriteMenu(base::Pickle* m, const PP_Flash_Menu* menu) { m->WriteUInt32(menu->count); for (uint32_t i = 0; i < menu->count; ++i) WriteMenuItem(m, menu->items + i); @@ -81,7 +81,7 @@ void FreeMenu(const PP_Flash_Menu* menu) { } bool ReadMenuItem(int depth, - const IPC::Message* m, + const base::Pickle* m, base::PickleIterator* iter, PP_Flash_MenuItem* menu_item) { uint32_t type; @@ -111,7 +111,7 @@ bool ReadMenuItem(int depth, } PP_Flash_Menu* ReadMenu(int depth, - const IPC::Message* m, + const base::Pickle* m, base::PickleIterator* iter) { if (depth > kMaxMenuDepth) return NULL; @@ -165,12 +165,11 @@ bool SerializedFlashMenu::SetPPMenu(const PP_Flash_Menu* menu) { return true; } - -void SerializedFlashMenu::WriteToMessage(IPC::Message* m) const { +void SerializedFlashMenu::WriteToMessage(base::Pickle* m) const { WriteMenu(m, pp_menu_); } -bool SerializedFlashMenu::ReadFromMessage(const IPC::Message* m, +bool SerializedFlashMenu::ReadFromMessage(const base::Pickle* m, base::PickleIterator* iter) { DCHECK(!pp_menu_); pp_menu_ = ReadMenu(0, m, iter); diff --git a/ppapi/proxy/serialized_flash_menu.h b/ppapi/proxy/serialized_flash_menu.h index 607c603..3160b26 100644 --- a/ppapi/proxy/serialized_flash_menu.h +++ b/ppapi/proxy/serialized_flash_menu.h @@ -12,6 +12,7 @@ #include "ppapi/proxy/ppapi_proxy_export.h" namespace base { +class Pickle; class PickleIterator; } @@ -33,8 +34,8 @@ class PPAPI_PROXY_EXPORT SerializedFlashMenu { const PP_Flash_Menu* pp_menu() const { return pp_menu_; } - void WriteToMessage(IPC::Message* m) const; - bool ReadFromMessage(const IPC::Message* m, base::PickleIterator* iter); + void WriteToMessage(base::Pickle* m) const; + bool ReadFromMessage(const base::Pickle* m, base::PickleIterator* iter); private: const PP_Flash_Menu* pp_menu_; diff --git a/ppapi/proxy/serialized_var.cc b/ppapi/proxy/serialized_var.cc index 4d3ecff..bbdba09 100644 --- a/ppapi/proxy/serialized_var.cc +++ b/ppapi/proxy/serialized_var.cc @@ -19,7 +19,7 @@ namespace ppapi { namespace proxy { namespace { -void DefaultHandleWriter(IPC::Message* m, const SerializedHandle& handle) { +void DefaultHandleWriter(base::Pickle* m, const SerializedHandle& handle) { IPC::ParamTraits<SerializedHandle>::Write(m, handle); } } // namespace @@ -95,7 +95,7 @@ void SerializedVar::Inner::ForceSetVarValueForTest(PP_Var value) { raw_var_data_.reset(NULL); } -void SerializedVar::Inner::WriteToMessage(IPC::Message* m) const { +void SerializedVar::Inner::WriteToMessage(base::Pickle* m) const { // When writing to the IPC messages, a serialization rules handler should // always have been set. // @@ -124,7 +124,7 @@ void SerializedVar::Inner::WriteToMessage(IPC::Message* m) const { } void SerializedVar::Inner::WriteDataToMessage( - IPC::Message* m, + base::Pickle* m, const HandleWriter& handle_writer) const { if (raw_var_data_) { m->WriteBool(true); // Success. @@ -134,7 +134,7 @@ void SerializedVar::Inner::WriteDataToMessage( } } -bool SerializedVar::Inner::ReadFromMessage(const IPC::Message* m, +bool SerializedVar::Inner::ReadFromMessage(const base::Pickle* m, base::PickleIterator* iter) { #ifndef NDEBUG // We should only deserialize something once or will end up with leaked diff --git a/ppapi/proxy/serialized_var.h b/ppapi/proxy/serialized_var.h index 3f8ec99..85c0018 100644 --- a/ppapi/proxy/serialized_var.h +++ b/ppapi/proxy/serialized_var.h @@ -81,17 +81,15 @@ class PPAPI_PROXY_EXPORT SerializedVar { ~SerializedVar(); // Backend implementation for IPC::ParamTraits<SerializedVar>. - void WriteToMessage(IPC::Message* m) const { - inner_->WriteToMessage(m); - } + void WriteToMessage(base::Pickle* m) const { inner_->WriteToMessage(m); } // If ReadFromMessage has been called, WriteDataToMessage will write the var // that has been read from ReadFromMessage back to a message. This is used // when converting handles for use in NaCl. - void WriteDataToMessage(IPC::Message* m, + void WriteDataToMessage(base::Pickle* m, const HandleWriter& handle_writer) const { inner_->WriteDataToMessage(m, handle_writer); } - bool ReadFromMessage(const IPC::Message* m, base::PickleIterator* iter) { + bool ReadFromMessage(const base::Pickle* m, base::PickleIterator* iter) { return inner_->ReadFromMessage(m, iter); } @@ -144,10 +142,10 @@ class PPAPI_PROXY_EXPORT SerializedVar { // it was just received off the wire, without any serialization rules. void ForceSetVarValueForTest(PP_Var value); - void WriteToMessage(IPC::Message* m) const; - void WriteDataToMessage(IPC::Message* m, + void WriteToMessage(base::Pickle* m) const; + void WriteDataToMessage(base::Pickle* m, const HandleWriter& handle_writer) const; - bool ReadFromMessage(const IPC::Message* m, base::PickleIterator* iter); + bool ReadFromMessage(const base::Pickle* m, base::PickleIterator* iter); // Sets the cleanup mode. See the CleanupMode enum below. void SetCleanupModeToEndSendPassRef(); diff --git a/printing/pdf_render_settings.h b/printing/pdf_render_settings.h index a2e182e..5c5542a 100644 --- a/printing/pdf_render_settings.h +++ b/printing/pdf_render_settings.h @@ -36,13 +36,14 @@ namespace IPC { template <> struct ParamTraits<printing::PdfRenderSettings> { typedef printing::PdfRenderSettings param_type; - static void Write(Message* m, const param_type& p) { + static void Write(base::Pickle* m, const param_type& p) { WriteParam(m, p.area_); WriteParam(m, p.dpi_); WriteParam(m, p.autorotate_); } - static bool Read(const Message* m, base::PickleIterator* iter, + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, param_type* r) { return ReadParam(m, iter, &r->area_) && ReadParam(m, iter, &r->dpi_) && diff --git a/remoting/host/chromoting_param_traits.cc b/remoting/host/chromoting_param_traits.cc index 80e749e..89918aa 100644 --- a/remoting/host/chromoting_param_traits.cc +++ b/remoting/host/chromoting_param_traits.cc @@ -12,14 +12,14 @@ namespace IPC { // static -void ParamTraits<webrtc::DesktopVector>::Write(Message* m, +void ParamTraits<webrtc::DesktopVector>::Write(base::Pickle* m, const webrtc::DesktopVector& p) { m->WriteInt(p.x()); m->WriteInt(p.y()); } // static -bool ParamTraits<webrtc::DesktopVector>::Read(const Message* m, +bool ParamTraits<webrtc::DesktopVector>::Read(const base::Pickle* m, base::PickleIterator* iter, webrtc::DesktopVector* r) { int x, y; @@ -37,14 +37,14 @@ void ParamTraits<webrtc::DesktopVector>::Log(const webrtc::DesktopVector& p, } // static -void ParamTraits<webrtc::DesktopSize>::Write(Message* m, +void ParamTraits<webrtc::DesktopSize>::Write(base::Pickle* m, const webrtc::DesktopSize& p) { m->WriteInt(p.width()); m->WriteInt(p.height()); } // static -bool ParamTraits<webrtc::DesktopSize>::Read(const Message* m, +bool ParamTraits<webrtc::DesktopSize>::Read(const base::Pickle* m, base::PickleIterator* iter, webrtc::DesktopSize* r) { int width, height; @@ -62,7 +62,7 @@ void ParamTraits<webrtc::DesktopSize>::Log(const webrtc::DesktopSize& p, } // static -void ParamTraits<webrtc::DesktopRect>::Write(Message* m, +void ParamTraits<webrtc::DesktopRect>::Write(base::Pickle* m, const webrtc::DesktopRect& p) { m->WriteInt(p.left()); m->WriteInt(p.top()); @@ -71,7 +71,7 @@ void ParamTraits<webrtc::DesktopRect>::Write(Message* m, } // static -bool ParamTraits<webrtc::DesktopRect>::Read(const Message* m, +bool ParamTraits<webrtc::DesktopRect>::Read(const base::Pickle* m, base::PickleIterator* iter, webrtc::DesktopRect* r) { int left, right, top, bottom; @@ -91,9 +91,8 @@ void ParamTraits<webrtc::DesktopRect>::Log(const webrtc::DesktopRect& p, } // static -void ParamTraits<webrtc::MouseCursor>::Write( - Message* m, - const webrtc::MouseCursor& p) { +void ParamTraits<webrtc::MouseCursor>::Write(base::Pickle* m, + const webrtc::MouseCursor& p) { ParamTraits<webrtc::DesktopSize>::Write(m, p.image()->size()); // Data is serialized in such a way that size is exactly width * height * @@ -112,7 +111,7 @@ void ParamTraits<webrtc::MouseCursor>::Write( } // static -bool ParamTraits<webrtc::MouseCursor>::Read(const Message* m, +bool ParamTraits<webrtc::MouseCursor>::Read(const base::Pickle* m, base::PickleIterator* iter, webrtc::MouseCursor* r) { webrtc::DesktopSize size; @@ -155,7 +154,7 @@ void ParamTraits<webrtc::MouseCursor>::Log( // static void ParamTraits<remoting::ScreenResolution>::Write( - Message* m, + base::Pickle* m, const remoting::ScreenResolution& p) { ParamTraits<webrtc::DesktopSize>::Write(m, p.dimensions()); ParamTraits<webrtc::DesktopVector>::Write(m, p.dpi()); @@ -163,7 +162,7 @@ void ParamTraits<remoting::ScreenResolution>::Write( // static bool ParamTraits<remoting::ScreenResolution>::Read( - const Message* m, + const base::Pickle* m, base::PickleIterator* iter, remoting::ScreenResolution* r) { webrtc::DesktopSize size; diff --git a/remoting/host/chromoting_param_traits.h b/remoting/host/chromoting_param_traits.h index 9da88f8..b13bc82 100644 --- a/remoting/host/chromoting_param_traits.h +++ b/remoting/host/chromoting_param_traits.h @@ -17,40 +17,50 @@ namespace IPC { template <> struct ParamTraits<webrtc::DesktopVector> { typedef webrtc::DesktopVector param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct ParamTraits<webrtc::DesktopSize> { typedef webrtc::DesktopSize param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct ParamTraits<webrtc::DesktopRect> { typedef webrtc::DesktopRect param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct ParamTraits<webrtc::MouseCursor> { typedef webrtc::MouseCursor param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct ParamTraits<remoting::ScreenResolution> { typedef remoting::ScreenResolution param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; diff --git a/ui/events/ipc/latency_info_param_traits.cc b/ui/events/ipc/latency_info_param_traits.cc index 27d9ab6..0bb2edc0 100644 --- a/ui/events/ipc/latency_info_param_traits.cc +++ b/ui/events/ipc/latency_info_param_traits.cc @@ -29,8 +29,7 @@ namespace IPC { #include "ui/events/ipc/latency_info_param_traits.h" namespace IPC { -void ParamTraits<ui::LatencyInfo>::Write(Message* m, - const param_type& p) { +void ParamTraits<ui::LatencyInfo>::Write(base::Pickle* m, const param_type& p) { WriteParam(m, p.trace_name_); WriteParam(m, p.latency_components_); WriteParam(m, p.input_coordinates_size_); @@ -45,7 +44,7 @@ void ParamTraits<ui::LatencyInfo>::Write(Message* m, WriteParam(m, p.terminated_); } -bool ParamTraits<ui::LatencyInfo>::Read(const Message* m, +bool ParamTraits<ui::LatencyInfo>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* p) { if (!ReadParam(m, iter, &p->trace_name_)) diff --git a/ui/events/ipc/latency_info_param_traits.h b/ui/events/ipc/latency_info_param_traits.h index 0716f43..9e11104 100644 --- a/ui/events/ipc/latency_info_param_traits.h +++ b/ui/events/ipc/latency_info_param_traits.h @@ -12,8 +12,10 @@ namespace IPC { template <> struct EVENTS_IPC_EXPORT ParamTraits<ui::LatencyInfo> { typedef ui::LatencyInfo param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* p); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* p); static void Log(const param_type& p, std::string* l); }; } // namespace IPC diff --git a/ui/gfx/ipc/gfx_param_traits.cc b/ui/gfx/ipc/gfx_param_traits.cc index a49e1da..68d8b3d 100644 --- a/ui/gfx/ipc/gfx_param_traits.cc +++ b/ui/gfx/ipc/gfx_param_traits.cc @@ -61,12 +61,12 @@ struct SkBitmap_Data { namespace IPC { -void ParamTraits<gfx::Point>::Write(Message* m, const gfx::Point& p) { +void ParamTraits<gfx::Point>::Write(base::Pickle* m, const gfx::Point& p) { WriteParam(m, p.x()); WriteParam(m, p.y()); } -bool ParamTraits<gfx::Point>::Read(const Message* m, +bool ParamTraits<gfx::Point>::Read(const base::Pickle* m, base::PickleIterator* iter, gfx::Point* r) { int x, y; @@ -81,12 +81,12 @@ void ParamTraits<gfx::Point>::Log(const gfx::Point& p, std::string* l) { l->append(base::StringPrintf("(%d, %d)", p.x(), p.y())); } -void ParamTraits<gfx::PointF>::Write(Message* m, const gfx::PointF& p) { +void ParamTraits<gfx::PointF>::Write(base::Pickle* m, const gfx::PointF& p) { WriteParam(m, p.x()); WriteParam(m, p.y()); } -bool ParamTraits<gfx::PointF>::Read(const Message* m, +bool ParamTraits<gfx::PointF>::Read(const base::Pickle* m, base::PickleIterator* iter, gfx::PointF* r) { float x, y; @@ -101,13 +101,13 @@ void ParamTraits<gfx::PointF>::Log(const gfx::PointF& p, std::string* l) { l->append(base::StringPrintf("(%f, %f)", p.x(), p.y())); } -void ParamTraits<gfx::Point3F>::Write(Message* m, const gfx::Point3F& p) { +void ParamTraits<gfx::Point3F>::Write(base::Pickle* m, const gfx::Point3F& p) { WriteParam(m, p.x()); WriteParam(m, p.y()); WriteParam(m, p.z()); } -bool ParamTraits<gfx::Point3F>::Read(const Message* m, +bool ParamTraits<gfx::Point3F>::Read(const base::Pickle* m, base::PickleIterator* iter, gfx::Point3F* r) { float x, y, z; @@ -124,14 +124,14 @@ void ParamTraits<gfx::Point3F>::Log(const gfx::Point3F& p, std::string* l) { l->append(base::StringPrintf("(%f, %f, %f)", p.x(), p.y(), p.z())); } -void ParamTraits<gfx::Size>::Write(Message* m, const gfx::Size& p) { +void ParamTraits<gfx::Size>::Write(base::Pickle* m, const gfx::Size& p) { DCHECK_GE(p.width(), 0); DCHECK_GE(p.height(), 0); int values[2] = { p.width(), p.height() }; m->WriteBytes(&values, sizeof(int) * 2); } -bool ParamTraits<gfx::Size>::Read(const Message* m, +bool ParamTraits<gfx::Size>::Read(const base::Pickle* m, base::PickleIterator* iter, gfx::Size* r) { const char* char_values; @@ -149,12 +149,12 @@ void ParamTraits<gfx::Size>::Log(const gfx::Size& p, std::string* l) { l->append(base::StringPrintf("(%d, %d)", p.width(), p.height())); } -void ParamTraits<gfx::SizeF>::Write(Message* m, const gfx::SizeF& p) { +void ParamTraits<gfx::SizeF>::Write(base::Pickle* m, const gfx::SizeF& p) { float values[2] = { p.width(), p.height() }; m->WriteBytes(&values, sizeof(float) * 2); } -bool ParamTraits<gfx::SizeF>::Read(const Message* m, +bool ParamTraits<gfx::SizeF>::Read(const base::Pickle* m, base::PickleIterator* iter, gfx::SizeF* r) { const char* char_values; @@ -170,12 +170,13 @@ void ParamTraits<gfx::SizeF>::Log(const gfx::SizeF& p, std::string* l) { l->append(base::StringPrintf("(%f, %f)", p.width(), p.height())); } -void ParamTraits<gfx::Vector2d>::Write(Message* m, const gfx::Vector2d& p) { +void ParamTraits<gfx::Vector2d>::Write(base::Pickle* m, + const gfx::Vector2d& p) { int values[2] = { p.x(), p.y() }; m->WriteBytes(&values, sizeof(int) * 2); } -bool ParamTraits<gfx::Vector2d>::Read(const Message* m, +bool ParamTraits<gfx::Vector2d>::Read(const base::Pickle* m, base::PickleIterator* iter, gfx::Vector2d* r) { const char* char_values; @@ -191,12 +192,13 @@ void ParamTraits<gfx::Vector2d>::Log(const gfx::Vector2d& v, std::string* l) { l->append(base::StringPrintf("(%d, %d)", v.x(), v.y())); } -void ParamTraits<gfx::Vector2dF>::Write(Message* m, const gfx::Vector2dF& p) { +void ParamTraits<gfx::Vector2dF>::Write(base::Pickle* m, + const gfx::Vector2dF& p) { float values[2] = { p.x(), p.y() }; m->WriteBytes(&values, sizeof(float) * 2); } -bool ParamTraits<gfx::Vector2dF>::Read(const Message* m, +bool ParamTraits<gfx::Vector2dF>::Read(const base::Pickle* m, base::PickleIterator* iter, gfx::Vector2dF* r) { const char* char_values; @@ -212,12 +214,12 @@ void ParamTraits<gfx::Vector2dF>::Log(const gfx::Vector2dF& v, std::string* l) { l->append(base::StringPrintf("(%f, %f)", v.x(), v.y())); } -void ParamTraits<gfx::Rect>::Write(Message* m, const gfx::Rect& p) { +void ParamTraits<gfx::Rect>::Write(base::Pickle* m, const gfx::Rect& p) { int values[4] = { p.x(), p.y(), p.width(), p.height() }; m->WriteBytes(&values, sizeof(int) * 4); } -bool ParamTraits<gfx::Rect>::Read(const Message* m, +bool ParamTraits<gfx::Rect>::Read(const base::Pickle* m, base::PickleIterator* iter, gfx::Rect* r) { const char* char_values; @@ -235,12 +237,12 @@ void ParamTraits<gfx::Rect>::Log(const gfx::Rect& p, std::string* l) { p.width(), p.height())); } -void ParamTraits<gfx::RectF>::Write(Message* m, const gfx::RectF& p) { +void ParamTraits<gfx::RectF>::Write(base::Pickle* m, const gfx::RectF& p) { float values[4] = { p.x(), p.y(), p.width(), p.height() }; m->WriteBytes(&values, sizeof(float) * 4); } -bool ParamTraits<gfx::RectF>::Read(const Message* m, +bool ParamTraits<gfx::RectF>::Read(const base::Pickle* m, base::PickleIterator* iter, gfx::RectF* r) { const char* char_values; @@ -256,7 +258,7 @@ void ParamTraits<gfx::RectF>::Log(const gfx::RectF& p, std::string* l) { p.width(), p.height())); } -void ParamTraits<SkBitmap>::Write(Message* m, const SkBitmap& p) { +void ParamTraits<SkBitmap>::Write(base::Pickle* m, const SkBitmap& p) { size_t fixed_size = sizeof(SkBitmap_Data); SkBitmap_Data bmp_data; bmp_data.InitSkBitmapDataForTransfer(p); @@ -268,7 +270,7 @@ void ParamTraits<SkBitmap>::Write(Message* m, const SkBitmap& p) { static_cast<int>(pixel_size)); } -bool ParamTraits<SkBitmap>::Read(const Message* m, +bool ParamTraits<SkBitmap>::Read(const base::Pickle* m, base::PickleIterator* iter, SkBitmap* r) { const char* fixed_data; @@ -297,12 +299,12 @@ void ParamTraits<SkBitmap>::Log(const SkBitmap& p, std::string* l) { l->append("<SkBitmap>"); } -void ParamTraits<gfx::Range>::Write(Message* m, const gfx::Range& r) { +void ParamTraits<gfx::Range>::Write(base::Pickle* m, const gfx::Range& r) { m->WriteSizeT(r.start()); m->WriteSizeT(r.end()); } -bool ParamTraits<gfx::Range>::Read(const Message* m, +bool ParamTraits<gfx::Range>::Read(const base::Pickle* m, base::PickleIterator* iter, gfx::Range* r) { size_t start, end; @@ -317,12 +319,13 @@ void ParamTraits<gfx::Range>::Log(const gfx::Range& r, std::string* l) { l->append(base::StringPrintf("(%" PRIuS ", %" PRIuS ")", r.start(), r.end())); } -void ParamTraits<gfx::ScrollOffset>::Write(Message* m, const param_type& p) { +void ParamTraits<gfx::ScrollOffset>::Write(base::Pickle* m, + const param_type& p) { m->WriteDouble(p.x()); m->WriteDouble(p.y()); } -bool ParamTraits<gfx::ScrollOffset>::Read(const Message* m, +bool ParamTraits<gfx::ScrollOffset>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { double x = 0.f; @@ -346,14 +349,14 @@ void ParamTraits<gfx::ScrollOffset>::Log(const param_type& p, std::string* l) { #if defined(OS_MACOSX) && !defined(OS_IOS) void ParamTraits<gfx::ScopedRefCountedIOSurfaceMachPort>::Write( - Message* m, + base::Pickle* m, const param_type p) { MachPortMac mach_port_mac(p.get()); ParamTraits<MachPortMac>::Write(m, mach_port_mac); } bool ParamTraits<gfx::ScopedRefCountedIOSurfaceMachPort>::Read( - const Message* m, + const base::Pickle* m, base::PickleIterator* iter, param_type* r) { MachPortMac mach_port_mac; diff --git a/ui/gfx/ipc/gfx_param_traits.h b/ui/gfx/ipc/gfx_param_traits.h index b7280ef..55c1b85 100644 --- a/ui/gfx/ipc/gfx_param_traits.h +++ b/ui/gfx/ipc/gfx_param_traits.h @@ -38,83 +38,103 @@ namespace IPC { template <> struct GFX_IPC_EXPORT ParamTraits<gfx::Point> { typedef gfx::Point param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct GFX_IPC_EXPORT ParamTraits<gfx::PointF> { typedef gfx::PointF param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct GFX_IPC_EXPORT ParamTraits<gfx::Point3F> { typedef gfx::Point3F param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct GFX_IPC_EXPORT ParamTraits<gfx::Size> { typedef gfx::Size param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct GFX_IPC_EXPORT ParamTraits<gfx::SizeF> { typedef gfx::SizeF param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct GFX_IPC_EXPORT ParamTraits<gfx::Vector2d> { typedef gfx::Vector2d param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct GFX_IPC_EXPORT ParamTraits<gfx::Vector2dF> { typedef gfx::Vector2dF param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct GFX_IPC_EXPORT ParamTraits<gfx::Rect> { typedef gfx::Rect param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct GFX_IPC_EXPORT ParamTraits<gfx::RectF> { typedef gfx::RectF param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct GFX_IPC_EXPORT ParamTraits<SkBitmap> { typedef SkBitmap param_type; - static void Write(Message* m, const param_type& p); + static void Write(base::Pickle* m, const param_type& p); // 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, base::PickleIterator* iter, param_type* r); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -122,16 +142,20 @@ struct GFX_IPC_EXPORT ParamTraits<SkBitmap> { template <> struct GFX_IPC_EXPORT ParamTraits<gfx::Range> { typedef gfx::Range param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; template <> struct GFX_IPC_EXPORT ParamTraits<gfx::ScrollOffset> { typedef gfx::ScrollOffset param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; @@ -139,12 +163,14 @@ struct GFX_IPC_EXPORT ParamTraits<gfx::ScrollOffset> { template <> struct GFX_IPC_EXPORT ParamTraits<gfx::ScopedRefCountedIOSurfaceMachPort> { typedef gfx::ScopedRefCountedIOSurfaceMachPort param_type; - static void Write(Message* m, const param_type p); + static void Write(base::Pickle* m, const param_type p); // Note: Read() passes ownership of the Mach send right from the IPC message // to the ScopedRefCountedIOSurfaceMachPort. Therefore, Read() may only be // called once for a given message, otherwise the singular right will be // managed and released by two objects. - static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); static void Log(const param_type& p, std::string* l); }; #endif // defined(OS_MACOSX) && !defined(OS_IOS) |