diff --git a/accessible/ipc/IPCTypes.h b/accessible/ipc/IPCTypes.h index e0b842fea7ff..c04452355131 100644 --- a/accessible/ipc/IPCTypes.h +++ b/accessible/ipc/IPCTypes.h @@ -49,13 +49,12 @@ template <> struct ParamTraits { typedef mozilla::a11y::FontSize paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mValue); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mValue); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &(aResult->mValue)); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &(aResult->mValue)); } }; @@ -63,13 +62,12 @@ template <> struct ParamTraits { typedef mozilla::a11y::DeleteEntry paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mValue); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mValue); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &(aResult->mValue)); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &(aResult->mValue)); } }; @@ -77,12 +75,11 @@ template <> struct ParamTraits { typedef mozilla::a11y::AccGroupInfo paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { MOZ_ASSERT_UNREACHABLE("Cannot serialize AccGroupInfo"); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { MOZ_ASSERT_UNREACHABLE("Cannot de-serialize AccGroupInfo"); return false; } @@ -92,13 +89,12 @@ template <> struct ParamTraits { typedef mozilla::a11y::Color paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mValue); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mValue); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &(aResult->mValue)); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &(aResult->mValue)); } }; @@ -106,27 +102,26 @@ template <> struct ParamTraits { typedef mozilla::a11y::AccAttributes paramType; - static void Write(Message* aMsg, const paramType* aParam) { + static void Write(MessageWriter* aWriter, const paramType* aParam) { if (!aParam) { - WriteParam(aMsg, true); + WriteParam(aWriter, true); return; } - WriteParam(aMsg, false); + WriteParam(aWriter, false); uint32_t count = aParam->mData.Count(); - WriteParam(aMsg, count); + WriteParam(aWriter, count); for (auto iter = aParam->mData.ConstIter(); !iter.Done(); iter.Next()) { RefPtr key = iter.Key(); - WriteParam(aMsg, key); + WriteParam(aWriter, key); const paramType::AttrValueType& data = iter.Data(); - WriteParam(aMsg, data); + WriteParam(aWriter, data); } } - static bool Read(const Message* aMsg, PickleIterator* aIter, - RefPtr* aResult) { + static bool Read(MessageReader* aReader, RefPtr* aResult) { bool isNull = false; - if (!ReadParam(aMsg, aIter, &isNull)) { + if (!ReadParam(aReader, &isNull)) { return false; } @@ -137,16 +132,16 @@ struct ParamTraits { *aResult = mozilla::MakeRefPtr(); uint32_t count; - if (!ReadParam(aMsg, aIter, &count)) { + if (!ReadParam(aReader, &count)) { return false; } for (uint32_t i = 0; i < count; ++i) { RefPtr key; - if (!ReadParam(aMsg, aIter, &key)) { + if (!ReadParam(aReader, &key)) { return false; } paramType::AttrValueType val(0); - if (!ReadParam(aMsg, aIter, &val)) { + if (!ReadParam(aReader, &val)) { return false; } (*aResult)->mData.InsertOrUpdate(key, std::move(val)); diff --git a/chrome/RegistryMessageUtils.h b/chrome/RegistryMessageUtils.h index cc682676dc26..c022a8071425 100644 --- a/chrome/RegistryMessageUtils.h +++ b/chrome/RegistryMessageUtils.h @@ -59,14 +59,13 @@ template <> struct ParamTraits { typedef SerializedURI paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.spec); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.spec); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { nsCString spec; - if (ReadParam(aMsg, aIter, &spec)) { + if (ReadParam(aReader, &spec)) { aResult->spec = spec; return true; } @@ -78,25 +77,22 @@ template <> struct ParamTraits { typedef ChromePackage paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.package); - WriteParam(aMsg, aParam.contentBaseURI); - WriteParam(aMsg, aParam.localeBaseURI); - WriteParam(aMsg, aParam.skinBaseURI); - WriteParam(aMsg, aParam.flags); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.package); + WriteParam(aWriter, aParam.contentBaseURI); + WriteParam(aWriter, aParam.localeBaseURI); + WriteParam(aWriter, aParam.skinBaseURI); + WriteParam(aWriter, aParam.flags); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { nsCString package; SerializedURI contentBaseURI, localeBaseURI, skinBaseURI; uint32_t flags; - if (ReadParam(aMsg, aIter, &package) && - ReadParam(aMsg, aIter, &contentBaseURI) && - ReadParam(aMsg, aIter, &localeBaseURI) && - ReadParam(aMsg, aIter, &skinBaseURI) && - ReadParam(aMsg, aIter, &flags)) { + if (ReadParam(aReader, &package) && ReadParam(aReader, &contentBaseURI) && + ReadParam(aReader, &localeBaseURI) && + ReadParam(aReader, &skinBaseURI) && ReadParam(aReader, &flags)) { aResult->package = package; aResult->contentBaseURI = contentBaseURI; aResult->localeBaseURI = localeBaseURI; @@ -119,22 +115,20 @@ template <> struct ParamTraits { typedef SubstitutionMapping paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.scheme); - WriteParam(aMsg, aParam.path); - WriteParam(aMsg, aParam.resolvedURI); - WriteParam(aMsg, aParam.flags); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.scheme); + WriteParam(aWriter, aParam.path); + WriteParam(aWriter, aParam.resolvedURI); + WriteParam(aWriter, aParam.flags); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { nsCString scheme, path; SerializedURI resolvedURI; uint32_t flags; - if (ReadParam(aMsg, aIter, &scheme) && ReadParam(aMsg, aIter, &path) && - ReadParam(aMsg, aIter, &resolvedURI) && - ReadParam(aMsg, aIter, &flags)) { + if (ReadParam(aReader, &scheme) && ReadParam(aReader, &path) && + ReadParam(aReader, &resolvedURI) && ReadParam(aReader, &flags)) { aResult->scheme = scheme; aResult->path = path; aResult->resolvedURI = resolvedURI; @@ -155,18 +149,16 @@ template <> struct ParamTraits { typedef OverrideMapping paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.originalURI); - WriteParam(aMsg, aParam.overrideURI); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.originalURI); + WriteParam(aWriter, aParam.overrideURI); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { SerializedURI originalURI; SerializedURI overrideURI; - if (ReadParam(aMsg, aIter, &originalURI) && - ReadParam(aMsg, aIter, &overrideURI)) { + if (ReadParam(aReader, &originalURI) && ReadParam(aReader, &overrideURI)) { aResult->originalURI = originalURI; aResult->overrideURI = overrideURI; return true; diff --git a/docshell/base/BrowsingContext.cpp b/docshell/base/BrowsingContext.cpp index 6a59136e5b2e..ae0944e11bd3 100644 --- a/docshell/base/BrowsingContext.cpp +++ b/docshell/base/BrowsingContext.cpp @@ -3711,19 +3711,19 @@ void BrowsingContext::ResetLocationChangeRateLimit() { namespace ipc { void IPDLParamTraits>::Write( - IPC::Message* aMsg, IProtocol* aActor, + IPC::MessageWriter* aWriter, IProtocol* aActor, const dom::MaybeDiscarded& aParam) { MOZ_DIAGNOSTIC_ASSERT(!aParam.GetMaybeDiscarded() || aParam.GetMaybeDiscarded()->EverAttached()); uint64_t id = aParam.ContextId(); - WriteIPDLParam(aMsg, aActor, id); + WriteIPDLParam(aWriter, aActor, id); } bool IPDLParamTraits>::Read( - const IPC::Message* aMsg, PickleIterator* aIter, IProtocol* aActor, + IPC::MessageReader* aReader, IProtocol* aActor, dom::MaybeDiscarded* aResult) { uint64_t id = 0; - if (!ReadIPDLParam(aMsg, aIter, aActor, &id)) { + if (!ReadIPDLParam(aReader, aActor, &id)) { return false; } @@ -3738,43 +3738,39 @@ bool IPDLParamTraits>::Read( } void IPDLParamTraits::Write( - IPC::Message* aMessage, IProtocol* aActor, + IPC::MessageWriter* aWriter, IProtocol* aActor, const dom::BrowsingContext::IPCInitializer& aInit) { // Write actor ID parameters. - WriteIPDLParam(aMessage, aActor, aInit.mId); - WriteIPDLParam(aMessage, aActor, aInit.mParentId); - WriteIPDLParam(aMessage, aActor, aInit.mWindowless); - WriteIPDLParam(aMessage, aActor, aInit.mUseRemoteTabs); - WriteIPDLParam(aMessage, aActor, aInit.mUseRemoteSubframes); - WriteIPDLParam(aMessage, aActor, aInit.mCreatedDynamically); - WriteIPDLParam(aMessage, aActor, aInit.mChildOffset); - WriteIPDLParam(aMessage, aActor, aInit.mOriginAttributes); - WriteIPDLParam(aMessage, aActor, aInit.mRequestContextId); - WriteIPDLParam(aMessage, aActor, aInit.mSessionHistoryIndex); - WriteIPDLParam(aMessage, aActor, aInit.mSessionHistoryCount); - WriteIPDLParam(aMessage, aActor, aInit.mFields); + WriteIPDLParam(aWriter, aActor, aInit.mId); + WriteIPDLParam(aWriter, aActor, aInit.mParentId); + WriteIPDLParam(aWriter, aActor, aInit.mWindowless); + WriteIPDLParam(aWriter, aActor, aInit.mUseRemoteTabs); + WriteIPDLParam(aWriter, aActor, aInit.mUseRemoteSubframes); + WriteIPDLParam(aWriter, aActor, aInit.mCreatedDynamically); + WriteIPDLParam(aWriter, aActor, aInit.mChildOffset); + WriteIPDLParam(aWriter, aActor, aInit.mOriginAttributes); + WriteIPDLParam(aWriter, aActor, aInit.mRequestContextId); + WriteIPDLParam(aWriter, aActor, aInit.mSessionHistoryIndex); + WriteIPDLParam(aWriter, aActor, aInit.mSessionHistoryCount); + WriteIPDLParam(aWriter, aActor, aInit.mFields); } bool IPDLParamTraits::Read( - const IPC::Message* aMessage, PickleIterator* aIterator, IProtocol* aActor, + IPC::MessageReader* aReader, IProtocol* aActor, dom::BrowsingContext::IPCInitializer* aInit) { // Read actor ID parameters. - if (!ReadIPDLParam(aMessage, aIterator, aActor, &aInit->mId) || - !ReadIPDLParam(aMessage, aIterator, aActor, &aInit->mParentId) || - !ReadIPDLParam(aMessage, aIterator, aActor, &aInit->mWindowless) || - !ReadIPDLParam(aMessage, aIterator, aActor, &aInit->mUseRemoteTabs) || - !ReadIPDLParam(aMessage, aIterator, aActor, - &aInit->mUseRemoteSubframes) || - !ReadIPDLParam(aMessage, aIterator, aActor, - &aInit->mCreatedDynamically) || - !ReadIPDLParam(aMessage, aIterator, aActor, &aInit->mChildOffset) || - !ReadIPDLParam(aMessage, aIterator, aActor, &aInit->mOriginAttributes) || - !ReadIPDLParam(aMessage, aIterator, aActor, &aInit->mRequestContextId) || - !ReadIPDLParam(aMessage, aIterator, aActor, - &aInit->mSessionHistoryIndex) || - !ReadIPDLParam(aMessage, aIterator, aActor, - &aInit->mSessionHistoryCount) || - !ReadIPDLParam(aMessage, aIterator, aActor, &aInit->mFields)) { + if (!ReadIPDLParam(aReader, aActor, &aInit->mId) || + !ReadIPDLParam(aReader, aActor, &aInit->mParentId) || + !ReadIPDLParam(aReader, aActor, &aInit->mWindowless) || + !ReadIPDLParam(aReader, aActor, &aInit->mUseRemoteTabs) || + !ReadIPDLParam(aReader, aActor, &aInit->mUseRemoteSubframes) || + !ReadIPDLParam(aReader, aActor, &aInit->mCreatedDynamically) || + !ReadIPDLParam(aReader, aActor, &aInit->mChildOffset) || + !ReadIPDLParam(aReader, aActor, &aInit->mOriginAttributes) || + !ReadIPDLParam(aReader, aActor, &aInit->mRequestContextId) || + !ReadIPDLParam(aReader, aActor, &aInit->mSessionHistoryIndex) || + !ReadIPDLParam(aReader, aActor, &aInit->mSessionHistoryCount) || + !ReadIPDLParam(aReader, aActor, &aInit->mFields)) { return false; } return true; diff --git a/docshell/base/BrowsingContext.h b/docshell/base/BrowsingContext.h index 8d6afd4e275c..9a2d542a03a7 100644 --- a/docshell/base/BrowsingContext.h +++ b/docshell/base/BrowsingContext.h @@ -1345,20 +1345,18 @@ extern template class syncedcontext::Transaction; namespace ipc { template <> struct IPDLParamTraits> { - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, const dom::MaybeDiscarded& aParam); - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, dom::MaybeDiscarded* aResult); }; template <> struct IPDLParamTraits { - static void Write(IPC::Message* aMessage, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, const dom::BrowsingContext::IPCInitializer& aInitializer); - static bool Read(const IPC::Message* aMessage, PickleIterator* aIterator, - IProtocol* aActor, + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, dom::BrowsingContext::IPCInitializer* aInitializer); }; } // namespace ipc diff --git a/docshell/base/SerializedLoadContext.h b/docshell/base/SerializedLoadContext.h index 689934f71462..d47ad080037b 100644 --- a/docshell/base/SerializedLoadContext.h +++ b/docshell/base/SerializedLoadContext.h @@ -63,29 +63,28 @@ template <> struct ParamTraits { typedef SerializedLoadContext paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { nsAutoCString suffix; aParam.mOriginAttributes.CreateSuffix(suffix); - WriteParam(aMsg, aParam.mIsNotNull); - WriteParam(aMsg, aParam.mIsContent); - WriteParam(aMsg, aParam.mIsPrivateBitValid); - WriteParam(aMsg, aParam.mUseRemoteTabs); - WriteParam(aMsg, aParam.mUseRemoteSubframes); - WriteParam(aMsg, aParam.mUseTrackingProtection); - WriteParam(aMsg, suffix); + WriteParam(aWriter, aParam.mIsNotNull); + WriteParam(aWriter, aParam.mIsContent); + WriteParam(aWriter, aParam.mIsPrivateBitValid); + WriteParam(aWriter, aParam.mUseRemoteTabs); + WriteParam(aWriter, aParam.mUseRemoteSubframes); + WriteParam(aWriter, aParam.mUseTrackingProtection); + WriteParam(aWriter, suffix); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { nsAutoCString suffix; - if (!ReadParam(aMsg, aIter, &aResult->mIsNotNull) || - !ReadParam(aMsg, aIter, &aResult->mIsContent) || - !ReadParam(aMsg, aIter, &aResult->mIsPrivateBitValid) || - !ReadParam(aMsg, aIter, &aResult->mUseRemoteTabs) || - !ReadParam(aMsg, aIter, &aResult->mUseRemoteSubframes) || - !ReadParam(aMsg, aIter, &aResult->mUseTrackingProtection) || - !ReadParam(aMsg, aIter, &suffix)) { + if (!ReadParam(aReader, &aResult->mIsNotNull) || + !ReadParam(aReader, &aResult->mIsContent) || + !ReadParam(aReader, &aResult->mIsPrivateBitValid) || + !ReadParam(aReader, &aResult->mUseRemoteTabs) || + !ReadParam(aReader, &aResult->mUseRemoteSubframes) || + !ReadParam(aReader, &aResult->mUseTrackingProtection) || + !ReadParam(aReader, &suffix)) { return false; } return aResult->mOriginAttributes.PopulateFromSuffix(suffix); diff --git a/docshell/base/SyncedContext.h b/docshell/base/SyncedContext.h index 669a9911f7a9..047ac41c5ccf 100644 --- a/docshell/base/SyncedContext.h +++ b/docshell/base/SyncedContext.h @@ -90,9 +90,9 @@ class Transaction { private: friend struct mozilla::ipc::IPDLParamTraits>; - void Write(IPC::Message* aMsg, mozilla::ipc::IProtocol* aActor) const; - bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - mozilla::ipc::IProtocol* aActor); + void Write(IPC::MessageWriter* aWriter, + mozilla::ipc::IProtocol* aActor) const; + bool Read(IPC::MessageReader* aReader, mozilla::ipc::IProtocol* aActor); // You probably don't want to directly call this method - instead call // `Commit`, which will perform the necessary synchronization. @@ -141,9 +141,9 @@ class FieldValues : public Base { private: friend struct mozilla::ipc::IPDLParamTraits>; - void Write(IPC::Message* aMsg, mozilla::ipc::IProtocol* aActor) const; - bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - mozilla::ipc::IProtocol* aActor); + void Write(IPC::MessageWriter* aWriter, + mozilla::ipc::IProtocol* aActor) const; + bool Read(IPC::MessageReader* aReader, mozilla::ipc::IProtocol* aActor); template static void EachIndexInner(std::index_sequence aIndexes, @@ -324,14 +324,14 @@ template struct IPDLParamTraits> { typedef dom::syncedcontext::Transaction paramType; - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, const paramType& aParam) { - aParam.Write(aMsg, aActor); + aParam.Write(aWriter, aActor); } - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, paramType* aResult) { - return aResult->Read(aMsg, aIter, aActor); + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + paramType* aResult) { + return aResult->Read(aReader, aActor); } }; @@ -339,14 +339,14 @@ template struct IPDLParamTraits> { typedef dom::syncedcontext::FieldValues paramType; - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, const paramType& aParam) { - aParam.Write(aMsg, aActor); + aParam.Write(aWriter, aActor); } - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, paramType* aResult) { - return aResult->Read(aMsg, aIter, aActor); + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + paramType* aResult) { + return aResult->Read(aReader, aActor); } }; diff --git a/docshell/base/SyncedContextInlines.h b/docshell/base/SyncedContextInlines.h index 8478ee4731e1..a12ddfdda6ed 100644 --- a/docshell/base/SyncedContextInlines.h +++ b/docshell/base/SyncedContextInlines.h @@ -294,27 +294,27 @@ typename Transaction::IndexSet Transaction::Validate( } template -void Transaction::Write(IPC::Message* aMsg, +void Transaction::Write(IPC::MessageWriter* aWriter, mozilla::ipc::IProtocol* aActor) const { // Record which field indices will be included, and then write those fields // out. typename IndexSet::serializedType modified = mModified.serialize(); - WriteIPDLParam(aMsg, aActor, modified); + WriteIPDLParam(aWriter, aActor, modified); EachIndex([&](auto idx) { if (mModified.contains(idx)) { - WriteIPDLParam(aMsg, aActor, mValues.Get(idx)); + WriteIPDLParam(aWriter, aActor, mValues.Get(idx)); } }); } template -bool Transaction::Read(const IPC::Message* aMsg, PickleIterator* aIter, +bool Transaction::Read(IPC::MessageReader* aReader, mozilla::ipc::IProtocol* aActor) { // Read in which field indices were sent by the remote, followed by the fields // identified by those indices. typename IndexSet::serializedType modified = typename IndexSet::serializedType{}; - if (!ReadIPDLParam(aMsg, aIter, aActor, &modified)) { + if (!ReadIPDLParam(aReader, aActor, &modified)) { return false; } mModified.deserialize(modified); @@ -322,30 +322,29 @@ bool Transaction::Read(const IPC::Message* aMsg, PickleIterator* aIter, bool ok = true; EachIndex([&](auto idx) { if (ok && mModified.contains(idx)) { - ok = ReadIPDLParam(aMsg, aIter, aActor, &mValues.Get(idx)); + ok = ReadIPDLParam(aReader, aActor, &mValues.Get(idx)); } }); return ok; } template -void FieldValues::Write(IPC::Message* aMsg, +void FieldValues::Write(IPC::MessageWriter* aWriter, mozilla::ipc::IProtocol* aActor) const { // XXX The this-> qualification is necessary to work around a bug in older gcc // versions causing an ICE. - EachIndex([&](auto idx) { WriteIPDLParam(aMsg, aActor, this->Get(idx)); }); + EachIndex([&](auto idx) { WriteIPDLParam(aWriter, aActor, this->Get(idx)); }); } template -bool FieldValues::Read(const IPC::Message* aMsg, - PickleIterator* aIter, +bool FieldValues::Read(IPC::MessageReader* aReader, mozilla::ipc::IProtocol* aActor) { bool ok = true; EachIndex([&](auto idx) { if (ok) { // XXX The this-> qualification is necessary to work around a bug in older // gcc versions causing an ICE. - ok = ReadIPDLParam(aMsg, aIter, aActor, &this->Get(idx)); + ok = ReadIPDLParam(aReader, aActor, &this->Get(idx)); } }); return ok; diff --git a/docshell/base/WindowContext.cpp b/docshell/base/WindowContext.cpp index 8eb488af5973..7d28e7b840c9 100644 --- a/docshell/base/WindowContext.cpp +++ b/docshell/base/WindowContext.cpp @@ -577,17 +577,17 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(WindowContext) namespace ipc { void IPDLParamTraits>::Write( - IPC::Message* aMsg, IProtocol* aActor, + IPC::MessageWriter* aWriter, IProtocol* aActor, const dom::MaybeDiscarded& aParam) { uint64_t id = aParam.ContextId(); - WriteIPDLParam(aMsg, aActor, id); + WriteIPDLParam(aWriter, aActor, id); } bool IPDLParamTraits>::Read( - const IPC::Message* aMsg, PickleIterator* aIter, IProtocol* aActor, + IPC::MessageReader* aReader, IProtocol* aActor, dom::MaybeDiscarded* aResult) { uint64_t id = 0; - if (!ReadIPDLParam(aMsg, aIter, aActor, &id)) { + if (!ReadIPDLParam(aReader, aActor, &id)) { return false; } @@ -602,24 +602,23 @@ bool IPDLParamTraits>::Read( } void IPDLParamTraits::Write( - IPC::Message* aMessage, IProtocol* aActor, + IPC::MessageWriter* aWriter, IProtocol* aActor, const dom::WindowContext::IPCInitializer& aInit) { // Write actor ID parameters. - WriteIPDLParam(aMessage, aActor, aInit.mInnerWindowId); - WriteIPDLParam(aMessage, aActor, aInit.mOuterWindowId); - WriteIPDLParam(aMessage, aActor, aInit.mBrowsingContextId); - WriteIPDLParam(aMessage, aActor, aInit.mFields); + WriteIPDLParam(aWriter, aActor, aInit.mInnerWindowId); + WriteIPDLParam(aWriter, aActor, aInit.mOuterWindowId); + WriteIPDLParam(aWriter, aActor, aInit.mBrowsingContextId); + WriteIPDLParam(aWriter, aActor, aInit.mFields); } bool IPDLParamTraits::Read( - const IPC::Message* aMessage, PickleIterator* aIterator, IProtocol* aActor, + IPC::MessageReader* aReader, IProtocol* aActor, dom::WindowContext::IPCInitializer* aInit) { // Read actor ID parameters. - return ReadIPDLParam(aMessage, aIterator, aActor, &aInit->mInnerWindowId) && - ReadIPDLParam(aMessage, aIterator, aActor, &aInit->mOuterWindowId) && - ReadIPDLParam(aMessage, aIterator, aActor, - &aInit->mBrowsingContextId) && - ReadIPDLParam(aMessage, aIterator, aActor, &aInit->mFields); + return ReadIPDLParam(aReader, aActor, &aInit->mInnerWindowId) && + ReadIPDLParam(aReader, aActor, &aInit->mOuterWindowId) && + ReadIPDLParam(aReader, aActor, &aInit->mBrowsingContextId) && + ReadIPDLParam(aReader, aActor, &aInit->mFields); } template struct IPDLParamTraits; diff --git a/docshell/base/WindowContext.h b/docshell/base/WindowContext.h index 54503d102087..e7122934c9d6 100644 --- a/docshell/base/WindowContext.h +++ b/docshell/base/WindowContext.h @@ -353,20 +353,18 @@ extern template class syncedcontext::Transaction; namespace ipc { template <> struct IPDLParamTraits> { - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, const dom::MaybeDiscarded& aParam); - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, dom::MaybeDiscarded* aResult); }; template <> struct IPDLParamTraits { - static void Write(IPC::Message* aMessage, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, const dom::WindowContext::IPCInitializer& aInitializer); - static bool Read(const IPC::Message* aMessage, PickleIterator* aIterator, - IProtocol* aActor, + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, dom::WindowContext::IPCInitializer* aInitializer); }; } // namespace ipc diff --git a/docshell/shistory/SessionHistoryEntry.cpp b/docshell/shistory/SessionHistoryEntry.cpp index 1eeb43f726c1..0448cafd8c47 100644 --- a/docshell/shistory/SessionHistoryEntry.cpp +++ b/docshell/shistory/SessionHistoryEntry.cpp @@ -1445,7 +1445,7 @@ void SessionHistoryEntry::SetInfo(SessionHistoryInfo* aInfo) { namespace ipc { void IPDLParamTraits::Write( - IPC::Message* aMsg, IProtocol* aActor, + IPC::MessageWriter* aWriter, IProtocol* aActor, const dom::SessionHistoryInfo& aParam) { Maybe> stateData; if (aParam.mStateData) { @@ -1471,63 +1471,66 @@ void IPDLParamTraits::Write( } } - WriteIPDLParam(aMsg, aActor, aParam.mURI); - WriteIPDLParam(aMsg, aActor, aParam.mOriginalURI); - WriteIPDLParam(aMsg, aActor, aParam.mResultPrincipalURI); - WriteIPDLParam(aMsg, aActor, aParam.mReferrerInfo); - WriteIPDLParam(aMsg, aActor, aParam.mTitle); - WriteIPDLParam(aMsg, aActor, aParam.mName); - WriteIPDLParam(aMsg, aActor, aParam.mPostData); - WriteIPDLParam(aMsg, aActor, aParam.mLoadType); - WriteIPDLParam(aMsg, aActor, aParam.mScrollPositionX); - WriteIPDLParam(aMsg, aActor, aParam.mScrollPositionY); - WriteIPDLParam(aMsg, aActor, stateData); - WriteIPDLParam(aMsg, aActor, aParam.mSrcdocData); - WriteIPDLParam(aMsg, aActor, aParam.mBaseURI); - WriteIPDLParam(aMsg, aActor, aParam.mLoadReplace); - WriteIPDLParam(aMsg, aActor, aParam.mURIWasModified); - WriteIPDLParam(aMsg, aActor, aParam.mScrollRestorationIsManual); - WriteIPDLParam(aMsg, aActor, aParam.mPersist); - WriteIPDLParam(aMsg, aActor, aParam.mHasUserInteraction); - WriteIPDLParam(aMsg, aActor, aParam.mHasUserActivation); - WriteIPDLParam(aMsg, aActor, aParam.mSharedState.Get()->mId); - WriteIPDLParam(aMsg, aActor, aParam.mSharedState.Get()->mTriggeringPrincipal); - WriteIPDLParam(aMsg, aActor, aParam.mSharedState.Get()->mPrincipalToInherit); - WriteIPDLParam(aMsg, aActor, + WriteIPDLParam(aWriter, aActor, aParam.mURI); + WriteIPDLParam(aWriter, aActor, aParam.mOriginalURI); + WriteIPDLParam(aWriter, aActor, aParam.mResultPrincipalURI); + WriteIPDLParam(aWriter, aActor, aParam.mReferrerInfo); + WriteIPDLParam(aWriter, aActor, aParam.mTitle); + WriteIPDLParam(aWriter, aActor, aParam.mName); + WriteIPDLParam(aWriter, aActor, aParam.mPostData); + WriteIPDLParam(aWriter, aActor, aParam.mLoadType); + WriteIPDLParam(aWriter, aActor, aParam.mScrollPositionX); + WriteIPDLParam(aWriter, aActor, aParam.mScrollPositionY); + WriteIPDLParam(aWriter, aActor, stateData); + WriteIPDLParam(aWriter, aActor, aParam.mSrcdocData); + WriteIPDLParam(aWriter, aActor, aParam.mBaseURI); + WriteIPDLParam(aWriter, aActor, aParam.mLoadReplace); + WriteIPDLParam(aWriter, aActor, aParam.mURIWasModified); + WriteIPDLParam(aWriter, aActor, aParam.mScrollRestorationIsManual); + WriteIPDLParam(aWriter, aActor, aParam.mPersist); + WriteIPDLParam(aWriter, aActor, aParam.mHasUserInteraction); + WriteIPDLParam(aWriter, aActor, aParam.mHasUserActivation); + WriteIPDLParam(aWriter, aActor, aParam.mSharedState.Get()->mId); + WriteIPDLParam(aWriter, aActor, + aParam.mSharedState.Get()->mTriggeringPrincipal); + WriteIPDLParam(aWriter, aActor, + aParam.mSharedState.Get()->mPrincipalToInherit); + WriteIPDLParam(aWriter, aActor, aParam.mSharedState.Get()->mPartitionedPrincipalToInherit); - WriteIPDLParam(aMsg, aActor, aParam.mSharedState.Get()->mCsp); - WriteIPDLParam(aMsg, aActor, aParam.mSharedState.Get()->mContentType); - WriteIPDLParam(aMsg, aActor, aParam.mSharedState.Get()->mLayoutHistoryState); - WriteIPDLParam(aMsg, aActor, aParam.mSharedState.Get()->mCacheKey); - WriteIPDLParam(aMsg, aActor, aParam.mSharedState.Get()->mIsFrameNavigation); + WriteIPDLParam(aWriter, aActor, aParam.mSharedState.Get()->mCsp); + WriteIPDLParam(aWriter, aActor, aParam.mSharedState.Get()->mContentType); + WriteIPDLParam(aWriter, aActor, + aParam.mSharedState.Get()->mLayoutHistoryState); + WriteIPDLParam(aWriter, aActor, aParam.mSharedState.Get()->mCacheKey); + WriteIPDLParam(aWriter, aActor, + aParam.mSharedState.Get()->mIsFrameNavigation); } bool IPDLParamTraits::Read( - const IPC::Message* aMsg, PickleIterator* aIter, IProtocol* aActor, + IPC::MessageReader* aReader, IProtocol* aActor, dom::SessionHistoryInfo* aResult) { Maybe> stateData; uint64_t sharedId; - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mURI) || - !ReadIPDLParam(aMsg, aIter, aActor, &aResult->mOriginalURI) || - !ReadIPDLParam(aMsg, aIter, aActor, &aResult->mResultPrincipalURI) || - !ReadIPDLParam(aMsg, aIter, aActor, &aResult->mReferrerInfo) || - !ReadIPDLParam(aMsg, aIter, aActor, &aResult->mTitle) || - !ReadIPDLParam(aMsg, aIter, aActor, &aResult->mName) || - !ReadIPDLParam(aMsg, aIter, aActor, &aResult->mPostData) || - !ReadIPDLParam(aMsg, aIter, aActor, &aResult->mLoadType) || - !ReadIPDLParam(aMsg, aIter, aActor, &aResult->mScrollPositionX) || - !ReadIPDLParam(aMsg, aIter, aActor, &aResult->mScrollPositionY) || - !ReadIPDLParam(aMsg, aIter, aActor, &stateData) || - !ReadIPDLParam(aMsg, aIter, aActor, &aResult->mSrcdocData) || - !ReadIPDLParam(aMsg, aIter, aActor, &aResult->mBaseURI) || - !ReadIPDLParam(aMsg, aIter, aActor, &aResult->mLoadReplace) || - !ReadIPDLParam(aMsg, aIter, aActor, &aResult->mURIWasModified) || - !ReadIPDLParam(aMsg, aIter, aActor, - &aResult->mScrollRestorationIsManual) || - !ReadIPDLParam(aMsg, aIter, aActor, &aResult->mPersist) || - !ReadIPDLParam(aMsg, aIter, aActor, &aResult->mHasUserInteraction) || - !ReadIPDLParam(aMsg, aIter, aActor, &aResult->mHasUserActivation) || - !ReadIPDLParam(aMsg, aIter, aActor, &sharedId)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mURI) || + !ReadIPDLParam(aReader, aActor, &aResult->mOriginalURI) || + !ReadIPDLParam(aReader, aActor, &aResult->mResultPrincipalURI) || + !ReadIPDLParam(aReader, aActor, &aResult->mReferrerInfo) || + !ReadIPDLParam(aReader, aActor, &aResult->mTitle) || + !ReadIPDLParam(aReader, aActor, &aResult->mName) || + !ReadIPDLParam(aReader, aActor, &aResult->mPostData) || + !ReadIPDLParam(aReader, aActor, &aResult->mLoadType) || + !ReadIPDLParam(aReader, aActor, &aResult->mScrollPositionX) || + !ReadIPDLParam(aReader, aActor, &aResult->mScrollPositionY) || + !ReadIPDLParam(aReader, aActor, &stateData) || + !ReadIPDLParam(aReader, aActor, &aResult->mSrcdocData) || + !ReadIPDLParam(aReader, aActor, &aResult->mBaseURI) || + !ReadIPDLParam(aReader, aActor, &aResult->mLoadReplace) || + !ReadIPDLParam(aReader, aActor, &aResult->mURIWasModified) || + !ReadIPDLParam(aReader, aActor, &aResult->mScrollRestorationIsManual) || + !ReadIPDLParam(aReader, aActor, &aResult->mPersist) || + !ReadIPDLParam(aReader, aActor, &aResult->mHasUserInteraction) || + !ReadIPDLParam(aReader, aActor, &aResult->mHasUserActivation) || + !ReadIPDLParam(aReader, aActor, &sharedId)) { aActor->FatalError("Error reading fields for SessionHistoryInfo"); return false; } @@ -1537,11 +1540,11 @@ bool IPDLParamTraits::Read( nsCOMPtr partitionedPrincipalToInherit; nsCOMPtr csp; nsCString contentType; - if (!ReadIPDLParam(aMsg, aIter, aActor, &triggeringPrincipal) || - !ReadIPDLParam(aMsg, aIter, aActor, &principalToInherit) || - !ReadIPDLParam(aMsg, aIter, aActor, &partitionedPrincipalToInherit) || - !ReadIPDLParam(aMsg, aIter, aActor, &csp) || - !ReadIPDLParam(aMsg, aIter, aActor, &contentType)) { + if (!ReadIPDLParam(aReader, aActor, &triggeringPrincipal) || + !ReadIPDLParam(aReader, aActor, &principalToInherit) || + !ReadIPDLParam(aReader, aActor, &partitionedPrincipalToInherit) || + !ReadIPDLParam(aReader, aActor, &csp) || + !ReadIPDLParam(aReader, aActor, &contentType)) { aActor->FatalError("Error reading fields for SessionHistoryInfo"); return false; } @@ -1588,11 +1591,11 @@ bool IPDLParamTraits::Read( aResult->mSharedState.Get()->mContentType = contentType; } - if (!ReadIPDLParam(aMsg, aIter, aActor, + if (!ReadIPDLParam(aReader, aActor, &aResult->mSharedState.Get()->mLayoutHistoryState) || - !ReadIPDLParam(aMsg, aIter, aActor, + !ReadIPDLParam(aReader, aActor, &aResult->mSharedState.Get()->mCacheKey) || - !ReadIPDLParam(aMsg, aIter, aActor, + !ReadIPDLParam(aReader, aActor, &aResult->mSharedState.Get()->mIsFrameNavigation)) { aActor->FatalError("Error reading fields for SessionHistoryInfo"); return false; @@ -1614,26 +1617,25 @@ bool IPDLParamTraits::Read( } void IPDLParamTraits::Write( - IPC::Message* aMsg, IProtocol* aActor, + IPC::MessageWriter* aWriter, IProtocol* aActor, const dom::LoadingSessionHistoryInfo& aParam) { - WriteIPDLParam(aMsg, aActor, aParam.mInfo); - WriteIPDLParam(aMsg, aActor, aParam.mLoadId); - WriteIPDLParam(aMsg, aActor, aParam.mLoadIsFromSessionHistory); - WriteIPDLParam(aMsg, aActor, aParam.mOffset); - WriteIPDLParam(aMsg, aActor, aParam.mLoadingCurrentEntry); - WriteIPDLParam(aMsg, aActor, aParam.mForceMaybeResetName); + WriteIPDLParam(aWriter, aActor, aParam.mInfo); + WriteIPDLParam(aWriter, aActor, aParam.mLoadId); + WriteIPDLParam(aWriter, aActor, aParam.mLoadIsFromSessionHistory); + WriteIPDLParam(aWriter, aActor, aParam.mOffset); + WriteIPDLParam(aWriter, aActor, aParam.mLoadingCurrentEntry); + WriteIPDLParam(aWriter, aActor, aParam.mForceMaybeResetName); } bool IPDLParamTraits::Read( - const IPC::Message* aMsg, PickleIterator* aIter, IProtocol* aActor, + IPC::MessageReader* aReader, IProtocol* aActor, dom::LoadingSessionHistoryInfo* aResult) { - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mInfo) || - !ReadIPDLParam(aMsg, aIter, aActor, &aResult->mLoadId) || - !ReadIPDLParam(aMsg, aIter, aActor, - &aResult->mLoadIsFromSessionHistory) || - !ReadIPDLParam(aMsg, aIter, aActor, &aResult->mOffset) || - !ReadIPDLParam(aMsg, aIter, aActor, &aResult->mLoadingCurrentEntry) || - !ReadIPDLParam(aMsg, aIter, aActor, &aResult->mForceMaybeResetName)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mInfo) || + !ReadIPDLParam(aReader, aActor, &aResult->mLoadId) || + !ReadIPDLParam(aReader, aActor, &aResult->mLoadIsFromSessionHistory) || + !ReadIPDLParam(aReader, aActor, &aResult->mOffset) || + !ReadIPDLParam(aReader, aActor, &aResult->mLoadingCurrentEntry) || + !ReadIPDLParam(aReader, aActor, &aResult->mForceMaybeResetName)) { aActor->FatalError("Error reading fields for LoadingSessionHistoryInfo"); return false; } @@ -1642,26 +1644,27 @@ bool IPDLParamTraits::Read( } void IPDLParamTraits::Write( - IPC::Message* aMsg, IProtocol* aActor, nsILayoutHistoryState* aParam) { + IPC::MessageWriter* aWriter, IProtocol* aActor, + nsILayoutHistoryState* aParam) { if (aParam) { - WriteIPDLParam(aMsg, aActor, true); + WriteIPDLParam(aWriter, aActor, true); bool scrollPositionOnly = false; nsTArray keys; nsTArray states; aParam->GetContents(&scrollPositionOnly, keys, states); - WriteIPDLParam(aMsg, aActor, scrollPositionOnly); - WriteIPDLParam(aMsg, aActor, keys); - WriteIPDLParam(aMsg, aActor, states); + WriteIPDLParam(aWriter, aActor, scrollPositionOnly); + WriteIPDLParam(aWriter, aActor, keys); + WriteIPDLParam(aWriter, aActor, states); } else { - WriteIPDLParam(aMsg, aActor, false); + WriteIPDLParam(aWriter, aActor, false); } } bool IPDLParamTraits::Read( - const IPC::Message* aMsg, PickleIterator* aIter, IProtocol* aActor, + IPC::MessageReader* aReader, IProtocol* aActor, RefPtr* aResult) { bool hasLayoutHistoryState = false; - if (!ReadIPDLParam(aMsg, aIter, aActor, &hasLayoutHistoryState)) { + if (!ReadIPDLParam(aReader, aActor, &hasLayoutHistoryState)) { aActor->FatalError("Error reading fields for nsILayoutHistoryState"); return false; } @@ -1670,9 +1673,9 @@ bool IPDLParamTraits::Read( bool scrollPositionOnly = false; nsTArray keys; nsTArray states; - if (!ReadIPDLParam(aMsg, aIter, aActor, &scrollPositionOnly) || - !ReadIPDLParam(aMsg, aIter, aActor, &keys) || - !ReadIPDLParam(aMsg, aIter, aActor, &states)) { + if (!ReadIPDLParam(aReader, aActor, &scrollPositionOnly) || + !ReadIPDLParam(aReader, aActor, &keys) || + !ReadIPDLParam(aReader, aActor, &states)) { aActor->FatalError("Error reading fields for nsILayoutHistoryState"); } @@ -1693,17 +1696,17 @@ bool IPDLParamTraits::Read( } void IPDLParamTraits::Write( - IPC::Message* aMsg, IProtocol* aActor, + IPC::MessageWriter* aWriter, IProtocol* aActor, const mozilla::dom::Wireframe& aParam) { - WriteParam(aMsg, aParam.mCanvasBackground); - WriteParam(aMsg, aParam.mRects); + WriteParam(aWriter, aParam.mCanvasBackground); + WriteParam(aWriter, aParam.mRects); } bool IPDLParamTraits::Read( - const IPC::Message* aMsg, PickleIterator* aIter, IProtocol* aActor, + IPC::MessageReader* aReader, IProtocol* aActor, mozilla::dom::Wireframe* aResult) { - return ReadParam(aMsg, aIter, &aResult->mCanvasBackground) && - ReadParam(aMsg, aIter, &aResult->mRects); + return ReadParam(aReader, &aResult->mCanvasBackground) && + ReadParam(aReader, &aResult->mRects); } } // namespace ipc @@ -1720,30 +1723,28 @@ struct ParamTraits template <> struct ParamTraits { - static void Write(Message* aMsg, + static void Write(MessageWriter* aWriter, const mozilla::dom::WireframeTaggedRect& aParam); - static bool Read(const Message* aMsg, PickleIterator* aIter, + static bool Read(MessageReader* aReader, mozilla::dom::WireframeTaggedRect* aResult); }; void ParamTraits::Write( - Message* aMsg, const mozilla::dom::WireframeTaggedRect& aParam) { - WriteParam(aMsg, aParam.mColor); - WriteParam(aMsg, aParam.mType); - WriteParam(aMsg, aParam.mX); - WriteParam(aMsg, aParam.mY); - WriteParam(aMsg, aParam.mWidth); - WriteParam(aMsg, aParam.mHeight); + MessageWriter* aWriter, const mozilla::dom::WireframeTaggedRect& aParam) { + WriteParam(aWriter, aParam.mColor); + WriteParam(aWriter, aParam.mType); + WriteParam(aWriter, aParam.mX); + WriteParam(aWriter, aParam.mY); + WriteParam(aWriter, aParam.mWidth); + WriteParam(aWriter, aParam.mHeight); } bool ParamTraits::Read( - const IPC::Message* aMsg, PickleIterator* aIter, - mozilla::dom::WireframeTaggedRect* aResult) { - return ReadParam(aMsg, aIter, &aResult->mColor) && - ReadParam(aMsg, aIter, &aResult->mType) && - ReadParam(aMsg, aIter, &aResult->mX) && - ReadParam(aMsg, aIter, &aResult->mY) && - ReadParam(aMsg, aIter, &aResult->mWidth) && - ReadParam(aMsg, aIter, &aResult->mHeight); + IPC::MessageReader* aReader, mozilla::dom::WireframeTaggedRect* aResult) { + return ReadParam(aReader, &aResult->mColor) && + ReadParam(aReader, &aResult->mType) && + ReadParam(aReader, &aResult->mX) && ReadParam(aReader, &aResult->mY) && + ReadParam(aReader, &aResult->mWidth) && + ReadParam(aReader, &aResult->mHeight); } } // namespace IPC diff --git a/docshell/shistory/SessionHistoryEntry.h b/docshell/shistory/SessionHistoryEntry.h index 4f20ab5fbb23..07c34b310c55 100644 --- a/docshell/shistory/SessionHistoryEntry.h +++ b/docshell/shistory/SessionHistoryEntry.h @@ -431,37 +431,37 @@ class IProtocol; // Allow sending SessionHistoryInfo objects over IPC. template <> struct IPDLParamTraits { - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, const dom::SessionHistoryInfo& aParam); - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, dom::SessionHistoryInfo* aResult); + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + dom::SessionHistoryInfo* aResult); }; // Allow sending LoadingSessionHistoryInfo objects over IPC. template <> struct IPDLParamTraits { - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, const dom::LoadingSessionHistoryInfo& aParam); - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, dom::LoadingSessionHistoryInfo* aResult); + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + dom::LoadingSessionHistoryInfo* aResult); }; // Allow sending nsILayoutHistoryState objects over IPC. template <> struct IPDLParamTraits { - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, nsILayoutHistoryState* aParam); - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, RefPtr* aResult); + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + RefPtr* aResult); }; // Allow sending dom::Wireframe objects over IPC. template <> struct IPDLParamTraits { - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, const mozilla::dom::Wireframe& aParam); - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, mozilla::dom::Wireframe* aResult); + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + mozilla::dom::Wireframe* aResult); }; } // namespace ipc diff --git a/dom/base/nsDOMNavigationTiming.cpp b/dom/base/nsDOMNavigationTiming.cpp index 6ed2d1b9c237..e0986cc4ff32 100644 --- a/dom/base/nsDOMNavigationTiming.cpp +++ b/dom/base/nsDOMNavigationTiming.cpp @@ -589,61 +589,61 @@ nsDOMNavigationTiming::nsDOMNavigationTiming(nsDocShell* aDocShell, /* static */ void mozilla::ipc::IPDLParamTraits::Write( - IPC::Message* aMsg, IProtocol* aActor, nsDOMNavigationTiming* aParam) { + IPC::MessageWriter* aWriter, IProtocol* aActor, + nsDOMNavigationTiming* aParam) { RefPtr unloadedURI = aParam->mUnloadedURI.get(); RefPtr loadedURI = aParam->mLoadedURI.get(); - WriteIPDLParam(aMsg, aActor, unloadedURI ? Some(unloadedURI) : Nothing()); - WriteIPDLParam(aMsg, aActor, loadedURI ? Some(loadedURI) : Nothing()); - WriteIPDLParam(aMsg, aActor, uint32_t(aParam->mNavigationType)); - WriteIPDLParam(aMsg, aActor, aParam->mNavigationStartHighRes); - WriteIPDLParam(aMsg, aActor, aParam->mNavigationStart); - WriteIPDLParam(aMsg, aActor, aParam->mNonBlankPaint); - WriteIPDLParam(aMsg, aActor, aParam->mContentfulComposite); - WriteIPDLParam(aMsg, aActor, aParam->mDOMContentFlushed); - WriteIPDLParam(aMsg, aActor, aParam->mBeforeUnloadStart); - WriteIPDLParam(aMsg, aActor, aParam->mUnloadStart); - WriteIPDLParam(aMsg, aActor, aParam->mUnloadEnd); - WriteIPDLParam(aMsg, aActor, aParam->mLoadEventStart); - WriteIPDLParam(aMsg, aActor, aParam->mLoadEventEnd); - WriteIPDLParam(aMsg, aActor, aParam->mDOMLoading); - WriteIPDLParam(aMsg, aActor, aParam->mDOMInteractive); - WriteIPDLParam(aMsg, aActor, aParam->mDOMContentLoadedEventStart); - WriteIPDLParam(aMsg, aActor, aParam->mDOMContentLoadedEventEnd); - WriteIPDLParam(aMsg, aActor, aParam->mDOMComplete); - WriteIPDLParam(aMsg, aActor, aParam->mTTFI); - WriteIPDLParam(aMsg, aActor, + WriteIPDLParam(aWriter, aActor, unloadedURI ? Some(unloadedURI) : Nothing()); + WriteIPDLParam(aWriter, aActor, loadedURI ? Some(loadedURI) : Nothing()); + WriteIPDLParam(aWriter, aActor, uint32_t(aParam->mNavigationType)); + WriteIPDLParam(aWriter, aActor, aParam->mNavigationStartHighRes); + WriteIPDLParam(aWriter, aActor, aParam->mNavigationStart); + WriteIPDLParam(aWriter, aActor, aParam->mNonBlankPaint); + WriteIPDLParam(aWriter, aActor, aParam->mContentfulComposite); + WriteIPDLParam(aWriter, aActor, aParam->mDOMContentFlushed); + WriteIPDLParam(aWriter, aActor, aParam->mBeforeUnloadStart); + WriteIPDLParam(aWriter, aActor, aParam->mUnloadStart); + WriteIPDLParam(aWriter, aActor, aParam->mUnloadEnd); + WriteIPDLParam(aWriter, aActor, aParam->mLoadEventStart); + WriteIPDLParam(aWriter, aActor, aParam->mLoadEventEnd); + WriteIPDLParam(aWriter, aActor, aParam->mDOMLoading); + WriteIPDLParam(aWriter, aActor, aParam->mDOMInteractive); + WriteIPDLParam(aWriter, aActor, aParam->mDOMContentLoadedEventStart); + WriteIPDLParam(aWriter, aActor, aParam->mDOMContentLoadedEventEnd); + WriteIPDLParam(aWriter, aActor, aParam->mDOMComplete); + WriteIPDLParam(aWriter, aActor, aParam->mTTFI); + WriteIPDLParam(aWriter, aActor, aParam->mDocShellHasBeenActiveSinceNavigationStart); } /* static */ bool mozilla::ipc::IPDLParamTraits::Read( - const IPC::Message* aMsg, PickleIterator* aIter, IProtocol* aActor, + IPC::MessageReader* aReader, IProtocol* aActor, RefPtr* aResult) { auto timing = MakeRefPtr(nullptr); uint32_t type; Maybe> unloadedURI; Maybe> loadedURI; - if (!ReadIPDLParam(aMsg, aIter, aActor, &unloadedURI) || - !ReadIPDLParam(aMsg, aIter, aActor, &loadedURI) || - !ReadIPDLParam(aMsg, aIter, aActor, &type) || - !ReadIPDLParam(aMsg, aIter, aActor, &timing->mNavigationStartHighRes) || - !ReadIPDLParam(aMsg, aIter, aActor, &timing->mNavigationStart) || - !ReadIPDLParam(aMsg, aIter, aActor, &timing->mNonBlankPaint) || - !ReadIPDLParam(aMsg, aIter, aActor, &timing->mContentfulComposite) || - !ReadIPDLParam(aMsg, aIter, aActor, &timing->mDOMContentFlushed) || - !ReadIPDLParam(aMsg, aIter, aActor, &timing->mBeforeUnloadStart) || - !ReadIPDLParam(aMsg, aIter, aActor, &timing->mUnloadStart) || - !ReadIPDLParam(aMsg, aIter, aActor, &timing->mUnloadEnd) || - !ReadIPDLParam(aMsg, aIter, aActor, &timing->mLoadEventStart) || - !ReadIPDLParam(aMsg, aIter, aActor, &timing->mLoadEventEnd) || - !ReadIPDLParam(aMsg, aIter, aActor, &timing->mDOMLoading) || - !ReadIPDLParam(aMsg, aIter, aActor, &timing->mDOMInteractive) || - !ReadIPDLParam(aMsg, aIter, aActor, - &timing->mDOMContentLoadedEventStart) || - !ReadIPDLParam(aMsg, aIter, aActor, &timing->mDOMContentLoadedEventEnd) || - !ReadIPDLParam(aMsg, aIter, aActor, &timing->mDOMComplete) || - !ReadIPDLParam(aMsg, aIter, aActor, &timing->mTTFI) || - !ReadIPDLParam(aMsg, aIter, aActor, + if (!ReadIPDLParam(aReader, aActor, &unloadedURI) || + !ReadIPDLParam(aReader, aActor, &loadedURI) || + !ReadIPDLParam(aReader, aActor, &type) || + !ReadIPDLParam(aReader, aActor, &timing->mNavigationStartHighRes) || + !ReadIPDLParam(aReader, aActor, &timing->mNavigationStart) || + !ReadIPDLParam(aReader, aActor, &timing->mNonBlankPaint) || + !ReadIPDLParam(aReader, aActor, &timing->mContentfulComposite) || + !ReadIPDLParam(aReader, aActor, &timing->mDOMContentFlushed) || + !ReadIPDLParam(aReader, aActor, &timing->mBeforeUnloadStart) || + !ReadIPDLParam(aReader, aActor, &timing->mUnloadStart) || + !ReadIPDLParam(aReader, aActor, &timing->mUnloadEnd) || + !ReadIPDLParam(aReader, aActor, &timing->mLoadEventStart) || + !ReadIPDLParam(aReader, aActor, &timing->mLoadEventEnd) || + !ReadIPDLParam(aReader, aActor, &timing->mDOMLoading) || + !ReadIPDLParam(aReader, aActor, &timing->mDOMInteractive) || + !ReadIPDLParam(aReader, aActor, &timing->mDOMContentLoadedEventStart) || + !ReadIPDLParam(aReader, aActor, &timing->mDOMContentLoadedEventEnd) || + !ReadIPDLParam(aReader, aActor, &timing->mDOMComplete) || + !ReadIPDLParam(aReader, aActor, &timing->mTTFI) || + !ReadIPDLParam(aReader, aActor, &timing->mDocShellHasBeenActiveSinceNavigationStart)) { return false; } diff --git a/dom/base/nsDOMNavigationTiming.h b/dom/base/nsDOMNavigationTiming.h index 16ba135dadbb..993de201b9c7 100644 --- a/dom/base/nsDOMNavigationTiming.h +++ b/dom/base/nsDOMNavigationTiming.h @@ -261,10 +261,10 @@ namespace mozilla { namespace ipc { template <> struct IPDLParamTraits { - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, nsDOMNavigationTiming* aParam); - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, RefPtr* aResult); + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + RefPtr* aResult); }; } // namespace ipc diff --git a/dom/bindings/BindingUtils.cpp b/dom/bindings/BindingUtils.cpp index 2338ecc0a1c6..1724eaaf81ed 100644 --- a/dom/bindings/BindingUtils.cpp +++ b/dom/bindings/BindingUtils.cpp @@ -251,23 +251,24 @@ nsTArray& TErrorResult::CreateErrorMessageHelper( } template -void TErrorResult::SerializeMessage(IPC::Message* aMsg) const { +void TErrorResult::SerializeMessage( + IPC::MessageWriter* aWriter) const { using namespace IPC; AssertInOwningThread(); MOZ_ASSERT(mUnionState == HasMessage); MOZ_ASSERT(mExtra.mMessage); - WriteParam(aMsg, mExtra.mMessage->mArgs); - WriteParam(aMsg, mExtra.mMessage->mErrorNumber); + WriteParam(aWriter, mExtra.mMessage->mArgs); + WriteParam(aWriter, mExtra.mMessage->mErrorNumber); } template -bool TErrorResult::DeserializeMessage(const IPC::Message* aMsg, - PickleIterator* aIter) { +bool TErrorResult::DeserializeMessage( + IPC::MessageReader* aReader) { using namespace IPC; AssertInOwningThread(); auto readMessage = MakeUnique(); - if (!ReadParam(aMsg, aIter, &readMessage->mArgs) || - !ReadParam(aMsg, aIter, &readMessage->mErrorNumber)) { + if (!ReadParam(aReader, &readMessage->mArgs) || + !ReadParam(aReader, &readMessage->mErrorNumber)) { return false; } if (!readMessage->HasCorrectNumberOfArguments()) { @@ -392,23 +393,23 @@ struct TErrorResult::DOMExceptionInfo { template void TErrorResult::SerializeDOMExceptionInfo( - IPC::Message* aMsg) const { + IPC::MessageWriter* aWriter) const { using namespace IPC; AssertInOwningThread(); MOZ_ASSERT(mUnionState == HasDOMExceptionInfo); MOZ_ASSERT(mExtra.mDOMExceptionInfo); - WriteParam(aMsg, mExtra.mDOMExceptionInfo->mMessage); - WriteParam(aMsg, mExtra.mDOMExceptionInfo->mRv); + WriteParam(aWriter, mExtra.mDOMExceptionInfo->mMessage); + WriteParam(aWriter, mExtra.mDOMExceptionInfo->mRv); } template bool TErrorResult::DeserializeDOMExceptionInfo( - const IPC::Message* aMsg, PickleIterator* aIter) { + IPC::MessageReader* aReader) { using namespace IPC; AssertInOwningThread(); nsCString message; nsresult rv; - if (!ReadParam(aMsg, aIter, &message) || !ReadParam(aMsg, aIter, &rv)) { + if (!ReadParam(aReader, &message) || !ReadParam(aReader, &rv)) { return false; } diff --git a/dom/bindings/ErrorIPCUtils.h b/dom/bindings/ErrorIPCUtils.h index e492618ececd..064d85150337 100644 --- a/dom/bindings/ErrorIPCUtils.h +++ b/dom/bindings/ErrorIPCUtils.h @@ -26,7 +26,7 @@ template <> struct ParamTraits { typedef mozilla::ErrorResult paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { // It should be the case that mMightHaveUnreportedJSException can only be // true when we're expecting a JS exception. We cannot send such messages // over the IPC channel since there is no sane way of transferring the JS @@ -42,43 +42,42 @@ struct ParamTraits { "Cannot encode an ErrorResult representing a Javascript exception"); } - WriteParam(aMsg, aParam.mResult); - WriteParam(aMsg, aParam.IsErrorWithMessage()); - WriteParam(aMsg, aParam.IsDOMException()); + WriteParam(aWriter, aParam.mResult); + WriteParam(aWriter, aParam.IsErrorWithMessage()); + WriteParam(aWriter, aParam.IsDOMException()); if (aParam.IsErrorWithMessage()) { - aParam.SerializeMessage(aMsg); + aParam.SerializeMessage(aWriter); } else if (aParam.IsDOMException()) { - aParam.SerializeDOMExceptionInfo(aMsg); + aParam.SerializeDOMExceptionInfo(aWriter); } } - static void Write(Message* aMsg, paramType&& aParam) { - Write(aMsg, static_cast(aParam)); + static void Write(MessageWriter* aWriter, paramType&& aParam) { + Write(aWriter, static_cast(aParam)); aParam.SuppressException(); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { paramType readValue; - if (!ReadParam(aMsg, aIter, &readValue.mResult)) { + if (!ReadParam(aReader, &readValue.mResult)) { return false; } bool hasMessage = false; - if (!ReadParam(aMsg, aIter, &hasMessage)) { + if (!ReadParam(aReader, &hasMessage)) { return false; } bool hasDOMExceptionInfo = false; - if (!ReadParam(aMsg, aIter, &hasDOMExceptionInfo)) { + if (!ReadParam(aReader, &hasDOMExceptionInfo)) { return false; } if (hasMessage && hasDOMExceptionInfo) { // Shouldn't have both! return false; } - if (hasMessage && !readValue.DeserializeMessage(aMsg, aIter)) { + if (hasMessage && !readValue.DeserializeMessage(aReader)) { return false; } else if (hasDOMExceptionInfo && - !readValue.DeserializeDOMExceptionInfo(aMsg, aIter)) { + !readValue.DeserializeDOMExceptionInfo(aReader)) { return false; } *aResult = std::move(readValue); @@ -90,16 +89,15 @@ template <> struct ParamTraits { typedef mozilla::CopyableErrorResult paramType; - static void Write(Message* aMsg, const paramType& aParam) { - ParamTraits::Write(aMsg, aParam); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + ParamTraits::Write(aWriter, aParam); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { // We can't cast *aResult to ErrorResult&, so cheat and just cast // to ErrorResult*. return ParamTraits::Read( - aMsg, aIter, reinterpret_cast(aResult)); + aReader, reinterpret_cast(aResult)); } }; diff --git a/dom/bindings/ErrorResult.h b/dom/bindings/ErrorResult.h index 697be76a38cc..8b2f7e6164c7 100644 --- a/dom/bindings/ErrorResult.h +++ b/dom/bindings/ErrorResult.h @@ -476,12 +476,11 @@ class TErrorResult { friend struct IPC::ParamTraits; friend struct IPC::ParamTraits; - void SerializeMessage(IPC::Message* aMsg) const; - bool DeserializeMessage(const IPC::Message* aMsg, PickleIterator* aIter); + void SerializeMessage(IPC::MessageWriter* aWriter) const; + bool DeserializeMessage(IPC::MessageReader* aReader); - void SerializeDOMExceptionInfo(IPC::Message* aMsg) const; - bool DeserializeDOMExceptionInfo(const IPC::Message* aMsg, - PickleIterator* aIter); + void SerializeDOMExceptionInfo(IPC::MessageWriter* aWriter) const; + bool DeserializeDOMExceptionInfo(IPC::MessageReader* aReader); // Helper method that creates a new Message for this TErrorResult, // and returns the arguments array from that Message. diff --git a/dom/canvas/WebGLIpdl.h b/dom/canvas/WebGLIpdl.h index 57756f476d95..5fc048bfbfca 100644 --- a/dom/canvas/WebGLIpdl.h +++ b/dom/canvas/WebGLIpdl.h @@ -115,15 +115,15 @@ template <> struct IPDLParamTraits final { using T = mozilla::webgl::FrontBufferSnapshotIpc; - static void Write(IPC::Message* const msg, IProtocol* actor, T& in) { - WriteParam(msg, in.surfSize); - WriteIPDLParam(msg, actor, std::move(in.shmem)); + static void Write(IPC::MessageWriter* const writer, IProtocol* actor, T& in) { + WriteParam(writer, in.surfSize); + WriteIPDLParam(writer, actor, std::move(in.shmem)); } - static bool Read(const IPC::Message* const msg, PickleIterator* const itr, - IProtocol* actor, T* const out) { - return ReadParam(msg, itr, &out->surfSize) && - ReadIPDLParam(msg, itr, actor, &out->shmem); + static bool Read(IPC::MessageReader* const reader, IProtocol* actor, + T* const out) { + return ReadParam(reader, &out->surfSize) && + ReadIPDLParam(reader, actor, &out->shmem); } }; @@ -133,17 +133,17 @@ template <> struct IPDLParamTraits final { using T = mozilla::webgl::ReadPixelsResultIpc; - static void Write(IPC::Message* const msg, IProtocol* actor, T& in) { - WriteParam(msg, in.subrect); - WriteParam(msg, in.byteStride); - WriteIPDLParam(msg, actor, std::move(in.shmem)); + static void Write(IPC::MessageWriter* const writer, IProtocol* actor, T& in) { + WriteParam(writer, in.subrect); + WriteParam(writer, in.byteStride); + WriteIPDLParam(writer, actor, std::move(in.shmem)); } - static bool Read(const IPC::Message* const msg, PickleIterator* const itr, - IProtocol* actor, T* const out) { - return ReadParam(msg, itr, &out->subrect) && - ReadParam(msg, itr, &out->byteStride) && - ReadIPDLParam(msg, itr, actor, &out->shmem); + static bool Read(IPC::MessageReader* const reader, IProtocol* actor, + T* const out) { + return ReadParam(reader, &out->subrect) && + ReadParam(reader, &out->byteStride) && + ReadIPDLParam(reader, actor, &out->shmem); } }; @@ -153,29 +153,30 @@ template <> struct IPDLParamTraits final { using T = mozilla::webgl::TexUnpackBlobDesc; - static void Write(IPC::Message* const msg, IProtocol* actor, T&& in) { - WriteParam(msg, in.imageTarget); - WriteParam(msg, in.size); - WriteParam(msg, in.srcAlphaType); + static void Write(IPC::MessageWriter* const writer, IProtocol* actor, + T&& in) { + WriteParam(writer, in.imageTarget); + WriteParam(writer, in.size); + WriteParam(writer, in.srcAlphaType); MOZ_RELEASE_ASSERT(!in.cpuData); MOZ_RELEASE_ASSERT(!in.pboOffset); - WriteParam(msg, in.structuredSrcSize); + WriteParam(writer, in.structuredSrcSize); MOZ_RELEASE_ASSERT(!in.image); - WriteIPDLParam(msg, actor, std::move(in.sd)); + WriteIPDLParam(writer, actor, std::move(in.sd)); MOZ_RELEASE_ASSERT(!in.dataSurf); - WriteParam(msg, in.unpacking); - WriteParam(msg, in.applyUnpackTransforms); + WriteParam(writer, in.unpacking); + WriteParam(writer, in.applyUnpackTransforms); } - static bool Read(const IPC::Message* const msg, PickleIterator* const itr, - IProtocol* actor, T* const out) { - return ReadParam(msg, itr, &out->imageTarget) && - ReadParam(msg, itr, &out->size) && - ReadParam(msg, itr, &out->srcAlphaType) && - ReadParam(msg, itr, &out->structuredSrcSize) && - ReadIPDLParam(msg, itr, actor, &out->sd) && - ReadParam(msg, itr, &out->unpacking) && - ReadParam(msg, itr, &out->applyUnpackTransforms); + static bool Read(IPC::MessageReader* const reader, IProtocol* actor, + T* const out) { + return ReadParam(reader, &out->imageTarget) && + ReadParam(reader, &out->size) && + ReadParam(reader, &out->srcAlphaType) && + ReadParam(reader, &out->structuredSrcSize) && + ReadIPDLParam(reader, actor, &out->sd) && + ReadParam(reader, &out->unpacking) && + ReadParam(reader, &out->applyUnpackTransforms); } }; @@ -216,14 +217,13 @@ bool ValidateParam(const T& val) { template struct ValidatedPlainOldDataSerializer : public PlainOldDataSerializer { - static void Write(Message* const msg, const T& in) { + static void Write(MessageWriter* const writer, const T& in) { MOZ_ASSERT(ValidateParam(in)); - PlainOldDataSerializer::Write(msg, in); + PlainOldDataSerializer::Write(writer, in); } - static bool Read(const Message* const msg, PickleIterator* const itr, - T* const out) { - if (!PlainOldDataSerializer::Read(msg, itr, out)) return false; + static bool Read(MessageReader* const reader, T* const out) { + if (!PlainOldDataSerializer::Read(reader, out)) return false; return ValidateParam(*out); } @@ -276,19 +276,17 @@ template <> struct ParamTraits final { using T = mozilla::webgl::InitContextResult; - static void Write(Message* const msg, const T& in) { - WriteParam(msg, in.error); - WriteParam(msg, in.options); - WriteParam(msg, in.limits); - WriteParam(msg, in.uploadableSdTypes); + static void Write(MessageWriter* const writer, const T& in) { + WriteParam(writer, in.error); + WriteParam(writer, in.options); + WriteParam(writer, in.limits); + WriteParam(writer, in.uploadableSdTypes); } - static bool Read(const Message* const msg, PickleIterator* const itr, - T* const out) { - return ReadParam(msg, itr, &out->error) && - ReadParam(msg, itr, &out->options) && - ReadParam(msg, itr, &out->limits) && - ReadParam(msg, itr, &out->uploadableSdTypes); + static bool Read(MessageReader* const reader, T* const out) { + return ReadParam(reader, &out->error) && ReadParam(reader, &out->options) && + ReadParam(reader, &out->limits) && + ReadParam(reader, &out->uploadableSdTypes); } }; @@ -313,18 +311,17 @@ template <> struct ParamTraits final { using T = mozilla::webgl::ReadPixelsDesc; - static void Write(Message* const msg, const T& in) { - WriteParam(msg, in.srcOffset); - WriteParam(msg, in.size); - WriteParam(msg, in.pi); - WriteParam(msg, in.packState); + static void Write(MessageWriter* const writer, const T& in) { + WriteParam(writer, in.srcOffset); + WriteParam(writer, in.size); + WriteParam(writer, in.pi); + WriteParam(writer, in.packState); } - static bool Read(const Message* const msg, PickleIterator* const itr, - T* const out) { - return ReadParam(msg, itr, &out->srcOffset) && - ReadParam(msg, itr, &out->size) && ReadParam(msg, itr, &out->pi) && - ReadParam(msg, itr, &out->packState); + static bool Read(MessageReader* const reader, T* const out) { + return ReadParam(reader, &out->srcOffset) && + ReadParam(reader, &out->size) && ReadParam(reader, &out->pi) && + ReadParam(reader, &out->packState); } }; @@ -334,14 +331,13 @@ template <> struct ParamTraits final { using T = mozilla::webgl::PackingInfo; - static void Write(Message* const msg, const T& in) { - WriteParam(msg, in.format); - WriteParam(msg, in.type); + static void Write(MessageWriter* const writer, const T& in) { + WriteParam(writer, in.format); + WriteParam(writer, in.type); } - static bool Read(const Message* const msg, PickleIterator* const itr, - T* const out) { - return ReadParam(msg, itr, &out->format) && ReadParam(msg, itr, &out->type); + static bool Read(MessageReader* const reader, T* const out) { + return ReadParam(reader, &out->format) && ReadParam(reader, &out->type); } }; @@ -351,19 +347,17 @@ template <> struct ParamTraits final { using T = mozilla::webgl::CompileResult; - static void Write(Message* const msg, const T& in) { - WriteParam(msg, in.pending); - WriteParam(msg, in.log); - WriteParam(msg, in.translatedSource); - WriteParam(msg, in.success); + static void Write(MessageWriter* const writer, const T& in) { + WriteParam(writer, in.pending); + WriteParam(writer, in.log); + WriteParam(writer, in.translatedSource); + WriteParam(writer, in.success); } - static bool Read(const Message* const msg, PickleIterator* const itr, - T* const out) { - return ReadParam(msg, itr, &out->pending) && - ReadParam(msg, itr, &out->log) && - ReadParam(msg, itr, &out->translatedSource) && - ReadParam(msg, itr, &out->success); + static bool Read(MessageReader* const reader, T* const out) { + return ReadParam(reader, &out->pending) && ReadParam(reader, &out->log) && + ReadParam(reader, &out->translatedSource) && + ReadParam(reader, &out->success); } }; @@ -373,21 +367,19 @@ template <> struct ParamTraits final { using T = mozilla::webgl::LinkResult; - static void Write(Message* const msg, const T& in) { - WriteParam(msg, in.pending); - WriteParam(msg, in.log); - WriteParam(msg, in.success); - WriteParam(msg, in.active); - WriteParam(msg, in.tfBufferMode); + static void Write(MessageWriter* const writer, const T& in) { + WriteParam(writer, in.pending); + WriteParam(writer, in.log); + WriteParam(writer, in.success); + WriteParam(writer, in.active); + WriteParam(writer, in.tfBufferMode); } - static bool Read(const Message* const msg, PickleIterator* const itr, - T* const out) { - return ReadParam(msg, itr, &out->pending) && - ReadParam(msg, itr, &out->log) && - ReadParam(msg, itr, &out->success) && - ReadParam(msg, itr, &out->active) && - ReadParam(msg, itr, &out->tfBufferMode); + static bool Read(MessageReader* const reader, T* const out) { + return ReadParam(reader, &out->pending) && ReadParam(reader, &out->log) && + ReadParam(reader, &out->success) && + ReadParam(reader, &out->active) && + ReadParam(reader, &out->tfBufferMode); } }; @@ -397,19 +389,18 @@ template <> struct ParamTraits final { using T = mozilla::webgl::LinkActiveInfo; - static void Write(Message* const msg, const T& in) { - WriteParam(msg, in.activeAttribs); - WriteParam(msg, in.activeUniforms); - WriteParam(msg, in.activeUniformBlocks); - WriteParam(msg, in.activeTfVaryings); + static void Write(MessageWriter* const writer, const T& in) { + WriteParam(writer, in.activeAttribs); + WriteParam(writer, in.activeUniforms); + WriteParam(writer, in.activeUniformBlocks); + WriteParam(writer, in.activeTfVaryings); } - static bool Read(const Message* const msg, PickleIterator* const itr, - T* const out) { - return ReadParam(msg, itr, &out->activeAttribs) && - ReadParam(msg, itr, &out->activeUniforms) && - ReadParam(msg, itr, &out->activeUniformBlocks) && - ReadParam(msg, itr, &out->activeTfVaryings); + static bool Read(MessageReader* const reader, T* const out) { + return ReadParam(reader, &out->activeAttribs) && + ReadParam(reader, &out->activeUniforms) && + ReadParam(reader, &out->activeUniformBlocks) && + ReadParam(reader, &out->activeTfVaryings); } }; @@ -419,17 +410,15 @@ template <> struct ParamTraits final { using T = mozilla::webgl::ActiveInfo; - static void Write(Message* const msg, const T& in) { - WriteParam(msg, in.elemType); - WriteParam(msg, in.elemCount); - WriteParam(msg, in.name); + static void Write(MessageWriter* const writer, const T& in) { + WriteParam(writer, in.elemType); + WriteParam(writer, in.elemCount); + WriteParam(writer, in.name); } - static bool Read(const Message* const msg, PickleIterator* const itr, - T* const out) { - return ReadParam(msg, itr, &out->elemType) && - ReadParam(msg, itr, &out->elemCount) && - ReadParam(msg, itr, &out->name); + static bool Read(MessageReader* const reader, T* const out) { + return ReadParam(reader, &out->elemType) && + ReadParam(reader, &out->elemCount) && ReadParam(reader, &out->name); } }; @@ -439,17 +428,16 @@ template <> struct ParamTraits final { using T = mozilla::webgl::ActiveAttribInfo; - static void Write(Message* const msg, const T& in) { - WriteParam(msg, static_cast(in)); - WriteParam(msg, in.location); - WriteParam(msg, in.baseType); + static void Write(MessageWriter* const writer, const T& in) { + WriteParam(writer, static_cast(in)); + WriteParam(writer, in.location); + WriteParam(writer, in.baseType); } - static bool Read(const Message* const msg, PickleIterator* const itr, - T* const out) { - return ReadParam(msg, itr, static_cast(out)) && - ReadParam(msg, itr, &out->location) && - ReadParam(msg, itr, &out->baseType); + static bool Read(MessageReader* const reader, T* const out) { + return ReadParam(reader, static_cast(out)) && + ReadParam(reader, &out->location) && + ReadParam(reader, &out->baseType); } }; @@ -459,25 +447,24 @@ template <> struct ParamTraits final { using T = mozilla::webgl::ActiveUniformInfo; - static void Write(Message* const msg, const T& in) { - WriteParam(msg, static_cast(in)); - WriteParam(msg, in.locByIndex); - WriteParam(msg, in.block_index); - WriteParam(msg, in.block_offset); - WriteParam(msg, in.block_arrayStride); - WriteParam(msg, in.block_matrixStride); - WriteParam(msg, in.block_isRowMajor); + static void Write(MessageWriter* const writer, const T& in) { + WriteParam(writer, static_cast(in)); + WriteParam(writer, in.locByIndex); + WriteParam(writer, in.block_index); + WriteParam(writer, in.block_offset); + WriteParam(writer, in.block_arrayStride); + WriteParam(writer, in.block_matrixStride); + WriteParam(writer, in.block_isRowMajor); } - static bool Read(const Message* const msg, PickleIterator* const itr, - T* const out) { - return ReadParam(msg, itr, static_cast(out)) && - ReadParam(msg, itr, &out->locByIndex) && - ReadParam(msg, itr, &out->block_index) && - ReadParam(msg, itr, &out->block_offset) && - ReadParam(msg, itr, &out->block_arrayStride) && - ReadParam(msg, itr, &out->block_matrixStride) && - ReadParam(msg, itr, &out->block_isRowMajor); + static bool Read(MessageReader* const reader, T* const out) { + return ReadParam(reader, static_cast(out)) && + ReadParam(reader, &out->locByIndex) && + ReadParam(reader, &out->block_index) && + ReadParam(reader, &out->block_offset) && + ReadParam(reader, &out->block_arrayStride) && + ReadParam(reader, &out->block_matrixStride) && + ReadParam(reader, &out->block_isRowMajor); } }; @@ -487,21 +474,19 @@ template <> struct ParamTraits final { using T = mozilla::webgl::ActiveUniformBlockInfo; - static void Write(Message* const msg, const T& in) { - WriteParam(msg, in.name); - WriteParam(msg, in.dataSize); - WriteParam(msg, in.activeUniformIndices); - WriteParam(msg, in.referencedByVertexShader); - WriteParam(msg, in.referencedByFragmentShader); + static void Write(MessageWriter* const writer, const T& in) { + WriteParam(writer, in.name); + WriteParam(writer, in.dataSize); + WriteParam(writer, in.activeUniformIndices); + WriteParam(writer, in.referencedByVertexShader); + WriteParam(writer, in.referencedByFragmentShader); } - static bool Read(const Message* const msg, PickleIterator* const itr, - T* const out) { - return ReadParam(msg, itr, &out->name) && - ReadParam(msg, itr, &out->dataSize) && - ReadParam(msg, itr, &out->activeUniformIndices) && - ReadParam(msg, itr, &out->referencedByVertexShader) && - ReadParam(msg, itr, &out->referencedByFragmentShader); + static bool Read(MessageReader* const reader, T* const out) { + return ReadParam(reader, &out->name) && ReadParam(reader, &out->dataSize) && + ReadParam(reader, &out->activeUniformIndices) && + ReadParam(reader, &out->referencedByVertexShader) && + ReadParam(reader, &out->referencedByFragmentShader); } }; @@ -511,17 +496,16 @@ template <> struct ParamTraits final { using T = mozilla::webgl::ShaderPrecisionFormat; - static void Write(Message* const msg, const T& in) { - WriteParam(msg, in.rangeMin); - WriteParam(msg, in.rangeMax); - WriteParam(msg, in.precision); + static void Write(MessageWriter* const writer, const T& in) { + WriteParam(writer, in.rangeMin); + WriteParam(writer, in.rangeMax); + WriteParam(writer, in.precision); } - static bool Read(const Message* const msg, PickleIterator* const itr, - T* const out) { - return ReadParam(msg, itr, &out->rangeMin) && - ReadParam(msg, itr, &out->rangeMax) && - ReadParam(msg, itr, &out->precision); + static bool Read(MessageReader* const reader, T* const out) { + return ReadParam(reader, &out->rangeMin) && + ReadParam(reader, &out->rangeMax) && + ReadParam(reader, &out->precision); } }; @@ -534,16 +518,15 @@ struct ParamTraits final { static_assert(std::is_trivial::value); - static void Write(Message* const msg, const T& in) { - msg->WriteBytes(in, kByteSize); + static void Write(MessageWriter* const writer, const T& in) { + writer->WriteBytes(in, kByteSize); } - static bool Read(const Message* const msg, PickleIterator* const itr, - T* const out) { - if (!msg->HasBytesAvailable(itr, kByteSize)) { + static bool Read(MessageReader* const reader, T* const out) { + if (!reader->HasBytesAvailable(kByteSize)) { return false; } - return msg->ReadBytesInto(itr, *out, kByteSize); + return reader->ReadBytesInto(*out, kByteSize); } }; @@ -553,15 +536,14 @@ template <> struct ParamTraits final { using T = mozilla::webgl::GetUniformData; - static void Write(Message* const msg, const T& in) { - ParamTraits::Write(msg, in.data); - WriteParam(msg, in.type); + static void Write(MessageWriter* const writer, const T& in) { + ParamTraits::Write(writer, in.data); + WriteParam(writer, in.type); } - static bool Read(const Message* const msg, PickleIterator* const itr, - T* const out) { - return ParamTraitsdata)>::Read(msg, itr, &out->data) && - ReadParam(msg, itr, &out->type); + static bool Read(MessageReader* const reader, T* const out) { + return ParamTraitsdata)>::Read(reader, &out->data) && + ReadParam(reader, &out->type); } }; @@ -571,14 +553,13 @@ template struct ParamTraits> final { using T = mozilla::avec2; - static void Write(Message* const msg, const T& in) { - WriteParam(msg, in.x); - WriteParam(msg, in.y); + static void Write(MessageWriter* const writer, const T& in) { + WriteParam(writer, in.x); + WriteParam(writer, in.y); } - static bool Read(const Message* const msg, PickleIterator* const itr, - T* const out) { - return ReadParam(msg, itr, &out->x) && ReadParam(msg, itr, &out->y); + static bool Read(MessageReader* const reader, T* const out) { + return ReadParam(reader, &out->x) && ReadParam(reader, &out->y); } }; @@ -588,16 +569,15 @@ template struct ParamTraits> final { using T = mozilla::avec3; - static void Write(Message* const msg, const T& in) { - WriteParam(msg, in.x); - WriteParam(msg, in.y); - WriteParam(msg, in.z); + static void Write(MessageWriter* const writer, const T& in) { + WriteParam(writer, in.x); + WriteParam(writer, in.y); + WriteParam(writer, in.z); } - static bool Read(const Message* const msg, PickleIterator* const itr, - T* const out) { - return ReadParam(msg, itr, &out->x) && ReadParam(msg, itr, &out->y) && - ReadParam(msg, itr, &out->z); + static bool Read(MessageReader* const reader, T* const out) { + return ReadParam(reader, &out->x) && ReadParam(reader, &out->y) && + ReadParam(reader, &out->z); } }; diff --git a/dom/events/Event.cpp b/dom/events/Event.cpp index c19083c0a79e..7260391d5884 100644 --- a/dom/events/Event.cpp +++ b/dom/events/Event.cpp @@ -780,38 +780,39 @@ double Event::TimeStamp() { workerPrivate->CrossOriginIsolated()); } -void Event::Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) { +void Event::Serialize(IPC::MessageWriter* aWriter, + bool aSerializeInterfaceType) { if (aSerializeInterfaceType) { - IPC::WriteParam(aMsg, u"event"_ns); + IPC::WriteParam(aWriter, u"event"_ns); } nsString type; GetType(type); - IPC::WriteParam(aMsg, type); + IPC::WriteParam(aWriter, type); - IPC::WriteParam(aMsg, Bubbles()); - IPC::WriteParam(aMsg, Cancelable()); - IPC::WriteParam(aMsg, IsTrusted()); - IPC::WriteParam(aMsg, Composed()); + IPC::WriteParam(aWriter, Bubbles()); + IPC::WriteParam(aWriter, Cancelable()); + IPC::WriteParam(aWriter, IsTrusted()); + IPC::WriteParam(aWriter, Composed()); // No timestamp serialization for now! } -bool Event::Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) { +bool Event::Deserialize(IPC::MessageReader* aReader) { nsString type; - NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &type), false); + NS_ENSURE_TRUE(IPC::ReadParam(aReader, &type), false); bool bubbles = false; - NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &bubbles), false); + NS_ENSURE_TRUE(IPC::ReadParam(aReader, &bubbles), false); bool cancelable = false; - NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &cancelable), false); + NS_ENSURE_TRUE(IPC::ReadParam(aReader, &cancelable), false); bool trusted = false; - NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &trusted), false); + NS_ENSURE_TRUE(IPC::ReadParam(aReader, &trusted), false); bool composed = false; - NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &composed), false); + NS_ENSURE_TRUE(IPC::ReadParam(aReader, &composed), false); InitEvent(type, bubbles, cancelable); SetTrusted(trusted); diff --git a/dom/events/Event.h b/dom/events/Event.h index c919464a8894..4d110b1126ba 100644 --- a/dom/events/Event.h +++ b/dom/events/Event.h @@ -144,8 +144,9 @@ class Event : public nsISupports, public nsWrapperCache { const WidgetEvent* WidgetEventPtr() const { return const_cast(this)->WidgetEventPtr(); } - virtual void Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType); - virtual bool Deserialize(const IPC::Message* aMsg, PickleIterator* aIter); + virtual void Serialize(IPC::MessageWriter* aWriter, + bool aSerializeInterfaceType); + virtual bool Deserialize(IPC::MessageReader* aReader); void SetOwner(EventTarget* aOwner); void StopCrossProcessForwarding(); void SetTrusted(bool aTrusted); diff --git a/dom/events/NotifyPaintEvent.cpp b/dom/events/NotifyPaintEvent.cpp index df2a0d8deef5..6bbcd736a426 100644 --- a/dom/events/NotifyPaintEvent.cpp +++ b/dom/events/NotifyPaintEvent.cpp @@ -79,31 +79,30 @@ already_AddRefed NotifyPaintEvent::PaintRequests( return requests.forget(); } -void NotifyPaintEvent::Serialize(IPC::Message* aMsg, +void NotifyPaintEvent::Serialize(IPC::MessageWriter* aWriter, bool aSerializeInterfaceType) { if (aSerializeInterfaceType) { - IPC::WriteParam(aMsg, u"notifypaintevent"_ns); + IPC::WriteParam(aWriter, u"notifypaintevent"_ns); } - Event::Serialize(aMsg, false); + Event::Serialize(aWriter, false); uint32_t length = mInvalidateRequests.Length(); - IPC::WriteParam(aMsg, length); + IPC::WriteParam(aWriter, length); for (uint32_t i = 0; i < length; ++i) { - IPC::WriteParam(aMsg, mInvalidateRequests[i]); + IPC::WriteParam(aWriter, mInvalidateRequests[i]); } } -bool NotifyPaintEvent::Deserialize(const IPC::Message* aMsg, - PickleIterator* aIter) { - NS_ENSURE_TRUE(Event::Deserialize(aMsg, aIter), false); +bool NotifyPaintEvent::Deserialize(IPC::MessageReader* aReader) { + NS_ENSURE_TRUE(Event::Deserialize(aReader), false); uint32_t length = 0; - NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &length), false); + NS_ENSURE_TRUE(IPC::ReadParam(aReader, &length), false); mInvalidateRequests.SetCapacity(length); for (uint32_t i = 0; i < length; ++i) { nsRect req; - NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &req), false); + NS_ENSURE_TRUE(IPC::ReadParam(aReader, &req), false); mInvalidateRequests.AppendElement(req); } diff --git a/dom/events/NotifyPaintEvent.h b/dom/events/NotifyPaintEvent.h index 67077c919247..c373a7e3c133 100644 --- a/dom/events/NotifyPaintEvent.h +++ b/dom/events/NotifyPaintEvent.h @@ -30,8 +30,9 @@ class NotifyPaintEvent : public Event { NS_INLINE_DECL_REFCOUNTING_INHERITED(NotifyPaintEvent, Event) - void Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) override; - bool Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) override; + void Serialize(IPC::MessageWriter* aWriter, + bool aSerializeInterfaceType) override; + bool Deserialize(IPC::MessageReader* aReader) override; virtual JSObject* WrapObjectInternal( JSContext* aCx, JS::Handle aGivenProto) override { diff --git a/dom/events/ScrollAreaEvent.cpp b/dom/events/ScrollAreaEvent.cpp index dcc52c3a9d43..b97700725dee 100644 --- a/dom/events/ScrollAreaEvent.cpp +++ b/dom/events/ScrollAreaEvent.cpp @@ -38,29 +38,28 @@ void ScrollAreaEvent::InitScrollAreaEvent(const nsAString& aEventType, mClientArea->SetRect(aX, aY, aWidth, aHeight); } -void ScrollAreaEvent::Serialize(IPC::Message* aMsg, +void ScrollAreaEvent::Serialize(IPC::MessageWriter* aWriter, bool aSerializeInterfaceType) { if (aSerializeInterfaceType) { - IPC::WriteParam(aMsg, u"scrollareaevent"_ns); + IPC::WriteParam(aWriter, u"scrollareaevent"_ns); } - Event::Serialize(aMsg, false); + Event::Serialize(aWriter, false); - IPC::WriteParam(aMsg, X()); - IPC::WriteParam(aMsg, Y()); - IPC::WriteParam(aMsg, Width()); - IPC::WriteParam(aMsg, Height()); + IPC::WriteParam(aWriter, X()); + IPC::WriteParam(aWriter, Y()); + IPC::WriteParam(aWriter, Width()); + IPC::WriteParam(aWriter, Height()); } -bool ScrollAreaEvent::Deserialize(const IPC::Message* aMsg, - PickleIterator* aIter) { - NS_ENSURE_TRUE(Event::Deserialize(aMsg, aIter), false); +bool ScrollAreaEvent::Deserialize(IPC::MessageReader* aReader) { + NS_ENSURE_TRUE(Event::Deserialize(aReader), false); float x, y, width, height; - NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &x), false); - NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &y), false); - NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &width), false); - NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &height), false); + NS_ENSURE_TRUE(IPC::ReadParam(aReader, &x), false); + NS_ENSURE_TRUE(IPC::ReadParam(aReader, &y), false); + NS_ENSURE_TRUE(IPC::ReadParam(aReader, &width), false); + NS_ENSURE_TRUE(IPC::ReadParam(aReader, &height), false); mClientArea->SetRect(x, y, width, height); return true; diff --git a/dom/events/ScrollAreaEvent.h b/dom/events/ScrollAreaEvent.h index 1d82a58b9cef..3c7baab81956 100644 --- a/dom/events/ScrollAreaEvent.h +++ b/dom/events/ScrollAreaEvent.h @@ -24,8 +24,9 @@ class ScrollAreaEvent : public UIEvent { NS_DECL_ISUPPORTS_INHERITED NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ScrollAreaEvent, UIEvent) - void Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) override; - bool Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) override; + void Serialize(IPC::MessageWriter* aWriter, + bool aSerializeInterfaceType) override; + bool Deserialize(IPC::MessageReader* aReader) override; virtual JSObject* WrapObjectInternal( JSContext* aCx, JS::Handle aGivenProto) override { diff --git a/dom/events/UIEvent.cpp b/dom/events/UIEvent.cpp index 71635d3de502..b4f44dda2846 100644 --- a/dom/events/UIEvent.cpp +++ b/dom/events/UIEvent.cpp @@ -207,19 +207,20 @@ void UIEvent::DuplicatePrivateData() { mEvent->mRefPoint = RoundedToInt(screenPoint * scale); } -void UIEvent::Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) { +void UIEvent::Serialize(IPC::MessageWriter* aWriter, + bool aSerializeInterfaceType) { if (aSerializeInterfaceType) { - IPC::WriteParam(aMsg, u"uievent"_ns); + IPC::WriteParam(aWriter, u"uievent"_ns); } - Event::Serialize(aMsg, false); + Event::Serialize(aWriter, false); - IPC::WriteParam(aMsg, Detail()); + IPC::WriteParam(aWriter, Detail()); } -bool UIEvent::Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) { - NS_ENSURE_TRUE(Event::Deserialize(aMsg, aIter), false); - NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &mDetail), false); +bool UIEvent::Deserialize(IPC::MessageReader* aReader) { + NS_ENSURE_TRUE(Event::Deserialize(aReader), false); + NS_ENSURE_TRUE(IPC::ReadParam(aReader, &mDetail), false); return true; } diff --git a/dom/events/UIEvent.h b/dom/events/UIEvent.h index 89d85e36df59..06d7440be159 100644 --- a/dom/events/UIEvent.h +++ b/dom/events/UIEvent.h @@ -31,8 +31,9 @@ class UIEvent : public Event { NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(UIEvent, Event) void DuplicatePrivateData() override; - void Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) override; - bool Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) override; + void Serialize(IPC::MessageWriter* aWriter, + bool aSerializeInterfaceType) override; + bool Deserialize(IPC::MessageReader* aReader) override; static already_AddRefed Constructor(const GlobalObject& aGlobal, const nsAString& aType, diff --git a/dom/file/ipc/IPCBlobUtils.cpp b/dom/file/ipc/IPCBlobUtils.cpp index e58e0785e15f..97c9dca98357 100644 --- a/dom/file/ipc/IPCBlobUtils.cpp +++ b/dom/file/ipc/IPCBlobUtils.cpp @@ -195,32 +195,33 @@ nsresult SerializeUntyped(BlobImpl* aBlobImpl, IProtocol* aActor, namespace ipc { void IPDLParamTraits::Write( - IPC::Message* aMsg, IProtocol* aActor, mozilla::dom::BlobImpl* aParam) { + IPC::MessageWriter* aWriter, IProtocol* aActor, + mozilla::dom::BlobImpl* aParam) { nsresult rv; mozilla::dom::IPCBlob ipcblob; if (aParam) { rv = mozilla::dom::IPCBlobUtils::SerializeUntyped(aParam, aActor, ipcblob); } if (!aParam || NS_WARN_IF(NS_FAILED(rv))) { - WriteIPDLParam(aMsg, aActor, false); + WriteIPDLParam(aWriter, aActor, false); } else { - WriteIPDLParam(aMsg, aActor, true); - WriteIPDLParam(aMsg, aActor, ipcblob); + WriteIPDLParam(aWriter, aActor, true); + WriteIPDLParam(aWriter, aActor, ipcblob); } } bool IPDLParamTraits::Read( - const IPC::Message* aMsg, PickleIterator* aIter, IProtocol* aActor, + IPC::MessageReader* aReader, IProtocol* aActor, RefPtr* aResult) { *aResult = nullptr; bool notnull = false; - if (!ReadIPDLParam(aMsg, aIter, aActor, ¬null)) { + if (!ReadIPDLParam(aReader, aActor, ¬null)) { return false; } if (notnull) { mozilla::dom::IPCBlob ipcblob; - if (!ReadIPDLParam(aMsg, aIter, aActor, &ipcblob)) { + if (!ReadIPDLParam(aReader, aActor, &ipcblob)) { return false; } *aResult = mozilla::dom::IPCBlobUtils::Deserialize(ipcblob); diff --git a/dom/file/ipc/IPCBlobUtils.h b/dom/file/ipc/IPCBlobUtils.h index 9028542d3d27..a3b558ead55f 100644 --- a/dom/file/ipc/IPCBlobUtils.h +++ b/dom/file/ipc/IPCBlobUtils.h @@ -285,10 +285,10 @@ namespace ipc { // __always make sure to handle null!__ template <> struct IPDLParamTraits { - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, mozilla::dom::BlobImpl* aParam); - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, RefPtr* aResult); + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + RefPtr* aResult); }; } // namespace ipc } // namespace mozilla diff --git a/dom/gamepad/ipc/GamepadMessageUtils.h b/dom/gamepad/ipc/GamepadMessageUtils.h index 0332548a7613..c29293d3a5b0 100644 --- a/dom/gamepad/ipc/GamepadMessageUtils.h +++ b/dom/gamepad/ipc/GamepadMessageUtils.h @@ -47,55 +47,54 @@ template <> struct ParamTraits { typedef mozilla::dom::GamepadPoseState paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.flags); - WriteParam(aMsg, aParam.orientation[0]); - WriteParam(aMsg, aParam.orientation[1]); - WriteParam(aMsg, aParam.orientation[2]); - WriteParam(aMsg, aParam.orientation[3]); - WriteParam(aMsg, aParam.position[0]); - WriteParam(aMsg, aParam.position[1]); - WriteParam(aMsg, aParam.position[2]); - WriteParam(aMsg, aParam.angularVelocity[0]); - WriteParam(aMsg, aParam.angularVelocity[1]); - WriteParam(aMsg, aParam.angularVelocity[2]); - WriteParam(aMsg, aParam.angularAcceleration[0]); - WriteParam(aMsg, aParam.angularAcceleration[1]); - WriteParam(aMsg, aParam.angularAcceleration[2]); - WriteParam(aMsg, aParam.linearVelocity[0]); - WriteParam(aMsg, aParam.linearVelocity[1]); - WriteParam(aMsg, aParam.linearVelocity[2]); - WriteParam(aMsg, aParam.linearAcceleration[0]); - WriteParam(aMsg, aParam.linearAcceleration[1]); - WriteParam(aMsg, aParam.linearAcceleration[2]); - WriteParam(aMsg, aParam.isPositionValid); - WriteParam(aMsg, aParam.isOrientationValid); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.flags); + WriteParam(aWriter, aParam.orientation[0]); + WriteParam(aWriter, aParam.orientation[1]); + WriteParam(aWriter, aParam.orientation[2]); + WriteParam(aWriter, aParam.orientation[3]); + WriteParam(aWriter, aParam.position[0]); + WriteParam(aWriter, aParam.position[1]); + WriteParam(aWriter, aParam.position[2]); + WriteParam(aWriter, aParam.angularVelocity[0]); + WriteParam(aWriter, aParam.angularVelocity[1]); + WriteParam(aWriter, aParam.angularVelocity[2]); + WriteParam(aWriter, aParam.angularAcceleration[0]); + WriteParam(aWriter, aParam.angularAcceleration[1]); + WriteParam(aWriter, aParam.angularAcceleration[2]); + WriteParam(aWriter, aParam.linearVelocity[0]); + WriteParam(aWriter, aParam.linearVelocity[1]); + WriteParam(aWriter, aParam.linearVelocity[2]); + WriteParam(aWriter, aParam.linearAcceleration[0]); + WriteParam(aWriter, aParam.linearAcceleration[1]); + WriteParam(aWriter, aParam.linearAcceleration[2]); + WriteParam(aWriter, aParam.isPositionValid); + WriteParam(aWriter, aParam.isOrientationValid); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &(aResult->flags)) || - !ReadParam(aMsg, aIter, &(aResult->orientation[0])) || - !ReadParam(aMsg, aIter, &(aResult->orientation[1])) || - !ReadParam(aMsg, aIter, &(aResult->orientation[2])) || - !ReadParam(aMsg, aIter, &(aResult->orientation[3])) || - !ReadParam(aMsg, aIter, &(aResult->position[0])) || - !ReadParam(aMsg, aIter, &(aResult->position[1])) || - !ReadParam(aMsg, aIter, &(aResult->position[2])) || - !ReadParam(aMsg, aIter, &(aResult->angularVelocity[0])) || - !ReadParam(aMsg, aIter, &(aResult->angularVelocity[1])) || - !ReadParam(aMsg, aIter, &(aResult->angularVelocity[2])) || - !ReadParam(aMsg, aIter, &(aResult->angularAcceleration[0])) || - !ReadParam(aMsg, aIter, &(aResult->angularAcceleration[1])) || - !ReadParam(aMsg, aIter, &(aResult->angularAcceleration[2])) || - !ReadParam(aMsg, aIter, &(aResult->linearVelocity[0])) || - !ReadParam(aMsg, aIter, &(aResult->linearVelocity[1])) || - !ReadParam(aMsg, aIter, &(aResult->linearVelocity[2])) || - !ReadParam(aMsg, aIter, &(aResult->linearAcceleration[0])) || - !ReadParam(aMsg, aIter, &(aResult->linearAcceleration[1])) || - !ReadParam(aMsg, aIter, &(aResult->linearAcceleration[2])) || - !ReadParam(aMsg, aIter, &(aResult->isPositionValid)) || - !ReadParam(aMsg, aIter, &(aResult->isOrientationValid))) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &(aResult->flags)) || + !ReadParam(aReader, &(aResult->orientation[0])) || + !ReadParam(aReader, &(aResult->orientation[1])) || + !ReadParam(aReader, &(aResult->orientation[2])) || + !ReadParam(aReader, &(aResult->orientation[3])) || + !ReadParam(aReader, &(aResult->position[0])) || + !ReadParam(aReader, &(aResult->position[1])) || + !ReadParam(aReader, &(aResult->position[2])) || + !ReadParam(aReader, &(aResult->angularVelocity[0])) || + !ReadParam(aReader, &(aResult->angularVelocity[1])) || + !ReadParam(aReader, &(aResult->angularVelocity[2])) || + !ReadParam(aReader, &(aResult->angularAcceleration[0])) || + !ReadParam(aReader, &(aResult->angularAcceleration[1])) || + !ReadParam(aReader, &(aResult->angularAcceleration[2])) || + !ReadParam(aReader, &(aResult->linearVelocity[0])) || + !ReadParam(aReader, &(aResult->linearVelocity[1])) || + !ReadParam(aReader, &(aResult->linearVelocity[2])) || + !ReadParam(aReader, &(aResult->linearAcceleration[0])) || + !ReadParam(aReader, &(aResult->linearAcceleration[1])) || + !ReadParam(aReader, &(aResult->linearAcceleration[2])) || + !ReadParam(aReader, &(aResult->isPositionValid)) || + !ReadParam(aReader, &(aResult->isOrientationValid))) { return false; } return true; @@ -106,25 +105,24 @@ template <> struct ParamTraits { typedef mozilla::dom::GamepadTouchState paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.touchId); - WriteParam(aMsg, aParam.surfaceId); - WriteParam(aMsg, aParam.position[0]); - WriteParam(aMsg, aParam.position[1]); - WriteParam(aMsg, aParam.surfaceDimensions[0]); - WriteParam(aMsg, aParam.surfaceDimensions[1]); - WriteParam(aMsg, aParam.isSurfaceDimensionsValid); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.touchId); + WriteParam(aWriter, aParam.surfaceId); + WriteParam(aWriter, aParam.position[0]); + WriteParam(aWriter, aParam.position[1]); + WriteParam(aWriter, aParam.surfaceDimensions[0]); + WriteParam(aWriter, aParam.surfaceDimensions[1]); + WriteParam(aWriter, aParam.isSurfaceDimensionsValid); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &(aResult->touchId)) || - !ReadParam(aMsg, aIter, &(aResult->surfaceId)) || - !ReadParam(aMsg, aIter, &(aResult->position[0])) || - !ReadParam(aMsg, aIter, &(aResult->position[1])) || - !ReadParam(aMsg, aIter, &(aResult->surfaceDimensions[0])) || - !ReadParam(aMsg, aIter, &(aResult->surfaceDimensions[1])) || - !ReadParam(aMsg, aIter, &(aResult->isSurfaceDimensionsValid))) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &(aResult->touchId)) || + !ReadParam(aReader, &(aResult->surfaceId)) || + !ReadParam(aReader, &(aResult->position[0])) || + !ReadParam(aReader, &(aResult->position[1])) || + !ReadParam(aReader, &(aResult->surfaceDimensions[0])) || + !ReadParam(aReader, &(aResult->surfaceDimensions[1])) || + !ReadParam(aReader, &(aResult->isSurfaceDimensionsValid))) { return false; } return true; @@ -141,14 +139,13 @@ struct ParamTraits template <> struct ParamTraits { typedef mozilla::dom::GamepadHandle paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mValue); - WriteParam(aMsg, aParam.mKind); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mValue); + WriteParam(aWriter, aParam.mKind); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aParam) { - return ReadParam(aMsg, aIter, &aParam->mValue) && - ReadParam(aMsg, aIter, &aParam->mKind); + static bool Read(MessageReader* aReader, paramType* aParam) { + return ReadParam(aReader, &aParam->mValue) && + ReadParam(aReader, &aParam->mKind); } }; diff --git a/dom/geolocation/nsGeoPositionIPCSerialiser.h b/dom/geolocation/nsGeoPositionIPCSerialiser.h index 93223d05691e..c1a255ad2bb4 100644 --- a/dom/geolocation/nsGeoPositionIPCSerialiser.h +++ b/dom/geolocation/nsGeoPositionIPCSerialiser.h @@ -16,42 +16,42 @@ namespace IPC { template <> struct ParamTraits { // Function to serialize a geoposition - static void Write(Message* aMsg, nsIDOMGeoPositionCoords* aParam) { + static void Write(MessageWriter* aWriter, nsIDOMGeoPositionCoords* aParam) { bool isNull = !aParam; - WriteParam(aMsg, isNull); + WriteParam(aWriter, isNull); // If it is a null object, then we are done if (isNull) return; double coordData; aParam->GetLatitude(&coordData); - WriteParam(aMsg, coordData); + WriteParam(aWriter, coordData); aParam->GetLongitude(&coordData); - WriteParam(aMsg, coordData); + WriteParam(aWriter, coordData); aParam->GetAltitude(&coordData); - WriteParam(aMsg, coordData); + WriteParam(aWriter, coordData); aParam->GetAccuracy(&coordData); - WriteParam(aMsg, coordData); + WriteParam(aWriter, coordData); aParam->GetAltitudeAccuracy(&coordData); - WriteParam(aMsg, coordData); + WriteParam(aWriter, coordData); aParam->GetHeading(&coordData); - WriteParam(aMsg, coordData); + WriteParam(aWriter, coordData); aParam->GetSpeed(&coordData); - WriteParam(aMsg, coordData); + WriteParam(aWriter, coordData); } // Function to de-serialize a geoposition - static bool Read(const Message* aMsg, PickleIterator* aIter, + static bool Read(MessageReader* aReader, RefPtr* aResult) { // Check if it is the null pointer we have transfered bool isNull; - if (!ReadParam(aMsg, aIter, &isNull)) return false; + if (!ReadParam(aReader, &isNull)) return false; if (isNull) { *aResult = nullptr; @@ -67,12 +67,10 @@ struct ParamTraits { double speed; // It's not important to us where it fails, but rather if it fails - if (!(ReadParam(aMsg, aIter, &latitude) && - ReadParam(aMsg, aIter, &longitude) && - ReadParam(aMsg, aIter, &altitude) && - ReadParam(aMsg, aIter, &accuracy) && - ReadParam(aMsg, aIter, &altitudeAccuracy) && - ReadParam(aMsg, aIter, &heading) && ReadParam(aMsg, aIter, &speed))) + if (!(ReadParam(aReader, &latitude) && ReadParam(aReader, &longitude) && + ReadParam(aReader, &altitude) && ReadParam(aReader, &accuracy) && + ReadParam(aReader, &altitudeAccuracy) && + ReadParam(aReader, &heading) && ReadParam(aReader, &speed))) return false; // We now have all the data @@ -91,27 +89,26 @@ struct ParamTraits { template <> struct ParamTraits { // Function to serialize a geoposition - static void Write(Message* aMsg, nsIDOMGeoPosition* aParam) { + static void Write(MessageWriter* aWriter, nsIDOMGeoPosition* aParam) { bool isNull = !aParam; - WriteParam(aMsg, isNull); + WriteParam(aWriter, isNull); // If it is a null object, then we are done if (isNull) return; EpochTimeStamp timeStamp; aParam->GetTimestamp(&timeStamp); - WriteParam(aMsg, timeStamp); + WriteParam(aWriter, timeStamp); nsCOMPtr coords; aParam->GetCoords(getter_AddRefs(coords)); - WriteParam(aMsg, coords); + WriteParam(aWriter, coords); } // Function to de-serialize a geoposition - static bool Read(const Message* aMsg, PickleIterator* aIter, - RefPtr* aResult) { + static bool Read(MessageReader* aReader, RefPtr* aResult) { // Check if it is the null pointer we have transfered bool isNull; - if (!ReadParam(aMsg, aIter, &isNull)) return false; + if (!ReadParam(aReader, &isNull)) return false; if (isNull) { *aResult = nullptr; @@ -122,8 +119,7 @@ struct ParamTraits { RefPtr coords; // It's not important to us where it fails, but rather if it fails - if (!ReadParam(aMsg, aIter, &timeStamp) || - !ReadParam(aMsg, aIter, &coords)) { + if (!ReadParam(aReader, &timeStamp) || !ReadParam(aReader, &coords)) { return false; } diff --git a/dom/indexedDB/SerializationHelpers.h b/dom/indexedDB/SerializationHelpers.h index b0818b5cabce..241c85d9a662 100644 --- a/dom/indexedDB/SerializationHelpers.h +++ b/dom/indexedDB/SerializationHelpers.h @@ -28,13 +28,12 @@ template <> struct ParamTraits { typedef mozilla::dom::indexedDB::Key paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mBuffer); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mBuffer); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mBuffer); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mBuffer); } static void Log(const paramType& aParam, std::wstring* aLog) { @@ -53,15 +52,14 @@ template <> struct ParamTraits { typedef mozilla::dom::indexedDB::KeyPath paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mType); - WriteParam(aMsg, aParam.mStrings); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mType); + WriteParam(aWriter, aParam.mStrings); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mType) && - ReadParam(aMsg, aIter, &aResult->mStrings); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mType) && + ReadParam(aReader, &aResult->mStrings); } static void Log(const paramType& aParam, std::wstring* aLog) { diff --git a/dom/ipc/CSPMessageUtils.cpp b/dom/ipc/CSPMessageUtils.cpp index 6ded353f0630..7ddc6d6271c5 100644 --- a/dom/ipc/CSPMessageUtils.cpp +++ b/dom/ipc/CSPMessageUtils.cpp @@ -14,23 +14,22 @@ namespace IPC { using namespace mozilla::ipc; void ParamTraits::Write( - Message* aMsg, nsIContentSecurityPolicy* aParam) { + MessageWriter* aWriter, nsIContentSecurityPolicy* aParam) { bool isNull = !aParam; - WriteParam(aMsg, isNull); + WriteParam(aWriter, isNull); if (isNull) { return; } CSPInfo csp; mozilla::Unused << NS_WARN_IF(NS_FAILED(CSPToCSPInfo(aParam, &csp))); - IPDLParamTraits::Write(aMsg, nullptr, csp); + IPDLParamTraits::Write(aWriter, nullptr, csp); } bool ParamTraits::Read( - const Message* aMsg, PickleIterator* aIter, - RefPtr* aResult) { + MessageReader* aReader, RefPtr* aResult) { bool isNull; - if (!ReadParam(aMsg, aIter, &isNull)) { + if (!ReadParam(aReader, &isNull)) { return false; } @@ -40,7 +39,7 @@ bool ParamTraits::Read( } CSPInfo csp; - if (!IPDLParamTraits::Read(aMsg, aIter, nullptr, &csp)) { + if (!IPDLParamTraits::Read(aReader, nullptr, &csp)) { return false; } diff --git a/dom/ipc/CSPMessageUtils.h b/dom/ipc/CSPMessageUtils.h index 3877e66402b8..286a3a97782e 100644 --- a/dom/ipc/CSPMessageUtils.h +++ b/dom/ipc/CSPMessageUtils.h @@ -15,8 +15,8 @@ namespace IPC { template <> struct ParamTraits { - static void Write(Message* aMsg, nsIContentSecurityPolicy* aParam); - static bool Read(const Message* aMsg, PickleIterator* aIter, + static void Write(MessageWriter* aWriter, nsIContentSecurityPolicy* aParam); + static bool Read(MessageReader* aReader, RefPtr* aResult); }; diff --git a/dom/ipc/DocShellMessageUtils.cpp b/dom/ipc/DocShellMessageUtils.cpp index d35d77840a38..3e7735986c23 100644 --- a/dom/ipc/DocShellMessageUtils.cpp +++ b/dom/ipc/DocShellMessageUtils.cpp @@ -11,18 +11,18 @@ namespace mozilla::ipc { -void IPDLParamTraits::Write(IPC::Message* aMsg, +void IPDLParamTraits::Write(IPC::MessageWriter* aWriter, IProtocol* aActor, nsDocShellLoadState* aParam) { MOZ_RELEASE_ASSERT(aParam); - WriteIPDLParam(aMsg, aActor, aParam->Serialize()); + WriteIPDLParam(aWriter, aActor, aParam->Serialize()); } bool IPDLParamTraits::Read( - const IPC::Message* aMsg, PickleIterator* aIter, IProtocol* aActor, + IPC::MessageReader* aReader, IProtocol* aActor, RefPtr* aResult) { dom::DocShellLoadStateInit loadState; - if (!ReadIPDLParam(aMsg, aIter, aActor, &loadState)) { + if (!ReadIPDLParam(aReader, aActor, &loadState)) { return false; } diff --git a/dom/ipc/DocShellMessageUtils.h b/dom/ipc/DocShellMessageUtils.h index b8e1316cd65b..0479ad1b4d45 100644 --- a/dom/ipc/DocShellMessageUtils.h +++ b/dom/ipc/DocShellMessageUtils.h @@ -18,10 +18,10 @@ namespace ipc { template <> struct IPDLParamTraits { - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, nsDocShellLoadState* aParam); - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, RefPtr* aResult); + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + RefPtr* aResult); }; } // namespace ipc diff --git a/dom/ipc/IdType.h b/dom/ipc/IdType.h index acc2b6d8109f..b568b85b5ff2 100644 --- a/dom/ipc/IdType.h +++ b/dom/ipc/IdType.h @@ -52,13 +52,12 @@ template struct ParamTraits> { using paramType = mozilla::dom::IdType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mId); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mId); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mId); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mId); } }; diff --git a/dom/ipc/PermissionMessageUtils.cpp b/dom/ipc/PermissionMessageUtils.cpp index 2e26aaa78a4c..4d3e8a349b00 100644 --- a/dom/ipc/PermissionMessageUtils.cpp +++ b/dom/ipc/PermissionMessageUtils.cpp @@ -12,7 +12,7 @@ namespace mozilla::ipc { -void IPDLParamTraits::Write(IPC::Message* aMsg, +void IPDLParamTraits::Write(IPC::MessageWriter* aWriter, IProtocol* aActor, nsIPrincipal* aParam) { MOZ_DIAGNOSTIC_ASSERT(NS_IsMainThread()); @@ -24,15 +24,14 @@ void IPDLParamTraits::Write(IPC::Message* aMsg, MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv)); } - WriteIPDLParam(aMsg, aActor, info); + WriteIPDLParam(aWriter, aActor, info); } -bool IPDLParamTraits::Read(const IPC::Message* aMsg, - PickleIterator* aIter, +bool IPDLParamTraits::Read(IPC::MessageReader* aReader, IProtocol* aActor, RefPtr* aResult) { Maybe info; - if (!ReadIPDLParam(aMsg, aIter, aActor, &info)) { + if (!ReadIPDLParam(aReader, aActor, &info)) { return false; } diff --git a/dom/ipc/PermissionMessageUtils.h b/dom/ipc/PermissionMessageUtils.h index e73ce7922e0b..1b636263f4a8 100644 --- a/dom/ipc/PermissionMessageUtils.h +++ b/dom/ipc/PermissionMessageUtils.h @@ -40,16 +40,16 @@ namespace ipc { template <> struct IPDLParamTraits { - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, nsIPrincipal* aParam); - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, RefPtr* aResult); + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + RefPtr* aResult); // Overload to support deserializing nsCOMPtr directly. - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, nsCOMPtr* aResult) { + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + nsCOMPtr* aResult) { RefPtr result; - if (!Read(aMsg, aIter, aActor, &result)) { + if (!Read(aReader, aActor, &result)) { return false; } *aResult = std::move(result); @@ -60,13 +60,13 @@ struct IPDLParamTraits { template <> struct IPDLParamTraits { typedef IPC::Principal paramType; - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, const paramType& aParam) { - WriteIPDLParam(aMsg, aActor, aParam.mPrincipal); + WriteIPDLParam(aWriter, aActor, aParam.mPrincipal); } - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, paramType* aResult) { - return ReadIPDLParam(aMsg, aIter, aActor, &aResult->mPrincipal); + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + paramType* aResult) { + return ReadIPDLParam(aReader, aActor, &aResult->mPrincipal); } }; diff --git a/dom/ipc/PropertyBagUtils.cpp b/dom/ipc/PropertyBagUtils.cpp index a43aa7168fcf..6c1b3e8feaef 100644 --- a/dom/ipc/PropertyBagUtils.cpp +++ b/dom/ipc/PropertyBagUtils.cpp @@ -20,7 +20,8 @@ using namespace mozilla::dom; namespace mozilla::ipc { -void IPDLParamTraits::Write(Message* aMsg, IProtocol* aActor, +void IPDLParamTraits::Write(MessageWriter* aWriter, + IProtocol* aActor, nsIVariant* aParam) { IDPLVariant variant; @@ -130,15 +131,14 @@ void IPDLParamTraits::Write(Message* aMsg, IProtocol* aActor, MOZ_CRASH("Non handled variant type, patch welcome"); break; } - WriteIPDLParam(aMsg, aActor, variant); + WriteIPDLParam(aWriter, aActor, variant); } -bool IPDLParamTraits::Read(const Message* aMsg, - PickleIterator* aIter, +bool IPDLParamTraits::Read(MessageReader* aReader, IProtocol* aActor, RefPtr* aResult) { IDPLVariant value; - if (!ReadIPDLParam(aMsg, aIter, aActor, &value)) { + if (!ReadIPDLParam(aReader, aActor, &value)) { return false; } @@ -219,7 +219,8 @@ bool IPDLParamTraits::Read(const Message* aMsg, return true; } -void IPDLParamTraits::Write(Message* aMsg, IProtocol* aActor, +void IPDLParamTraits::Write(MessageWriter* aWriter, + IProtocol* aActor, nsIPropertyBag2* aParam) { // We send a nsIPropertyBag as an array of IPDLProperty nsTArray bag; @@ -235,15 +236,14 @@ void IPDLParamTraits::Write(Message* aMsg, IProtocol* aActor, bag.AppendElement(IPDLProperty{name, value}); } } - WriteIPDLParam(aMsg, aActor, bag); + WriteIPDLParam(aWriter, aActor, bag); } -bool IPDLParamTraits::Read(const Message* aMsg, - PickleIterator* aIter, +bool IPDLParamTraits::Read(MessageReader* aReader, IProtocol* aActor, RefPtr* aResult) { nsTArray bag; - if (!ReadIPDLParam(aMsg, aIter, aActor, &bag)) { + if (!ReadIPDLParam(aReader, aActor, &bag)) { return false; } diff --git a/dom/ipc/PropertyBagUtils.h b/dom/ipc/PropertyBagUtils.h index a85f87b16feb..573bc80ddc3b 100644 --- a/dom/ipc/PropertyBagUtils.h +++ b/dom/ipc/PropertyBagUtils.h @@ -20,17 +20,18 @@ namespace ipc { */ template <> struct IPDLParamTraits { - static void Write(IPC::Message* aMsg, IProtocol* aActor, nsIVariant* aParam); - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, RefPtr* aResult); + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, + nsIVariant* aParam); + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + RefPtr* aResult); }; template <> struct IPDLParamTraits { - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, nsIPropertyBag2* aParam); - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, RefPtr* aResult); + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + RefPtr* aResult); }; } // namespace ipc diff --git a/dom/ipc/ReferrerInfoUtils.cpp b/dom/ipc/ReferrerInfoUtils.cpp index a1d54d29d83d..a2728e342c03 100644 --- a/dom/ipc/ReferrerInfoUtils.cpp +++ b/dom/ipc/ReferrerInfoUtils.cpp @@ -12,10 +12,10 @@ namespace IPC { -void ParamTraits::Write(Message* aMsg, +void ParamTraits::Write(MessageWriter* aWriter, nsIReferrerInfo* aParam) { bool isNull = !aParam; - WriteParam(aMsg, isNull); + WriteParam(aWriter, isNull); if (isNull) { return; } @@ -25,14 +25,13 @@ void ParamTraits::Write(Message* aMsg, MOZ_CRASH("Unable to serialize referrer info."); return; } - WriteParam(aMsg, infoString); + WriteParam(aWriter, infoString); } -bool ParamTraits::Read(const Message* aMsg, - PickleIterator* aIter, +bool ParamTraits::Read(MessageReader* aReader, RefPtr* aResult) { bool isNull; - if (!ReadParam(aMsg, aIter, &isNull)) { + if (!ReadParam(aReader, &isNull)) { return false; } if (isNull) { @@ -40,7 +39,7 @@ bool ParamTraits::Read(const Message* aMsg, return true; } nsAutoCString infoString; - if (!ReadParam(aMsg, aIter, &infoString)) { + if (!ReadParam(aReader, &infoString)) { return false; } nsCOMPtr iSupports; diff --git a/dom/ipc/ReferrerInfoUtils.h b/dom/ipc/ReferrerInfoUtils.h index 803a308c7ead..9a17f9d148ae 100644 --- a/dom/ipc/ReferrerInfoUtils.h +++ b/dom/ipc/ReferrerInfoUtils.h @@ -15,9 +15,8 @@ namespace IPC { template <> struct ParamTraits { - static void Write(Message* aMsg, nsIReferrerInfo* aParam); - static bool Read(const Message* aMsg, PickleIterator* aIter, - RefPtr* aResult); + static void Write(MessageWriter* aWriter, nsIReferrerInfo* aParam); + static bool Read(MessageReader* aReader, RefPtr* aResult); }; } // namespace IPC diff --git a/dom/ipc/StructuredCloneData.cpp b/dom/ipc/StructuredCloneData.cpp index b649db5b86e9..84ba326fe611 100644 --- a/dom/ipc/StructuredCloneData.cpp +++ b/dom/ipc/StructuredCloneData.cpp @@ -379,15 +379,14 @@ void StructuredCloneData::StealFromClonedMessageDataForBackgroundChild( UnpackClonedMessageData(aClonedData, *this); } -void StructuredCloneData::WriteIPCParams(IPC::Message* aMsg) const { - WriteParam(aMsg, Data()); +void StructuredCloneData::WriteIPCParams(IPC::MessageWriter* aWriter) const { + WriteParam(aWriter, Data()); } -bool StructuredCloneData::ReadIPCParams(const IPC::Message* aMsg, - PickleIterator* aIter) { +bool StructuredCloneData::ReadIPCParams(IPC::MessageReader* aReader) { MOZ_ASSERT(!mInitialized); JSStructuredCloneData data(JS::StructuredCloneScope::DifferentProcess); - if (!ReadParam(aMsg, aIter, &data)) { + if (!ReadParam(aReader, &data)) { return false; } mSharedData = new SharedJSAllocatedData(std::move(data)); diff --git a/dom/ipc/StructuredCloneData.h b/dom/ipc/StructuredCloneData.h index bfee12089115..4b380dfcad55 100644 --- a/dom/ipc/StructuredCloneData.h +++ b/dom/ipc/StructuredCloneData.h @@ -280,8 +280,8 @@ class StructuredCloneData : public StructuredCloneHolder { } // For IPC serialization - void WriteIPCParams(IPC::Message* aMessage) const; - bool ReadIPCParams(const IPC::Message* aMessage, PickleIterator* aIter); + void WriteIPCParams(IPC::MessageWriter* aWriter) const; + bool ReadIPCParams(IPC::MessageReader* aReader); protected: already_AddRefed TakeSharedData(); diff --git a/dom/ipc/TabMessageUtils.cpp b/dom/ipc/TabMessageUtils.cpp index 00f55cfcba3e..2dbb411dcff2 100644 --- a/dom/ipc/TabMessageUtils.cpp +++ b/dom/ipc/TabMessageUtils.cpp @@ -12,11 +12,10 @@ namespace mozilla::dom { -bool ReadRemoteEvent(const IPC::Message* aMsg, PickleIterator* aIter, - RemoteDOMEvent* aResult) { +bool ReadRemoteEvent(IPC::MessageReader* aReader, RemoteDOMEvent* aResult) { aResult->mEvent = nullptr; nsString type; - NS_ENSURE_TRUE(ReadParam(aMsg, aIter, &type), false); + NS_ENSURE_TRUE(ReadParam(aReader, &type), false); aResult->mEvent = EventDispatcher::CreateEvent(nullptr, nullptr, nullptr, type); @@ -24,7 +23,7 @@ bool ReadRemoteEvent(const IPC::Message* aMsg, PickleIterator* aIter, // In a controlled environment, we should always have a valid event. bool ret = false; if (aResult->mEvent) { - ret = aResult->mEvent->Deserialize(aMsg, aIter); + ret = aResult->mEvent->Deserialize(aReader); } MOZ_ASSERT_UNLESS_FUZZING(ret); diff --git a/dom/ipc/TabMessageUtils.h b/dom/ipc/TabMessageUtils.h index 84ed551518cd..02e9fa34c377 100644 --- a/dom/ipc/TabMessageUtils.h +++ b/dom/ipc/TabMessageUtils.h @@ -20,7 +20,7 @@ namespace mozilla::dom { -bool ReadRemoteEvent(const IPC::Message* aMsg, PickleIterator* aIter, +bool ReadRemoteEvent(IPC::MessageReader* aReader, mozilla::dom::RemoteDOMEvent* aResult); } // namespace mozilla::dom @@ -31,13 +31,12 @@ template <> struct ParamTraits { typedef mozilla::dom::RemoteDOMEvent paramType; - static void Write(Message* aMsg, const paramType& aParam) { - aParam.mEvent->Serialize(aMsg, true); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + aParam.mEvent->Serialize(aWriter, true); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return mozilla::dom::ReadRemoteEvent(aMsg, aIter, aResult); + static bool Read(MessageReader* aReader, paramType* aResult) { + return mozilla::dom::ReadRemoteEvent(aReader, aResult); } static void Log(const paramType& aParam, std::wstring* aLog) {} @@ -65,19 +64,18 @@ template <> struct ParamTraits { typedef mozilla::dom::EffectsInfo paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mVisibleRect); - WriteParam(aMsg, aParam.mScaleX); - WriteParam(aMsg, aParam.mScaleY); - WriteParam(aMsg, aParam.mTransformToAncestorScale); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mVisibleRect); + WriteParam(aWriter, aParam.mScaleX); + WriteParam(aWriter, aParam.mScaleY); + WriteParam(aWriter, aParam.mTransformToAncestorScale); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mVisibleRect) && - ReadParam(aMsg, aIter, &aResult->mScaleX) && - ReadParam(aMsg, aIter, &aResult->mScaleY) && - ReadParam(aMsg, aIter, &aResult->mTransformToAncestorScale); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mVisibleRect) && + ReadParam(aReader, &aResult->mScaleX) && + ReadParam(aReader, &aResult->mScaleY) && + ReadParam(aReader, &aResult->mTransformToAncestorScale); } }; @@ -96,25 +94,24 @@ template <> struct ParamTraits { typedef mozilla::ScrollAxis paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mWhereToScroll); - WriteParam(aMsg, aParam.mWhenToScroll); - WriteParam(aMsg, aParam.mOnlyIfPerceivedScrollableDirection); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mWhereToScroll); + WriteParam(aWriter, aParam.mWhenToScroll); + WriteParam(aWriter, aParam.mOnlyIfPerceivedScrollableDirection); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &aResult->mWhereToScroll)) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &aResult->mWhereToScroll)) { return false; } - if (!ReadParam(aMsg, aIter, &aResult->mWhenToScroll)) { + if (!ReadParam(aReader, &aResult->mWhenToScroll)) { return false; } // We can't set mOnlyIfPerceivedScrollableDirection directly since it's // a bitfield. bool value; - if (!ReadParam(aMsg, aIter, &value)) { + if (!ReadParam(aReader, &value)) { return false; } aResult->mOnlyIfPerceivedScrollableDirection = value; diff --git a/dom/localstorage/SerializationHelpers.h b/dom/localstorage/SerializationHelpers.h index 529037e63ccf..54d6f2a035e6 100644 --- a/dom/localstorage/SerializationHelpers.h +++ b/dom/localstorage/SerializationHelpers.h @@ -42,19 +42,18 @@ template <> struct ParamTraits { typedef mozilla::dom::LSValue paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mBuffer); - WriteParam(aMsg, aParam.mUTF16Length); - WriteParam(aMsg, aParam.mConversionType); - WriteParam(aMsg, aParam.mCompressionType); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mBuffer); + WriteParam(aWriter, aParam.mUTF16Length); + WriteParam(aWriter, aParam.mConversionType); + WriteParam(aWriter, aParam.mCompressionType); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mBuffer) && - ReadParam(aMsg, aIter, &aResult->mUTF16Length) && - ReadParam(aMsg, aIter, &aResult->mConversionType) && - ReadParam(aMsg, aIter, &aResult->mCompressionType); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mBuffer) && + ReadParam(aReader, &aResult->mUTF16Length) && + ReadParam(aReader, &aResult->mConversionType) && + ReadParam(aReader, &aResult->mCompressionType); } static void Log(const paramType& aParam, std::wstring* aLog) { diff --git a/dom/media/gmp/GMPMessageUtils.h b/dom/media/gmp/GMPMessageUtils.h index a48be17db4c3..bc69e85c819d 100644 --- a/dom/media/gmp/GMPMessageUtils.h +++ b/dom/media/gmp/GMPMessageUtils.h @@ -65,25 +65,24 @@ template <> struct ParamTraits { typedef GMPSimulcastStream paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mWidth); - WriteParam(aMsg, aParam.mHeight); - WriteParam(aMsg, aParam.mNumberOfTemporalLayers); - WriteParam(aMsg, aParam.mMaxBitrate); - WriteParam(aMsg, aParam.mTargetBitrate); - WriteParam(aMsg, aParam.mMinBitrate); - WriteParam(aMsg, aParam.mQPMax); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mWidth); + WriteParam(aWriter, aParam.mHeight); + WriteParam(aWriter, aParam.mNumberOfTemporalLayers); + WriteParam(aWriter, aParam.mMaxBitrate); + WriteParam(aWriter, aParam.mTargetBitrate); + WriteParam(aWriter, aParam.mMinBitrate); + WriteParam(aWriter, aParam.mQPMax); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (ReadParam(aMsg, aIter, &(aResult->mWidth)) && - ReadParam(aMsg, aIter, &(aResult->mHeight)) && - ReadParam(aMsg, aIter, &(aResult->mNumberOfTemporalLayers)) && - ReadParam(aMsg, aIter, &(aResult->mMaxBitrate)) && - ReadParam(aMsg, aIter, &(aResult->mTargetBitrate)) && - ReadParam(aMsg, aIter, &(aResult->mMinBitrate)) && - ReadParam(aMsg, aIter, &(aResult->mQPMax))) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (ReadParam(aReader, &(aResult->mWidth)) && + ReadParam(aReader, &(aResult->mHeight)) && + ReadParam(aReader, &(aResult->mNumberOfTemporalLayers)) && + ReadParam(aReader, &(aResult->mMaxBitrate)) && + ReadParam(aReader, &(aResult->mTargetBitrate)) && + ReadParam(aReader, &(aResult->mMinBitrate)) && + ReadParam(aReader, &(aResult->mQPMax))) { return true; } return false; @@ -101,41 +100,40 @@ template <> struct ParamTraits { typedef GMPVideoCodec paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mGMPApiVersion); - WriteParam(aMsg, aParam.mCodecType); - WriteParam(aMsg, static_cast( - nsDependentCString(aParam.mPLName))); - WriteParam(aMsg, aParam.mPLType); - WriteParam(aMsg, aParam.mWidth); - WriteParam(aMsg, aParam.mHeight); - WriteParam(aMsg, aParam.mStartBitrate); - WriteParam(aMsg, aParam.mMaxBitrate); - WriteParam(aMsg, aParam.mMinBitrate); - WriteParam(aMsg, aParam.mMaxFramerate); - WriteParam(aMsg, aParam.mFrameDroppingOn); - WriteParam(aMsg, aParam.mKeyFrameInterval); - WriteParam(aMsg, aParam.mQPMax); - WriteParam(aMsg, aParam.mNumberOfSimulcastStreams); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mGMPApiVersion); + WriteParam(aWriter, aParam.mCodecType); + WriteParam(aWriter, static_cast( + nsDependentCString(aParam.mPLName))); + WriteParam(aWriter, aParam.mPLType); + WriteParam(aWriter, aParam.mWidth); + WriteParam(aWriter, aParam.mHeight); + WriteParam(aWriter, aParam.mStartBitrate); + WriteParam(aWriter, aParam.mMaxBitrate); + WriteParam(aWriter, aParam.mMinBitrate); + WriteParam(aWriter, aParam.mMaxFramerate); + WriteParam(aWriter, aParam.mFrameDroppingOn); + WriteParam(aWriter, aParam.mKeyFrameInterval); + WriteParam(aWriter, aParam.mQPMax); + WriteParam(aWriter, aParam.mNumberOfSimulcastStreams); for (uint32_t i = 0; i < aParam.mNumberOfSimulcastStreams; i++) { - WriteParam(aMsg, aParam.mSimulcastStream[i]); + WriteParam(aWriter, aParam.mSimulcastStream[i]); } - WriteParam(aMsg, aParam.mMode); + WriteParam(aWriter, aParam.mMode); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { // NOTE: make sure this matches any versions supported - if (!ReadParam(aMsg, aIter, &(aResult->mGMPApiVersion)) || + if (!ReadParam(aReader, &(aResult->mGMPApiVersion)) || aResult->mGMPApiVersion != kGMPVersion33) { return false; } - if (!ReadParam(aMsg, aIter, &(aResult->mCodecType))) { + if (!ReadParam(aReader, &(aResult->mCodecType))) { return false; } nsAutoCString plName; - if (!ReadParam(aMsg, aIter, &plName) || + if (!ReadParam(aReader, &plName) || plName.Length() > kGMPPayloadNameSize - 1) { return false; } @@ -143,20 +141,20 @@ struct ParamTraits { memset(aResult->mPLName + plName.Length(), 0, kGMPPayloadNameSize - plName.Length()); - if (!ReadParam(aMsg, aIter, &(aResult->mPLType)) || - !ReadParam(aMsg, aIter, &(aResult->mWidth)) || - !ReadParam(aMsg, aIter, &(aResult->mHeight)) || - !ReadParam(aMsg, aIter, &(aResult->mStartBitrate)) || - !ReadParam(aMsg, aIter, &(aResult->mMaxBitrate)) || - !ReadParam(aMsg, aIter, &(aResult->mMinBitrate)) || - !ReadParam(aMsg, aIter, &(aResult->mMaxFramerate)) || - !ReadParam(aMsg, aIter, &(aResult->mFrameDroppingOn)) || - !ReadParam(aMsg, aIter, &(aResult->mKeyFrameInterval))) { + if (!ReadParam(aReader, &(aResult->mPLType)) || + !ReadParam(aReader, &(aResult->mWidth)) || + !ReadParam(aReader, &(aResult->mHeight)) || + !ReadParam(aReader, &(aResult->mStartBitrate)) || + !ReadParam(aReader, &(aResult->mMaxBitrate)) || + !ReadParam(aReader, &(aResult->mMinBitrate)) || + !ReadParam(aReader, &(aResult->mMaxFramerate)) || + !ReadParam(aReader, &(aResult->mFrameDroppingOn)) || + !ReadParam(aReader, &(aResult->mKeyFrameInterval))) { return false; } - if (!ReadParam(aMsg, aIter, &(aResult->mQPMax)) || - !ReadParam(aMsg, aIter, &(aResult->mNumberOfSimulcastStreams))) { + if (!ReadParam(aReader, &(aResult->mQPMax)) || + !ReadParam(aReader, &(aResult->mNumberOfSimulcastStreams))) { return false; } @@ -165,12 +163,12 @@ struct ParamTraits { } for (uint32_t i = 0; i < aResult->mNumberOfSimulcastStreams; i++) { - if (!ReadParam(aMsg, aIter, &(aResult->mSimulcastStream[i]))) { + if (!ReadParam(aReader, &(aResult->mSimulcastStream[i]))) { return false; } } - if (!ReadParam(aMsg, aIter, &(aResult->mMode))) { + if (!ReadParam(aReader, &(aResult->mMode))) { return false; } diff --git a/dom/media/ipc/MediaIPCUtils.h b/dom/media/ipc/MediaIPCUtils.h index ed9f9006b88c..9ea393d6c860 100644 --- a/dom/media/ipc/MediaIPCUtils.h +++ b/dom/media/ipc/MediaIPCUtils.h @@ -19,40 +19,39 @@ template <> struct ParamTraits { typedef mozilla::VideoInfo paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { // TrackInfo - WriteParam(aMsg, aParam.mMimeType); + WriteParam(aWriter, aParam.mMimeType); // VideoInfo - WriteParam(aMsg, aParam.mDisplay); - WriteParam(aMsg, aParam.mStereoMode); - WriteParam(aMsg, aParam.mImage); - WriteParam(aMsg, aParam.mImageRect); - WriteParam(aMsg, *aParam.mCodecSpecificConfig); - WriteParam(aMsg, *aParam.mExtraData); - WriteParam(aMsg, aParam.mRotation); - WriteParam(aMsg, aParam.mColorDepth); - WriteParam(aMsg, aParam.mColorSpace); - WriteParam(aMsg, aParam.mColorRange); - WriteParam(aMsg, aParam.HasAlpha()); + WriteParam(aWriter, aParam.mDisplay); + WriteParam(aWriter, aParam.mStereoMode); + WriteParam(aWriter, aParam.mImage); + WriteParam(aWriter, aParam.mImageRect); + WriteParam(aWriter, *aParam.mCodecSpecificConfig); + WriteParam(aWriter, *aParam.mExtraData); + WriteParam(aWriter, aParam.mRotation); + WriteParam(aWriter, aParam.mColorDepth); + WriteParam(aWriter, aParam.mColorSpace); + WriteParam(aWriter, aParam.mColorRange); + WriteParam(aWriter, aParam.HasAlpha()); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { mozilla::gfx::IntRect imageRect; bool alphaPresent; - if (ReadParam(aMsg, aIter, &aResult->mMimeType) && - ReadParam(aMsg, aIter, &aResult->mDisplay) && - ReadParam(aMsg, aIter, &aResult->mStereoMode) && - ReadParam(aMsg, aIter, &aResult->mImage) && - ReadParam(aMsg, aIter, &aResult->mImageRect) && - ReadParam(aMsg, aIter, aResult->mCodecSpecificConfig.get()) && - ReadParam(aMsg, aIter, aResult->mExtraData.get()) && - ReadParam(aMsg, aIter, &aResult->mRotation) && - ReadParam(aMsg, aIter, &aResult->mColorDepth) && - ReadParam(aMsg, aIter, &aResult->mColorSpace) && - ReadParam(aMsg, aIter, &aResult->mColorRange) && - ReadParam(aMsg, aIter, &alphaPresent)) { + if (ReadParam(aReader, &aResult->mMimeType) && + ReadParam(aReader, &aResult->mDisplay) && + ReadParam(aReader, &aResult->mStereoMode) && + ReadParam(aReader, &aResult->mImage) && + ReadParam(aReader, &aResult->mImageRect) && + ReadParam(aReader, aResult->mCodecSpecificConfig.get()) && + ReadParam(aReader, aResult->mExtraData.get()) && + ReadParam(aReader, &aResult->mRotation) && + ReadParam(aReader, &aResult->mColorDepth) && + ReadParam(aReader, &aResult->mColorSpace) && + ReadParam(aReader, &aResult->mColorRange) && + ReadParam(aReader, &alphaPresent)) { aResult->SetAlpha(alphaPresent); return true; } @@ -83,32 +82,31 @@ template <> struct ParamTraits { typedef mozilla::AudioInfo paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { // TrackInfo - WriteParam(aMsg, aParam.mMimeType); + WriteParam(aWriter, aParam.mMimeType); // AudioInfo - WriteParam(aMsg, aParam.mRate); - WriteParam(aMsg, aParam.mChannels); - WriteParam(aMsg, aParam.mChannelMap); - WriteParam(aMsg, aParam.mBitDepth); - WriteParam(aMsg, aParam.mProfile); - WriteParam(aMsg, aParam.mExtendedProfile); - WriteParam(aMsg, *aParam.mCodecSpecificConfig); - WriteParam(aMsg, *aParam.mExtraData); + WriteParam(aWriter, aParam.mRate); + WriteParam(aWriter, aParam.mChannels); + WriteParam(aWriter, aParam.mChannelMap); + WriteParam(aWriter, aParam.mBitDepth); + WriteParam(aWriter, aParam.mProfile); + WriteParam(aWriter, aParam.mExtendedProfile); + WriteParam(aWriter, *aParam.mCodecSpecificConfig); + WriteParam(aWriter, *aParam.mExtraData); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (ReadParam(aMsg, aIter, &aResult->mMimeType) && - ReadParam(aMsg, aIter, &aResult->mRate) && - ReadParam(aMsg, aIter, &aResult->mChannels) && - ReadParam(aMsg, aIter, &aResult->mChannelMap) && - ReadParam(aMsg, aIter, &aResult->mBitDepth) && - ReadParam(aMsg, aIter, &aResult->mProfile) && - ReadParam(aMsg, aIter, &aResult->mExtendedProfile) && - ReadParam(aMsg, aIter, aResult->mCodecSpecificConfig.get()) && - ReadParam(aMsg, aIter, aResult->mExtraData.get())) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (ReadParam(aReader, &aResult->mMimeType) && + ReadParam(aReader, &aResult->mRate) && + ReadParam(aReader, &aResult->mChannels) && + ReadParam(aReader, &aResult->mChannelMap) && + ReadParam(aReader, &aResult->mBitDepth) && + ReadParam(aReader, &aResult->mProfile) && + ReadParam(aReader, &aResult->mExtendedProfile) && + ReadParam(aReader, aResult->mCodecSpecificConfig.get()) && + ReadParam(aReader, aResult->mExtraData.get())) { return true; } return false; @@ -127,16 +125,15 @@ template <> struct ParamTraits { typedef mozilla::media::TimeUnit paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.IsValid()); - WriteParam(aMsg, aParam.IsValid() ? aParam.ToMicroseconds() : 0); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.IsValid()); + WriteParam(aWriter, aParam.IsValid() ? aParam.ToMicroseconds() : 0); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { bool valid; int64_t value; - if (ReadParam(aMsg, aIter, &valid) && ReadParam(aMsg, aIter, &value)) { + if (ReadParam(aReader, &valid) && ReadParam(aReader, &value)) { if (!valid) { *aResult = mozilla::media::TimeUnit::Invalid(); } else { @@ -152,17 +149,16 @@ template <> struct ParamTraits { typedef mozilla::media::TimeInterval paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mStart); - WriteParam(aMsg, aParam.mEnd); - WriteParam(aMsg, aParam.mFuzz); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mStart); + WriteParam(aWriter, aParam.mEnd); + WriteParam(aWriter, aParam.mFuzz); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (ReadParam(aMsg, aIter, &aResult->mStart) && - ReadParam(aMsg, aIter, &aResult->mEnd) && - ReadParam(aMsg, aIter, &aResult->mFuzz)) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (ReadParam(aReader, &aResult->mStart) && + ReadParam(aReader, &aResult->mEnd) && + ReadParam(aReader, &aResult->mFuzz)) { return true; } return false; @@ -173,16 +169,15 @@ template <> struct ParamTraits { typedef mozilla::MediaResult paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.Code()); - WriteParam(aMsg, aParam.Message()); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.Code()); + WriteParam(aWriter, aParam.Message()); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { nsresult result; nsCString message; - if (ReadParam(aMsg, aIter, &result) && ReadParam(aMsg, aIter, &message)) { + if (ReadParam(aReader, &result) && ReadParam(aReader, &message)) { *aResult = paramType(result, std::move(message)); return true; } @@ -194,19 +189,18 @@ template <> struct ParamTraits { typedef mozilla::DecoderDoctorDiagnostics paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mDiagnosticsType); - WriteParam(aMsg, aParam.mFormat); - WriteParam(aMsg, aParam.mFlags); - WriteParam(aMsg, aParam.mEvent); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mDiagnosticsType); + WriteParam(aWriter, aParam.mFormat); + WriteParam(aWriter, aParam.mFlags); + WriteParam(aWriter, aParam.mEvent); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (ReadParam(aMsg, aIter, &aResult->mDiagnosticsType) && - ReadParam(aMsg, aIter, &aResult->mFormat) && - ReadParam(aMsg, aIter, &aResult->mFlags) && - ReadParam(aMsg, aIter, &aResult->mEvent)) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (ReadParam(aReader, &aResult->mDiagnosticsType) && + ReadParam(aReader, &aResult->mFormat) && + ReadParam(aReader, &aResult->mFlags) && + ReadParam(aReader, &aResult->mEvent)) { return true; } return false; @@ -225,17 +219,15 @@ template <> struct ParamTraits { typedef mozilla::DecoderDoctorEvent paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { int domain = aParam.mDomain; - WriteParam(aMsg, domain); - WriteParam(aMsg, aParam.mResult); + WriteParam(aWriter, domain); + WriteParam(aWriter, aParam.mResult); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { int domain = 0; - if (ReadParam(aMsg, aIter, &domain) && - ReadParam(aMsg, aIter, &aResult->mResult)) { + if (ReadParam(aReader, &domain) && ReadParam(aReader, &aResult->mResult)) { aResult->mDomain = paramType::Domain(domain); return true; } diff --git a/dom/media/ipc/RemoteImageHolder.cpp b/dom/media/ipc/RemoteImageHolder.cpp index 88e9061d58f4..c707f7c072ad 100644 --- a/dom/media/ipc/RemoteImageHolder.cpp +++ b/dom/media/ipc/RemoteImageHolder.cpp @@ -138,21 +138,22 @@ RemoteImageHolder::~RemoteImageHolder() { } /* static */ void ipc::IPDLParamTraits::Write( - IPC::Message* aMsg, ipc::IProtocol* aActor, RemoteImageHolder&& aParam) { - WriteIPDLParam(aMsg, aActor, aParam.mSource); - WriteIPDLParam(aMsg, aActor, aParam.mSize); - WriteIPDLParam(aMsg, aActor, aParam.mSD); + IPC::MessageWriter* aWriter, ipc::IProtocol* aActor, + RemoteImageHolder&& aParam) { + WriteIPDLParam(aWriter, aActor, aParam.mSource); + WriteIPDLParam(aWriter, aActor, aParam.mSize); + WriteIPDLParam(aWriter, aActor, aParam.mSD); // Empty this holder. aParam.mSD = Nothing(); aParam.mManager = nullptr; } /* static */ bool ipc::IPDLParamTraits::Read( - const IPC::Message* aMsg, PickleIterator* aIter, ipc::IProtocol* aActor, + IPC::MessageReader* aReader, ipc::IProtocol* aActor, RemoteImageHolder* aResult) { - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mSource) || - !ReadIPDLParam(aMsg, aIter, aActor, &aResult->mSize) || - !ReadIPDLParam(aMsg, aIter, aActor, &aResult->mSD)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mSource) || + !ReadIPDLParam(aReader, aActor, &aResult->mSize) || + !ReadIPDLParam(aReader, aActor, &aResult->mSD)) { return false; } if (!aResult->IsEmpty()) { diff --git a/dom/media/ipc/RemoteImageHolder.h b/dom/media/ipc/RemoteImageHolder.h index c677b388ada3..3e8f22a2785f 100644 --- a/dom/media/ipc/RemoteImageHolder.h +++ b/dom/media/ipc/RemoteImageHolder.h @@ -53,10 +53,10 @@ class RemoteImageHolder final { template <> struct ipc::IPDLParamTraits { - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, RemoteImageHolder&& aParam); - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, RemoteImageHolder* aResult); + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + RemoteImageHolder* aResult); }; } // namespace mozilla diff --git a/dom/media/ipc/RemoteMediaData.cpp b/dom/media/ipc/RemoteMediaData.cpp index f005160a35e9..09203b3c71db 100644 --- a/dom/media/ipc/RemoteMediaData.cpp +++ b/dom/media/ipc/RemoteMediaData.cpp @@ -107,26 +107,26 @@ already_AddRefed RemoteArrayOfByteBuffer::MediaByteBufferAt( } /*static */ void ipc::IPDLParamTraits::Write( - IPC::Message* aMsg, ipc::IProtocol* aActor, + IPC::MessageWriter* aWriter, ipc::IProtocol* aActor, const RemoteArrayOfByteBuffer& aVar) { - WriteIPDLParam(aMsg, aActor, aVar.mIsValid); + WriteIPDLParam(aWriter, aActor, aVar.mIsValid); // We need the following gymnastic as the Shmem transfered over IPC will be // revoked. We must create a temporary one instead so that it can be recycled // later back into the original ShmemPool. if (aVar.mBuffers) { - WriteIPDLParam(aMsg, aActor, Some(ipc::Shmem(*aVar.mBuffers))); + WriteIPDLParam(aWriter, aActor, Some(ipc::Shmem(*aVar.mBuffers))); } else { - WriteIPDLParam(aMsg, aActor, Maybe()); + WriteIPDLParam(aWriter, aActor, Maybe()); } - WriteIPDLParam(aMsg, aActor, aVar.mOffsets); + WriteIPDLParam(aWriter, aActor, aVar.mOffsets); } /* static */ bool ipc::IPDLParamTraits::Read( - const IPC::Message* aMsg, PickleIterator* aIter, - mozilla::ipc::IProtocol* aActor, RemoteArrayOfByteBuffer* aVar) { - return ReadIPDLParam(aMsg, aIter, aActor, &aVar->mIsValid) && - ReadIPDLParam(aMsg, aIter, aActor, &aVar->mBuffers) && - ReadIPDLParam(aMsg, aIter, aActor, &aVar->mOffsets); + IPC::MessageReader* aReader, mozilla::ipc::IProtocol* aActor, + RemoteArrayOfByteBuffer* aVar) { + return ReadIPDLParam(aReader, aActor, &aVar->mIsValid) && + ReadIPDLParam(aReader, aActor, &aVar->mBuffers) && + ReadIPDLParam(aReader, aActor, &aVar->mOffsets); } bool ArrayOfRemoteMediaRawData::Fill( @@ -211,22 +211,22 @@ already_AddRefed ArrayOfRemoteMediaRawData::ElementAt( } /*static */ void ipc::IPDLParamTraits::Write( - IPC::Message* aMsg, ipc::IProtocol* aActor, + IPC::MessageWriter* aWriter, ipc::IProtocol* aActor, ArrayOfRemoteMediaRawData* aVar) { - WriteIPDLParam(aMsg, aActor, std::move(aVar->mSamples)); - WriteIPDLParam(aMsg, aActor, std::move(aVar->mBuffers)); - WriteIPDLParam(aMsg, aActor, std::move(aVar->mAlphaBuffers)); - WriteIPDLParam(aMsg, aActor, std::move(aVar->mExtraDatas)); + WriteIPDLParam(aWriter, aActor, std::move(aVar->mSamples)); + WriteIPDLParam(aWriter, aActor, std::move(aVar->mBuffers)); + WriteIPDLParam(aWriter, aActor, std::move(aVar->mAlphaBuffers)); + WriteIPDLParam(aWriter, aActor, std::move(aVar->mExtraDatas)); } /* static */ bool ipc::IPDLParamTraits::Read( - const IPC::Message* aMsg, PickleIterator* aIter, - mozilla::ipc::IProtocol* aActor, RefPtr* aVar) { + IPC::MessageReader* aReader, mozilla::ipc::IProtocol* aActor, + RefPtr* aVar) { auto array = MakeRefPtr(); - if (!ReadIPDLParam(aMsg, aIter, aActor, &array->mSamples) || - !ReadIPDLParam(aMsg, aIter, aActor, &array->mBuffers) || - !ReadIPDLParam(aMsg, aIter, aActor, &array->mAlphaBuffers) || - !ReadIPDLParam(aMsg, aIter, aActor, &array->mExtraDatas)) { + if (!ReadIPDLParam(aReader, aActor, &array->mSamples) || + !ReadIPDLParam(aReader, aActor, &array->mBuffers) || + !ReadIPDLParam(aReader, aActor, &array->mAlphaBuffers) || + !ReadIPDLParam(aReader, aActor, &array->mExtraDatas)) { return false; } *aVar = std::move(array); @@ -235,24 +235,24 @@ already_AddRefed ArrayOfRemoteMediaRawData::ElementAt( /* static */ void ipc::IPDLParamTraits::Write( - IPC::Message* aMsg, ipc::IProtocol* aActor, const paramType& aVar) { - WriteIPDLParam(aMsg, aActor, aVar.mBase); - WriteIPDLParam(aMsg, aActor, aVar.mEOS); - WriteIPDLParam(aMsg, aActor, aVar.mHeight); - WriteIPDLParam(aMsg, aActor, aVar.mDiscardPadding); - WriteIPDLParam(aMsg, aActor, aVar.mOriginalPresentationWindow); + IPC::MessageWriter* aWriter, ipc::IProtocol* aActor, + const paramType& aVar) { + WriteIPDLParam(aWriter, aActor, aVar.mBase); + WriteIPDLParam(aWriter, aActor, aVar.mEOS); + WriteIPDLParam(aWriter, aActor, aVar.mHeight); + WriteIPDLParam(aWriter, aActor, aVar.mDiscardPadding); + WriteIPDLParam(aWriter, aActor, aVar.mOriginalPresentationWindow); } /* static */ bool ipc::IPDLParamTraits::Read( - const IPC::Message* aMsg, PickleIterator* aIter, ipc::IProtocol* aActor, - paramType* aVar) { + IPC::MessageReader* aReader, ipc::IProtocol* aActor, paramType* aVar) { MediaDataIPDL mBase; - return ReadIPDLParam(aMsg, aIter, aActor, &aVar->mBase) && - ReadIPDLParam(aMsg, aIter, aActor, &aVar->mEOS) && - ReadIPDLParam(aMsg, aIter, aActor, &aVar->mHeight) && - ReadIPDLParam(aMsg, aIter, aActor, &aVar->mDiscardPadding) && - ReadIPDLParam(aMsg, aIter, aActor, &aVar->mOriginalPresentationWindow); + return ReadIPDLParam(aReader, aActor, &aVar->mBase) && + ReadIPDLParam(aReader, aActor, &aVar->mEOS) && + ReadIPDLParam(aReader, aActor, &aVar->mHeight) && + ReadIPDLParam(aReader, aActor, &aVar->mDiscardPadding) && + ReadIPDLParam(aReader, aActor, &aVar->mOriginalPresentationWindow); }; bool ArrayOfRemoteAudioData::Fill( @@ -304,17 +304,18 @@ already_AddRefed ArrayOfRemoteAudioData::ElementAt( } /*static */ void ipc::IPDLParamTraits::Write( - IPC::Message* aMsg, ipc::IProtocol* aActor, ArrayOfRemoteAudioData* aVar) { - WriteIPDLParam(aMsg, aActor, std::move(aVar->mSamples)); - WriteIPDLParam(aMsg, aActor, std::move(aVar->mBuffers)); + IPC::MessageWriter* aWriter, ipc::IProtocol* aActor, + ArrayOfRemoteAudioData* aVar) { + WriteIPDLParam(aWriter, aActor, std::move(aVar->mSamples)); + WriteIPDLParam(aWriter, aActor, std::move(aVar->mBuffers)); } /* static */ bool ipc::IPDLParamTraits::Read( - const IPC::Message* aMsg, PickleIterator* aIter, - mozilla::ipc::IProtocol* aActor, RefPtr* aVar) { + IPC::MessageReader* aReader, mozilla::ipc::IProtocol* aActor, + RefPtr* aVar) { auto array = MakeRefPtr(); - if (!ReadIPDLParam(aMsg, aIter, aActor, &array->mSamples) || - !ReadIPDLParam(aMsg, aIter, aActor, &array->mBuffers)) { + if (!ReadIPDLParam(aReader, aActor, &array->mSamples) || + !ReadIPDLParam(aReader, aActor, &array->mBuffers)) { return false; } *aVar = std::move(array); @@ -323,30 +324,30 @@ already_AddRefed ArrayOfRemoteAudioData::ElementAt( /* static */ void ipc::IPDLParamTraits::Write( - IPC::Message* aMsg, ipc::IProtocol* aActor, const paramType& aVar) { - WriteIPDLParam(aMsg, aActor, aVar.mBase); - WriteIPDLParam(aMsg, aActor, aVar.mChannels); - WriteIPDLParam(aMsg, aActor, aVar.mRate); - WriteIPDLParam(aMsg, aActor, aVar.mChannelMap); - WriteIPDLParam(aMsg, aActor, aVar.mOriginalTime); - WriteIPDLParam(aMsg, aActor, aVar.mTrimWindow); - WriteIPDLParam(aMsg, aActor, aVar.mFrames); - WriteIPDLParam(aMsg, aActor, aVar.mDataOffset); + IPC::MessageWriter* aWriter, ipc::IProtocol* aActor, + const paramType& aVar) { + WriteIPDLParam(aWriter, aActor, aVar.mBase); + WriteIPDLParam(aWriter, aActor, aVar.mChannels); + WriteIPDLParam(aWriter, aActor, aVar.mRate); + WriteIPDLParam(aWriter, aActor, aVar.mChannelMap); + WriteIPDLParam(aWriter, aActor, aVar.mOriginalTime); + WriteIPDLParam(aWriter, aActor, aVar.mTrimWindow); + WriteIPDLParam(aWriter, aActor, aVar.mFrames); + WriteIPDLParam(aWriter, aActor, aVar.mDataOffset); } /* static */ bool ipc::IPDLParamTraits::Read( - const IPC::Message* aMsg, PickleIterator* aIter, ipc::IProtocol* aActor, - paramType* aVar) { + IPC::MessageReader* aReader, ipc::IProtocol* aActor, paramType* aVar) { MediaDataIPDL mBase; - if (!ReadIPDLParam(aMsg, aIter, aActor, &aVar->mBase) || - !ReadIPDLParam(aMsg, aIter, aActor, &aVar->mChannels) || - !ReadIPDLParam(aMsg, aIter, aActor, &aVar->mRate) || - !ReadIPDLParam(aMsg, aIter, aActor, &aVar->mChannelMap) || - !ReadIPDLParam(aMsg, aIter, aActor, &aVar->mOriginalTime) || - !ReadIPDLParam(aMsg, aIter, aActor, &aVar->mTrimWindow) || - !ReadIPDLParam(aMsg, aIter, aActor, &aVar->mFrames) || - !ReadIPDLParam(aMsg, aIter, aActor, &aVar->mDataOffset)) { + if (!ReadIPDLParam(aReader, aActor, &aVar->mBase) || + !ReadIPDLParam(aReader, aActor, &aVar->mChannels) || + !ReadIPDLParam(aReader, aActor, &aVar->mRate) || + !ReadIPDLParam(aReader, aActor, &aVar->mChannelMap) || + !ReadIPDLParam(aReader, aActor, &aVar->mOriginalTime) || + !ReadIPDLParam(aReader, aActor, &aVar->mTrimWindow) || + !ReadIPDLParam(aReader, aActor, &aVar->mFrames) || + !ReadIPDLParam(aReader, aActor, &aVar->mDataOffset)) { return false; } return true; diff --git a/dom/media/ipc/RemoteMediaData.h b/dom/media/ipc/RemoteMediaData.h index f8f9aa4ad4c3..25b07a5ce2a6 100644 --- a/dom/media/ipc/RemoteMediaData.h +++ b/dom/media/ipc/RemoteMediaData.h @@ -296,20 +296,20 @@ namespace ipc { template <> struct IPDLParamTraits { typedef RemoteVideoData paramType; - static void Write(IPC::Message* aMsg, ipc::IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, ipc::IProtocol* aActor, paramType&& aVar) { - WriteIPDLParam(aMsg, aActor, std::move(aVar.mBase)); - WriteIPDLParam(aMsg, aActor, std::move(aVar.mDisplay)); - WriteIPDLParam(aMsg, aActor, std::move(aVar.mImage)); - aMsg->WriteBytes(&aVar.mFrameID, 4); + WriteIPDLParam(aWriter, aActor, std::move(aVar.mBase)); + WriteIPDLParam(aWriter, aActor, std::move(aVar.mDisplay)); + WriteIPDLParam(aWriter, aActor, std::move(aVar.mImage)); + aWriter->WriteBytes(&aVar.mFrameID, 4); } - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - mozilla::ipc::IProtocol* aActor, paramType* aVar) { - if (!ReadIPDLParam(aMsg, aIter, aActor, &aVar->mBase) || - !ReadIPDLParam(aMsg, aIter, aActor, &aVar->mDisplay) || - !ReadIPDLParam(aMsg, aIter, aActor, &aVar->mImage) || - !aMsg->ReadBytesInto(aIter, &aVar->mFrameID, 4)) { + static bool Read(IPC::MessageReader* aReader, mozilla::ipc::IProtocol* aActor, + paramType* aVar) { + if (!ReadIPDLParam(aReader, aActor, &aVar->mBase) || + !ReadIPDLParam(aReader, aActor, &aVar->mDisplay) || + !ReadIPDLParam(aReader, aActor, &aVar->mImage) || + !aReader->ReadBytesInto(&aVar->mFrameID, 4)) { return false; } return true; @@ -319,15 +319,15 @@ struct IPDLParamTraits { template <> struct IPDLParamTraits { typedef ArrayOfRemoteVideoData paramType; - static void Write(IPC::Message* aMsg, mozilla::ipc::IProtocol* aActor, - paramType* aVar) { - WriteIPDLParam(aMsg, aActor, std::move(aVar->mArray)); + static void Write(IPC::MessageWriter* aWriter, + mozilla::ipc::IProtocol* aActor, paramType* aVar) { + WriteIPDLParam(aWriter, aActor, std::move(aVar->mArray)); } - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - ipc::IProtocol* aActor, RefPtr* aVar) { + static bool Read(IPC::MessageReader* aReader, ipc::IProtocol* aActor, + RefPtr* aVar) { nsTArray array; - if (!ReadIPDLParam(aMsg, aIter, aActor, &array)) { + if (!ReadIPDLParam(aReader, aActor, &array)) { return false; } auto results = MakeRefPtr(std::move(array)); @@ -341,51 +341,51 @@ struct IPDLParamTraits { typedef RemoteArrayOfByteBuffer paramType; // We do not want to move the RemoteArrayOfByteBuffer as we want to recycle // the shmem it contains for another time. - static void Write(IPC::Message* aMsg, ipc::IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, ipc::IProtocol* aActor, const paramType& aVar); - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - ipc::IProtocol* aActor, paramType* aVar); + static bool Read(IPC::MessageReader* aReader, ipc::IProtocol* aActor, + paramType* aVar); }; template <> struct IPDLParamTraits { typedef ArrayOfRemoteMediaRawData::RemoteMediaRawData paramType; - static void Write(IPC::Message* aMsg, ipc::IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, ipc::IProtocol* aActor, const paramType& aVar); - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - ipc::IProtocol* aActor, paramType* aVar); + static bool Read(IPC::MessageReader* aReader, ipc::IProtocol* aActor, + paramType* aVar); }; template <> struct IPDLParamTraits { typedef ArrayOfRemoteMediaRawData paramType; - static void Write(IPC::Message* aMsg, ipc::IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, ipc::IProtocol* aActor, paramType* aVar); - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - ipc::IProtocol* aActor, RefPtr* aVar); + static bool Read(IPC::MessageReader* aReader, ipc::IProtocol* aActor, + RefPtr* aVar); }; template <> struct IPDLParamTraits { typedef ArrayOfRemoteAudioData::RemoteAudioData paramType; - static void Write(IPC::Message* aMsg, ipc::IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, ipc::IProtocol* aActor, const paramType& aVar); - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - ipc::IProtocol* aActor, paramType* aVar); + static bool Read(IPC::MessageReader* aReader, ipc::IProtocol* aActor, + paramType* aVar); }; template <> struct IPDLParamTraits { typedef ArrayOfRemoteAudioData paramType; - static void Write(IPC::Message* aMsg, ipc::IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, ipc::IProtocol* aActor, paramType* aVar); - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - ipc::IProtocol* aActor, RefPtr* aVar); + static bool Read(IPC::MessageReader* aReader, ipc::IProtocol* aActor, + RefPtr* aVar); }; } // namespace ipc diff --git a/dom/media/mediacontrol/MediaControlIPC.h b/dom/media/mediacontrol/MediaControlIPC.h index 023b9a391945..100e5832c222 100644 --- a/dom/media/mediacontrol/MediaControlIPC.h +++ b/dom/media/mediacontrol/MediaControlIPC.h @@ -38,15 +38,14 @@ template <> struct ParamTraits { typedef mozilla::dom::SeekDetails paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mSeekTime); - WriteParam(aMsg, aParam.mFastSeek); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mSeekTime); + WriteParam(aWriter, aParam.mFastSeek); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &aResult->mSeekTime) || - !ReadParam(aMsg, aIter, &aResult->mFastSeek)) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &aResult->mSeekTime) || + !ReadParam(aReader, &aResult->mFastSeek)) { return false; } return true; @@ -57,15 +56,14 @@ template <> struct ParamTraits { typedef mozilla::dom::MediaControlAction paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mKey); - WriteParam(aMsg, aParam.mDetails); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mKey); + WriteParam(aWriter, aParam.mDetails); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &aResult->mKey) || - !ReadParam(aMsg, aIter, &aResult->mDetails)) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &aResult->mKey) || + !ReadParam(aReader, &aResult->mDetails)) { return false; } return true; diff --git a/dom/media/mediasession/MediaSessionIPCUtils.h b/dom/media/mediasession/MediaSessionIPCUtils.h index d957e1059dc2..c44f4b4553af 100644 --- a/dom/media/mediasession/MediaSessionIPCUtils.h +++ b/dom/media/mediasession/MediaSessionIPCUtils.h @@ -25,17 +25,16 @@ template <> struct ParamTraits { typedef mozilla::dom::MediaImage paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mSizes); - WriteParam(aMsg, aParam.mSrc); - WriteParam(aMsg, aParam.mType); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mSizes); + WriteParam(aWriter, aParam.mSrc); + WriteParam(aWriter, aParam.mType); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &(aResult->mSizes)) || - !ReadParam(aMsg, aIter, &(aResult->mSrc)) || - !ReadParam(aMsg, aIter, &(aResult->mType))) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &(aResult->mSizes)) || + !ReadParam(aReader, &(aResult->mSrc)) || + !ReadParam(aReader, &(aResult->mType))) { return false; } return true; @@ -46,19 +45,18 @@ template <> struct ParamTraits { typedef mozilla::dom::MediaMetadataBase paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mTitle); - WriteParam(aMsg, aParam.mArtist); - WriteParam(aMsg, aParam.mAlbum); - WriteParam(aMsg, aParam.mArtwork); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mTitle); + WriteParam(aWriter, aParam.mArtist); + WriteParam(aWriter, aParam.mAlbum); + WriteParam(aWriter, aParam.mArtwork); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &(aResult->mTitle)) || - !ReadParam(aMsg, aIter, &(aResult->mArtist)) || - !ReadParam(aMsg, aIter, &(aResult->mAlbum)) || - !ReadParam(aMsg, aIter, &(aResult->mArtwork))) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &(aResult->mTitle)) || + !ReadParam(aReader, &(aResult->mArtist)) || + !ReadParam(aReader, &(aResult->mAlbum)) || + !ReadParam(aReader, &(aResult->mArtwork))) { return false; } return true; @@ -69,17 +67,16 @@ template <> struct ParamTraits { typedef mozilla::dom::PositionState paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mDuration); - WriteParam(aMsg, aParam.mPlaybackRate); - WriteParam(aMsg, aParam.mLastReportedPlaybackPosition); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mDuration); + WriteParam(aWriter, aParam.mPlaybackRate); + WriteParam(aWriter, aParam.mLastReportedPlaybackPosition); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &(aResult->mDuration)) || - !ReadParam(aMsg, aIter, &(aResult->mPlaybackRate)) || - !ReadParam(aMsg, aIter, &(aResult->mLastReportedPlaybackPosition))) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &(aResult->mDuration)) || + !ReadParam(aReader, &(aResult->mPlaybackRate)) || + !ReadParam(aReader, &(aResult->mLastReportedPlaybackPosition))) { return false; } return true; diff --git a/dom/media/webrtc/WebrtcGlobal.h b/dom/media/webrtc/WebrtcGlobal.h index 28d4dca006aa..95655202e8b8 100644 --- a/dom/media/webrtc/WebrtcGlobal.h +++ b/dom/media/webrtc/WebrtcGlobal.h @@ -99,13 +99,12 @@ struct ParamTraits< mozilla::dom::NotReallyMovableButLetsPretendItIsRTCStatsCollection> { typedef mozilla::dom::NotReallyMovableButLetsPretendItIsRTCStatsCollection paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, static_cast(aParam)); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, static_cast(aResult)); } }; @@ -133,17 +132,18 @@ DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::dom::RTCSdpHistoryEntryInternal, template <> struct ParamTraits { - static void Write(Message* aMsg, + static void Write(MessageWriter* aWriter, const mozilla::dom::RTCStatsCollection& aParam) { mozilla::dom::ForAllRTCStatsCollectionMembers( - aParam, [&](const auto&... aMember) { WriteParams(aMsg, aMember...); }); + aParam, + [&](const auto&... aMember) { WriteParams(aWriter, aMember...); }); } - static bool Read(const Message* aMsg, PickleIterator* aIter, + static bool Read(MessageReader* aReader, mozilla::dom::RTCStatsCollection* aResult) { return mozilla::dom::ForAllRTCStatsCollectionMembers( *aResult, - [&](auto&... aMember) { return ReadParams(aMsg, aIter, aMember...); }); + [&](auto&... aMember) { return ReadParams(aReader, aMember...); }); } }; @@ -154,19 +154,18 @@ DEFINE_IPC_SERIALIZER_WITH_SUPER_CLASS_AND_FIELDS( typedef mozilla::dom::RTCStats RTCStats; -static void WriteRTCStats(Message* aMsg, const RTCStats& aParam) { +static void WriteRTCStats(MessageWriter* aWriter, const RTCStats& aParam) { // RTCStats base class - WriteParam(aMsg, aParam.mId); - WriteParam(aMsg, aParam.mTimestamp); - WriteParam(aMsg, aParam.mType); + WriteParam(aWriter, aParam.mId); + WriteParam(aWriter, aParam.mTimestamp); + WriteParam(aWriter, aParam.mType); } -static bool ReadRTCStats(const Message* aMsg, PickleIterator* aIter, - RTCStats* aResult) { +static bool ReadRTCStats(MessageReader* aReader, RTCStats* aResult) { // RTCStats base class - if (!ReadParam(aMsg, aIter, &(aResult->mId)) || - !ReadParam(aMsg, aIter, &(aResult->mTimestamp)) || - !ReadParam(aMsg, aIter, &(aResult->mType))) { + if (!ReadParam(aReader, &(aResult->mId)) || + !ReadParam(aReader, &(aResult->mTimestamp)) || + !ReadParam(aReader, &(aResult->mType))) { return false; } @@ -177,41 +176,40 @@ template <> struct ParamTraits { typedef mozilla::dom::RTCIceCandidatePairStats paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mTransportId); - WriteParam(aMsg, aParam.mLocalCandidateId); - WriteParam(aMsg, aParam.mPriority); - WriteParam(aMsg, aParam.mNominated); - WriteParam(aMsg, aParam.mWritable); - WriteParam(aMsg, aParam.mReadable); - WriteParam(aMsg, aParam.mRemoteCandidateId); - WriteParam(aMsg, aParam.mSelected); - WriteParam(aMsg, aParam.mComponentId); - WriteParam(aMsg, aParam.mState); - WriteParam(aMsg, aParam.mBytesSent); - WriteParam(aMsg, aParam.mBytesReceived); - WriteParam(aMsg, aParam.mLastPacketSentTimestamp); - WriteParam(aMsg, aParam.mLastPacketReceivedTimestamp); - WriteRTCStats(aMsg, aParam); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mTransportId); + WriteParam(aWriter, aParam.mLocalCandidateId); + WriteParam(aWriter, aParam.mPriority); + WriteParam(aWriter, aParam.mNominated); + WriteParam(aWriter, aParam.mWritable); + WriteParam(aWriter, aParam.mReadable); + WriteParam(aWriter, aParam.mRemoteCandidateId); + WriteParam(aWriter, aParam.mSelected); + WriteParam(aWriter, aParam.mComponentId); + WriteParam(aWriter, aParam.mState); + WriteParam(aWriter, aParam.mBytesSent); + WriteParam(aWriter, aParam.mBytesReceived); + WriteParam(aWriter, aParam.mLastPacketSentTimestamp); + WriteParam(aWriter, aParam.mLastPacketReceivedTimestamp); + WriteRTCStats(aWriter, aParam); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &(aResult->mTransportId)) || - !ReadParam(aMsg, aIter, &(aResult->mLocalCandidateId)) || - !ReadParam(aMsg, aIter, &(aResult->mPriority)) || - !ReadParam(aMsg, aIter, &(aResult->mNominated)) || - !ReadParam(aMsg, aIter, &(aResult->mWritable)) || - !ReadParam(aMsg, aIter, &(aResult->mReadable)) || - !ReadParam(aMsg, aIter, &(aResult->mRemoteCandidateId)) || - !ReadParam(aMsg, aIter, &(aResult->mSelected)) || - !ReadParam(aMsg, aIter, &(aResult->mComponentId)) || - !ReadParam(aMsg, aIter, &(aResult->mState)) || - !ReadParam(aMsg, aIter, &(aResult->mBytesSent)) || - !ReadParam(aMsg, aIter, &(aResult->mBytesReceived)) || - !ReadParam(aMsg, aIter, &(aResult->mLastPacketSentTimestamp)) || - !ReadParam(aMsg, aIter, &(aResult->mLastPacketReceivedTimestamp)) || - !ReadRTCStats(aMsg, aIter, aResult)) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &(aResult->mTransportId)) || + !ReadParam(aReader, &(aResult->mLocalCandidateId)) || + !ReadParam(aReader, &(aResult->mPriority)) || + !ReadParam(aReader, &(aResult->mNominated)) || + !ReadParam(aReader, &(aResult->mWritable)) || + !ReadParam(aReader, &(aResult->mReadable)) || + !ReadParam(aReader, &(aResult->mRemoteCandidateId)) || + !ReadParam(aReader, &(aResult->mSelected)) || + !ReadParam(aReader, &(aResult->mComponentId)) || + !ReadParam(aReader, &(aResult->mState)) || + !ReadParam(aReader, &(aResult->mBytesSent)) || + !ReadParam(aReader, &(aResult->mBytesReceived)) || + !ReadParam(aReader, &(aResult->mLastPacketSentTimestamp)) || + !ReadParam(aReader, &(aResult->mLastPacketReceivedTimestamp)) || + !ReadRTCStats(aReader, aResult)) { return false; } @@ -223,29 +221,28 @@ template <> struct ParamTraits { typedef mozilla::dom::RTCIceCandidateStats paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mCandidateType); - WriteParam(aMsg, aParam.mPriority); - WriteParam(aMsg, aParam.mTransportId); - WriteParam(aMsg, aParam.mAddress); - WriteParam(aMsg, aParam.mRelayProtocol); - WriteParam(aMsg, aParam.mPort); - WriteParam(aMsg, aParam.mProtocol); - WriteParam(aMsg, aParam.mProxied); - WriteRTCStats(aMsg, aParam); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mCandidateType); + WriteParam(aWriter, aParam.mPriority); + WriteParam(aWriter, aParam.mTransportId); + WriteParam(aWriter, aParam.mAddress); + WriteParam(aWriter, aParam.mRelayProtocol); + WriteParam(aWriter, aParam.mPort); + WriteParam(aWriter, aParam.mProtocol); + WriteParam(aWriter, aParam.mProxied); + WriteRTCStats(aWriter, aParam); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &(aResult->mCandidateType)) || - !ReadParam(aMsg, aIter, &(aResult->mPriority)) || - !ReadParam(aMsg, aIter, &(aResult->mTransportId)) || - !ReadParam(aMsg, aIter, &(aResult->mAddress)) || - !ReadParam(aMsg, aIter, &(aResult->mRelayProtocol)) || - !ReadParam(aMsg, aIter, &(aResult->mPort)) || - !ReadParam(aMsg, aIter, &(aResult->mProtocol)) || - !ReadParam(aMsg, aIter, &(aResult->mProxied)) || - !ReadRTCStats(aMsg, aIter, aResult)) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &(aResult->mCandidateType)) || + !ReadParam(aReader, &(aResult->mPriority)) || + !ReadParam(aReader, &(aResult->mTransportId)) || + !ReadParam(aReader, &(aResult->mAddress)) || + !ReadParam(aReader, &(aResult->mRelayProtocol)) || + !ReadParam(aReader, &(aResult->mPort)) || + !ReadParam(aReader, &(aResult->mProtocol)) || + !ReadParam(aReader, &(aResult->mProxied)) || + !ReadRTCStats(aReader, aResult)) { return false; } @@ -254,110 +251,107 @@ struct ParamTraits { }; static void WriteRTCRtpStreamStats( - Message* aMsg, const mozilla::dom::RTCRtpStreamStats& aParam) { - WriteParam(aMsg, aParam.mSsrc); - WriteParam(aMsg, aParam.mMediaType); - WriteParam(aMsg, aParam.mKind); - WriteParam(aMsg, aParam.mTransportId); - WriteParam(aMsg, aParam.mCodecId); - WriteRTCStats(aMsg, aParam); + MessageWriter* aWriter, const mozilla::dom::RTCRtpStreamStats& aParam) { + WriteParam(aWriter, aParam.mSsrc); + WriteParam(aWriter, aParam.mMediaType); + WriteParam(aWriter, aParam.mKind); + WriteParam(aWriter, aParam.mTransportId); + WriteParam(aWriter, aParam.mCodecId); + WriteRTCStats(aWriter, aParam); } -static bool ReadRTCRtpStreamStats(const Message* aMsg, PickleIterator* aIter, +static bool ReadRTCRtpStreamStats(MessageReader* aReader, mozilla::dom::RTCRtpStreamStats* aResult) { - return ReadParam(aMsg, aIter, &(aResult->mSsrc)) && - ReadParam(aMsg, aIter, &(aResult->mMediaType)) && - ReadParam(aMsg, aIter, &(aResult->mKind)) && - ReadParam(aMsg, aIter, &(aResult->mTransportId)) && - ReadParam(aMsg, aIter, &(aResult->mCodecId)) && - ReadRTCStats(aMsg, aIter, aResult); + return ReadParam(aReader, &(aResult->mSsrc)) && + ReadParam(aReader, &(aResult->mMediaType)) && + ReadParam(aReader, &(aResult->mKind)) && + ReadParam(aReader, &(aResult->mTransportId)) && + ReadParam(aReader, &(aResult->mCodecId)) && + ReadRTCStats(aReader, aResult); } static void WriteRTCReceivedRtpStreamStats( - Message* aMsg, const mozilla::dom::RTCReceivedRtpStreamStats& aParam) { - WriteParam(aMsg, aParam.mPacketsReceived); - WriteParam(aMsg, aParam.mPacketsLost); - WriteParam(aMsg, aParam.mJitter); - WriteParam(aMsg, aParam.mDiscardedPackets); - WriteParam(aMsg, aParam.mPacketsDiscarded); - WriteRTCRtpStreamStats(aMsg, aParam); + MessageWriter* aWriter, + const mozilla::dom::RTCReceivedRtpStreamStats& aParam) { + WriteParam(aWriter, aParam.mPacketsReceived); + WriteParam(aWriter, aParam.mPacketsLost); + WriteParam(aWriter, aParam.mJitter); + WriteParam(aWriter, aParam.mDiscardedPackets); + WriteParam(aWriter, aParam.mPacketsDiscarded); + WriteRTCRtpStreamStats(aWriter, aParam); } static bool ReadRTCReceivedRtpStreamStats( - const Message* aMsg, PickleIterator* aIter, - mozilla::dom::RTCReceivedRtpStreamStats* aResult) { - return ReadParam(aMsg, aIter, &(aResult->mPacketsReceived)) && - ReadParam(aMsg, aIter, &(aResult->mPacketsLost)) && - ReadParam(aMsg, aIter, &(aResult->mJitter)) && - ReadParam(aMsg, aIter, &(aResult->mDiscardedPackets)) && - ReadParam(aMsg, aIter, &(aResult->mPacketsDiscarded)) && - ReadRTCRtpStreamStats(aMsg, aIter, aResult); + MessageReader* aReader, mozilla::dom::RTCReceivedRtpStreamStats* aResult) { + return ReadParam(aReader, &(aResult->mPacketsReceived)) && + ReadParam(aReader, &(aResult->mPacketsLost)) && + ReadParam(aReader, &(aResult->mJitter)) && + ReadParam(aReader, &(aResult->mDiscardedPackets)) && + ReadParam(aReader, &(aResult->mPacketsDiscarded)) && + ReadRTCRtpStreamStats(aReader, aResult); } template <> struct ParamTraits { typedef mozilla::dom::RTCInboundRtpStreamStats paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mRemoteId); - WriteParam(aMsg, aParam.mFramesDecoded); - WriteParam(aMsg, aParam.mBytesReceived); - WriteParam(aMsg, aParam.mNackCount); - WriteParam(aMsg, aParam.mFirCount); - WriteParam(aMsg, aParam.mPliCount); - WriteRTCReceivedRtpStreamStats(aMsg, aParam); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mRemoteId); + WriteParam(aWriter, aParam.mFramesDecoded); + WriteParam(aWriter, aParam.mBytesReceived); + WriteParam(aWriter, aParam.mNackCount); + WriteParam(aWriter, aParam.mFirCount); + WriteParam(aWriter, aParam.mPliCount); + WriteRTCReceivedRtpStreamStats(aWriter, aParam); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &(aResult->mRemoteId)) && - ReadParam(aMsg, aIter, &(aResult->mFramesDecoded)) && - ReadParam(aMsg, aIter, &(aResult->mBytesReceived)) && - ReadParam(aMsg, aIter, &(aResult->mNackCount)) && - ReadParam(aMsg, aIter, &(aResult->mFirCount)) && - ReadParam(aMsg, aIter, &(aResult->mPliCount)) && - ReadRTCReceivedRtpStreamStats(aMsg, aIter, aResult); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &(aResult->mRemoteId)) && + ReadParam(aReader, &(aResult->mFramesDecoded)) && + ReadParam(aReader, &(aResult->mBytesReceived)) && + ReadParam(aReader, &(aResult->mNackCount)) && + ReadParam(aReader, &(aResult->mFirCount)) && + ReadParam(aReader, &(aResult->mPliCount)) && + ReadRTCReceivedRtpStreamStats(aReader, aResult); } }; static void WriteRTCSentRtpStreamStats( - Message* aMsg, const mozilla::dom::RTCSentRtpStreamStats& aParam) { - WriteParam(aMsg, aParam.mPacketsSent); - WriteParam(aMsg, aParam.mBytesSent); - WriteRTCRtpStreamStats(aMsg, aParam); + MessageWriter* aWriter, const mozilla::dom::RTCSentRtpStreamStats& aParam) { + WriteParam(aWriter, aParam.mPacketsSent); + WriteParam(aWriter, aParam.mBytesSent); + WriteRTCRtpStreamStats(aWriter, aParam); } static bool ReadRTCSentRtpStreamStats( - const Message* aMsg, PickleIterator* aIter, - mozilla::dom::RTCSentRtpStreamStats* aResult) { - return ReadParam(aMsg, aIter, &(aResult->mPacketsSent)) && - ReadParam(aMsg, aIter, &(aResult->mBytesSent)) && - ReadRTCRtpStreamStats(aMsg, aIter, aResult); + MessageReader* aReader, mozilla::dom::RTCSentRtpStreamStats* aResult) { + return ReadParam(aReader, &(aResult->mPacketsSent)) && + ReadParam(aReader, &(aResult->mBytesSent)) && + ReadRTCRtpStreamStats(aReader, aResult); } template <> struct ParamTraits { typedef mozilla::dom::RTCOutboundRtpStreamStats paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mRemoteId); - WriteParam(aMsg, aParam.mFramesEncoded); - WriteParam(aMsg, aParam.mQpSum); - WriteParam(aMsg, aParam.mNackCount); - WriteParam(aMsg, aParam.mFirCount); - WriteParam(aMsg, aParam.mPliCount); - WriteRTCSentRtpStreamStats(aMsg, aParam); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mRemoteId); + WriteParam(aWriter, aParam.mFramesEncoded); + WriteParam(aWriter, aParam.mQpSum); + WriteParam(aWriter, aParam.mNackCount); + WriteParam(aWriter, aParam.mFirCount); + WriteParam(aWriter, aParam.mPliCount); + WriteRTCSentRtpStreamStats(aWriter, aParam); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &(aResult->mRemoteId)) && - ReadParam(aMsg, aIter, &(aResult->mFramesEncoded)) && - ReadParam(aMsg, aIter, &(aResult->mQpSum)) && - ReadParam(aMsg, aIter, &(aResult->mNackCount)) && - ReadParam(aMsg, aIter, &(aResult->mFirCount)) && - ReadParam(aMsg, aIter, &(aResult->mPliCount)) && - ReadRTCSentRtpStreamStats(aMsg, aIter, aResult); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &(aResult->mRemoteId)) && + ReadParam(aReader, &(aResult->mFramesEncoded)) && + ReadParam(aReader, &(aResult->mQpSum)) && + ReadParam(aReader, &(aResult->mNackCount)) && + ReadParam(aReader, &(aResult->mFirCount)) && + ReadParam(aReader, &(aResult->mPliCount)) && + ReadRTCSentRtpStreamStats(aReader, aResult); } }; @@ -365,17 +359,16 @@ template <> struct ParamTraits { typedef mozilla::dom::RTCRemoteInboundRtpStreamStats paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mLocalId); - WriteParam(aMsg, aParam.mRoundTripTime); - WriteRTCReceivedRtpStreamStats(aMsg, aParam); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mLocalId); + WriteParam(aWriter, aParam.mRoundTripTime); + WriteRTCReceivedRtpStreamStats(aWriter, aParam); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &(aResult->mLocalId)) && - ReadParam(aMsg, aIter, &(aResult->mRoundTripTime)) && - ReadRTCReceivedRtpStreamStats(aMsg, aIter, aResult); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &(aResult->mLocalId)) && + ReadParam(aReader, &(aResult->mRoundTripTime)) && + ReadRTCReceivedRtpStreamStats(aReader, aResult); } }; @@ -383,17 +376,16 @@ template <> struct ParamTraits { typedef mozilla::dom::RTCRemoteOutboundRtpStreamStats paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mLocalId); - WriteParam(aMsg, aParam.mRemoteTimestamp); - WriteRTCSentRtpStreamStats(aMsg, aParam); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mLocalId); + WriteParam(aWriter, aParam.mRemoteTimestamp); + WriteRTCSentRtpStreamStats(aWriter, aParam); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &(aResult->mLocalId)) && - ReadParam(aMsg, aIter, &(aResult->mRemoteTimestamp)) && - ReadRTCSentRtpStreamStats(aMsg, aIter, aResult); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &(aResult->mLocalId)) && + ReadParam(aReader, &(aResult->mRemoteTimestamp)) && + ReadRTCSentRtpStreamStats(aReader, aResult); } }; @@ -401,17 +393,16 @@ template <> struct ParamTraits { typedef mozilla::dom::RTCRTPContributingSourceStats paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mContributorSsrc); - WriteParam(aMsg, aParam.mInboundRtpStreamId); - WriteRTCStats(aMsg, aParam); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mContributorSsrc); + WriteParam(aWriter, aParam.mInboundRtpStreamId); + WriteRTCStats(aWriter, aParam); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &(aResult->mContributorSsrc)) || - !ReadParam(aMsg, aIter, &(aResult->mInboundRtpStreamId)) || - !ReadRTCStats(aMsg, aIter, aResult)) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &(aResult->mContributorSsrc)) || + !ReadParam(aReader, &(aResult->mInboundRtpStreamId)) || + !ReadRTCStats(aReader, aResult)) { return false; } return true; diff --git a/dom/media/webrtc/WebrtcIPCTraits.h b/dom/media/webrtc/WebrtcIPCTraits.h index 89fef9eba11a..b076745608c7 100644 --- a/dom/media/webrtc/WebrtcIPCTraits.h +++ b/dom/media/webrtc/WebrtcIPCTraits.h @@ -30,22 +30,21 @@ struct ParamTraits { // private generated code. So we have to re-create it. enum Type { kUninitialized, kString, kStringSequence }; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { if (aParam.IsString()) { - aMsg->WriteInt16(kString); - WriteParam(aMsg, aParam.GetAsString()); + aWriter->WriteInt16(kString); + WriteParam(aWriter, aParam.GetAsString()); } else if (aParam.IsStringSequence()) { - aMsg->WriteInt16(kStringSequence); - WriteParam(aMsg, aParam.GetAsStringSequence()); + aWriter->WriteInt16(kStringSequence); + WriteParam(aWriter, aParam.GetAsStringSequence()); } else { - aMsg->WriteInt16(kUninitialized); + aWriter->WriteInt16(kUninitialized); } } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { int16_t type; - if (!aMsg->ReadInt16(aIter, &type)) { + if (!aReader->ReadInt16(&type)) { return false; } @@ -54,9 +53,9 @@ struct ParamTraits { aResult->Uninit(); return true; case kString: - return ReadParam(aMsg, aIter, &aResult->SetAsString()); + return ReadParam(aReader, &aResult->SetAsString()); case kStringSequence: - return ReadParam(aMsg, aIter, &aResult->SetAsStringSequence()); + return ReadParam(aReader, &aResult->SetAsStringSequence()); } return false; diff --git a/dom/media/webrtc/transport/ipc/NrIceStunAddrMessageUtils.h b/dom/media/webrtc/transport/ipc/NrIceStunAddrMessageUtils.h index b45845df5253..34ec46726e1e 100644 --- a/dom/media/webrtc/transport/ipc/NrIceStunAddrMessageUtils.h +++ b/dom/media/webrtc/transport/ipc/NrIceStunAddrMessageUtils.h @@ -20,22 +20,22 @@ namespace IPC { template <> struct ParamTraits { - static void Write(Message* aMsg, const mozilla::NrIceStunAddr& aParam) { + static void Write(MessageWriter* aWriter, + const mozilla::NrIceStunAddr& aParam) { #ifdef MOZ_WEBRTC const size_t bufSize = aParam.SerializationBufferSize(); char* buffer = new char[bufSize]; aParam.Serialize(buffer, bufSize); - aMsg->WriteBytes((void*)buffer, bufSize); + aWriter->WriteBytes((void*)buffer, bufSize); delete[] buffer; #endif } - static bool Read(const Message* aMsg, PickleIterator* aIter, - mozilla::NrIceStunAddr* aResult) { + static bool Read(MessageReader* aReader, mozilla::NrIceStunAddr* aResult) { #ifdef MOZ_WEBRTC const size_t bufSize = aResult->SerializationBufferSize(); char* buffer = new char[bufSize]; - bool result = aMsg->ReadBytesInto(aIter, (void*)buffer, bufSize); + bool result = aReader->ReadBytesInto((void*)buffer, bufSize); if (result) { result = result && (NS_OK == aResult->Deserialize(buffer, bufSize)); diff --git a/dom/media/webrtc/transport/mediapacket.cpp b/dom/media/webrtc/transport/mediapacket.cpp index 55095c9dafdd..9388640e6738 100644 --- a/dom/media/webrtc/transport/mediapacket.cpp +++ b/dom/media/webrtc/transport/mediapacket.cpp @@ -26,34 +26,34 @@ void MediaPacket::Copy(const uint8_t* data, size_t len, size_t capacity) { memcpy(data_.get(), data, len); } -void MediaPacket::Serialize(IPC::Message* aMsg) const { - aMsg->WriteUInt32(len_); - aMsg->WriteUInt32(capacity_); +void MediaPacket::Serialize(IPC::MessageWriter* aWriter) const { + aWriter->WriteUInt32(len_); + aWriter->WriteUInt32(capacity_); if (len_) { - aMsg->WriteBytes(data_.get(), len_); + aWriter->WriteBytes(data_.get(), len_); } - aMsg->WriteUInt32(encrypted_len_); + aWriter->WriteUInt32(encrypted_len_); if (encrypted_len_) { - aMsg->WriteBytes(encrypted_data_.get(), encrypted_len_); + aWriter->WriteBytes(encrypted_data_.get(), encrypted_len_); } - aMsg->WriteInt32(sdp_level_.isSome() ? *sdp_level_ : -1); - aMsg->WriteInt32(type_); + aWriter->WriteInt32(sdp_level_.isSome() ? *sdp_level_ : -1); + aWriter->WriteInt32(type_); } -bool MediaPacket::Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) { +bool MediaPacket::Deserialize(IPC::MessageReader* aReader) { Reset(); uint32_t len; - if (!aMsg->ReadUInt32(aIter, &len)) { + if (!aReader->ReadUInt32(&len)) { return false; } uint32_t capacity; - if (!aMsg->ReadUInt32(aIter, &capacity)) { + if (!aReader->ReadUInt32(&capacity)) { return false; } if (len) { MOZ_RELEASE_ASSERT(capacity >= len); UniquePtr data(new uint8_t[capacity]); - if (!aMsg->ReadBytesInto(aIter, data.get(), len)) { + if (!aReader->ReadBytesInto(data.get(), len)) { return false; } data_ = std::move(data); @@ -61,12 +61,12 @@ bool MediaPacket::Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) { capacity_ = capacity; } - if (!aMsg->ReadUInt32(aIter, &len)) { + if (!aReader->ReadUInt32(&len)) { return false; } if (len) { UniquePtr data(new uint8_t[len]); - if (!aMsg->ReadBytesInto(aIter, data.get(), len)) { + if (!aReader->ReadBytesInto(data.get(), len)) { return false; } encrypted_data_ = std::move(data); @@ -74,7 +74,7 @@ bool MediaPacket::Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) { } int32_t sdp_level; - if (!aMsg->ReadInt32(aIter, &sdp_level)) { + if (!aReader->ReadInt32(&sdp_level)) { return false; } @@ -83,7 +83,7 @@ bool MediaPacket::Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) { } int32_t type; - if (!aMsg->ReadInt32(aIter, &type)) { + if (!aReader->ReadInt32(&type)) { return false; } type_ = static_cast(type); diff --git a/dom/media/webrtc/transport/mediapacket.h b/dom/media/webrtc/transport/mediapacket.h index 2dc79d7dbd0d..1ba479bc9be8 100644 --- a/dom/media/webrtc/transport/mediapacket.h +++ b/dom/media/webrtc/transport/mediapacket.h @@ -80,8 +80,8 @@ class MediaPacket { Type type() const { return type_; } - void Serialize(IPC::Message* aMsg) const; - bool Deserialize(const IPC::Message* aMsg, PickleIterator* aIter); + void Serialize(IPC::MessageWriter* aWriter) const; + bool Deserialize(IPC::MessageReader* aReader); private: UniquePtr data_; @@ -102,13 +102,13 @@ struct ParamTraits; template <> struct ParamTraits { - static void Write(Message* aMsg, const mozilla::MediaPacket& aParam) { - aParam.Serialize(aMsg); + static void Write(MessageWriter* aWriter, + const mozilla::MediaPacket& aParam) { + aParam.Serialize(aWriter); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - mozilla::MediaPacket* aResult) { - return aResult->Deserialize(aMsg, aIter); + static bool Read(MessageReader* aReader, mozilla::MediaPacket* aResult) { + return aResult->Deserialize(aReader); } }; } // namespace IPC diff --git a/dom/performance/PerformanceTiming.h b/dom/performance/PerformanceTiming.h index 88be82ad2823..a0ee32a4521b 100644 --- a/dom/performance/PerformanceTiming.h +++ b/dom/performance/PerformanceTiming.h @@ -428,127 +428,126 @@ namespace ipc { template <> struct IPDLParamTraits { using paramType = mozilla::dom::PerformanceTimingData; - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, const paramType& aParam) { - WriteIPDLParam(aMsg, aActor, aParam.mServerTiming); - WriteIPDLParam(aMsg, aActor, aParam.mNextHopProtocol); - WriteIPDLParam(aMsg, aActor, aParam.mAsyncOpen); - WriteIPDLParam(aMsg, aActor, aParam.mRedirectStart); - WriteIPDLParam(aMsg, aActor, aParam.mRedirectEnd); - WriteIPDLParam(aMsg, aActor, aParam.mDomainLookupStart); - WriteIPDLParam(aMsg, aActor, aParam.mDomainLookupEnd); - WriteIPDLParam(aMsg, aActor, aParam.mConnectStart); - WriteIPDLParam(aMsg, aActor, aParam.mSecureConnectionStart); - WriteIPDLParam(aMsg, aActor, aParam.mConnectEnd); - WriteIPDLParam(aMsg, aActor, aParam.mRequestStart); - WriteIPDLParam(aMsg, aActor, aParam.mResponseStart); - WriteIPDLParam(aMsg, aActor, aParam.mCacheReadStart); - WriteIPDLParam(aMsg, aActor, aParam.mResponseEnd); - WriteIPDLParam(aMsg, aActor, aParam.mCacheReadEnd); - WriteIPDLParam(aMsg, aActor, aParam.mWorkerStart); - WriteIPDLParam(aMsg, aActor, aParam.mWorkerRequestStart); - WriteIPDLParam(aMsg, aActor, aParam.mWorkerResponseEnd); - WriteIPDLParam(aMsg, aActor, aParam.mZeroTime); - WriteIPDLParam(aMsg, aActor, aParam.mFetchStart); - WriteIPDLParam(aMsg, aActor, aParam.mEncodedBodySize); - WriteIPDLParam(aMsg, aActor, aParam.mTransferSize); - WriteIPDLParam(aMsg, aActor, aParam.mDecodedBodySize); - WriteIPDLParam(aMsg, aActor, aParam.mRedirectCount); - WriteIPDLParam(aMsg, aActor, aParam.mAllRedirectsSameOrigin); - WriteIPDLParam(aMsg, aActor, aParam.mAllRedirectsPassTAO); - WriteIPDLParam(aMsg, aActor, aParam.mSecureConnection); - WriteIPDLParam(aMsg, aActor, aParam.mTimingAllowed); - WriteIPDLParam(aMsg, aActor, aParam.mInitialized); + WriteIPDLParam(aWriter, aActor, aParam.mServerTiming); + WriteIPDLParam(aWriter, aActor, aParam.mNextHopProtocol); + WriteIPDLParam(aWriter, aActor, aParam.mAsyncOpen); + WriteIPDLParam(aWriter, aActor, aParam.mRedirectStart); + WriteIPDLParam(aWriter, aActor, aParam.mRedirectEnd); + WriteIPDLParam(aWriter, aActor, aParam.mDomainLookupStart); + WriteIPDLParam(aWriter, aActor, aParam.mDomainLookupEnd); + WriteIPDLParam(aWriter, aActor, aParam.mConnectStart); + WriteIPDLParam(aWriter, aActor, aParam.mSecureConnectionStart); + WriteIPDLParam(aWriter, aActor, aParam.mConnectEnd); + WriteIPDLParam(aWriter, aActor, aParam.mRequestStart); + WriteIPDLParam(aWriter, aActor, aParam.mResponseStart); + WriteIPDLParam(aWriter, aActor, aParam.mCacheReadStart); + WriteIPDLParam(aWriter, aActor, aParam.mResponseEnd); + WriteIPDLParam(aWriter, aActor, aParam.mCacheReadEnd); + WriteIPDLParam(aWriter, aActor, aParam.mWorkerStart); + WriteIPDLParam(aWriter, aActor, aParam.mWorkerRequestStart); + WriteIPDLParam(aWriter, aActor, aParam.mWorkerResponseEnd); + WriteIPDLParam(aWriter, aActor, aParam.mZeroTime); + WriteIPDLParam(aWriter, aActor, aParam.mFetchStart); + WriteIPDLParam(aWriter, aActor, aParam.mEncodedBodySize); + WriteIPDLParam(aWriter, aActor, aParam.mTransferSize); + WriteIPDLParam(aWriter, aActor, aParam.mDecodedBodySize); + WriteIPDLParam(aWriter, aActor, aParam.mRedirectCount); + WriteIPDLParam(aWriter, aActor, aParam.mAllRedirectsSameOrigin); + WriteIPDLParam(aWriter, aActor, aParam.mAllRedirectsPassTAO); + WriteIPDLParam(aWriter, aActor, aParam.mSecureConnection); + WriteIPDLParam(aWriter, aActor, aParam.mTimingAllowed); + WriteIPDLParam(aWriter, aActor, aParam.mInitialized); } - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, paramType* aResult) { - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mServerTiming)) { + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + paramType* aResult) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mServerTiming)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mNextHopProtocol)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mNextHopProtocol)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mAsyncOpen)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mAsyncOpen)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mRedirectStart)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mRedirectStart)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mRedirectEnd)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mRedirectEnd)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mDomainLookupStart)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mDomainLookupStart)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mDomainLookupEnd)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mDomainLookupEnd)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mConnectStart)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mConnectStart)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mSecureConnectionStart)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mSecureConnectionStart)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mConnectEnd)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mConnectEnd)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mRequestStart)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mRequestStart)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mResponseStart)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mResponseStart)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mCacheReadStart)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mCacheReadStart)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mResponseEnd)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mResponseEnd)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mCacheReadEnd)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mCacheReadEnd)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mWorkerStart)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mWorkerStart)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mWorkerRequestStart)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mWorkerRequestStart)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mWorkerResponseEnd)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mWorkerResponseEnd)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mZeroTime)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mZeroTime)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mFetchStart)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mFetchStart)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mEncodedBodySize)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mEncodedBodySize)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mTransferSize)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mTransferSize)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mDecodedBodySize)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mDecodedBodySize)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mRedirectCount)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mRedirectCount)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, - &aResult->mAllRedirectsSameOrigin)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mAllRedirectsSameOrigin)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mAllRedirectsPassTAO)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mAllRedirectsPassTAO)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mSecureConnection)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mSecureConnection)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mTimingAllowed)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mTimingAllowed)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mInitialized)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mInitialized)) { return false; } return true; @@ -558,7 +557,7 @@ struct IPDLParamTraits { template <> struct IPDLParamTraits> { using paramType = nsCOMPtr; - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, const paramType& aParam) { nsAutoCString name; Unused << aParam->GetName(name); @@ -566,23 +565,23 @@ struct IPDLParamTraits> { Unused << aParam->GetDuration(&duration); nsAutoCString description; Unused << aParam->GetDescription(description); - WriteIPDLParam(aMsg, aActor, name); - WriteIPDLParam(aMsg, aActor, duration); - WriteIPDLParam(aMsg, aActor, description); + WriteIPDLParam(aWriter, aActor, name); + WriteIPDLParam(aWriter, aActor, duration); + WriteIPDLParam(aWriter, aActor, description); } - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, paramType* aResult) { + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + paramType* aResult) { nsAutoCString name; double duration; nsAutoCString description; - if (!ReadIPDLParam(aMsg, aIter, aActor, &name)) { + if (!ReadIPDLParam(aReader, aActor, &name)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &duration)) { + if (!ReadIPDLParam(aReader, aActor, &duration)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &description)) { + if (!ReadIPDLParam(aReader, aActor, &description)) { return false; } diff --git a/dom/quota/SerializationHelpers.h b/dom/quota/SerializationHelpers.h index a6479445f68d..e63e3ef67d65 100644 --- a/dom/quota/SerializationHelpers.h +++ b/dom/quota/SerializationHelpers.h @@ -34,23 +34,22 @@ template <> struct ParamTraits { using ParamType = mozilla::dom::quota::FullOriginMetadata; - static void Write(Message* aMsg, const ParamType& aParam) { - WriteParam(aMsg, aParam.mSuffix); - WriteParam(aMsg, aParam.mGroup); - WriteParam(aMsg, aParam.mOrigin); - WriteParam(aMsg, aParam.mPersistenceType); - WriteParam(aMsg, aParam.mPersisted); - WriteParam(aMsg, aParam.mLastAccessTime); + static void Write(MessageWriter* aWriter, const ParamType& aParam) { + WriteParam(aWriter, aParam.mSuffix); + WriteParam(aWriter, aParam.mGroup); + WriteParam(aWriter, aParam.mOrigin); + WriteParam(aWriter, aParam.mPersistenceType); + WriteParam(aWriter, aParam.mPersisted); + WriteParam(aWriter, aParam.mLastAccessTime); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - ParamType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mSuffix) && - ReadParam(aMsg, aIter, &aResult->mGroup) && - ReadParam(aMsg, aIter, &aResult->mOrigin) && - ReadParam(aMsg, aIter, &aResult->mPersistenceType) && - ReadParam(aMsg, aIter, &aResult->mPersisted) && - ReadParam(aMsg, aIter, &aResult->mLastAccessTime); + static bool Read(MessageReader* aReader, ParamType* aResult) { + return ReadParam(aReader, &aResult->mSuffix) && + ReadParam(aReader, &aResult->mGroup) && + ReadParam(aReader, &aResult->mOrigin) && + ReadParam(aReader, &aResult->mPersistenceType) && + ReadParam(aReader, &aResult->mPersisted) && + ReadParam(aReader, &aResult->mLastAccessTime); } }; @@ -58,21 +57,20 @@ template <> struct ParamTraits { typedef mozilla::OriginAttributesPattern paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mFirstPartyDomain); - WriteParam(aMsg, aParam.mInIsolatedMozBrowser); - WriteParam(aMsg, aParam.mPrivateBrowsingId); - WriteParam(aMsg, aParam.mUserContextId); - WriteParam(aMsg, aParam.mGeckoViewSessionContextId); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mFirstPartyDomain); + WriteParam(aWriter, aParam.mInIsolatedMozBrowser); + WriteParam(aWriter, aParam.mPrivateBrowsingId); + WriteParam(aWriter, aParam.mUserContextId); + WriteParam(aWriter, aParam.mGeckoViewSessionContextId); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mFirstPartyDomain) && - ReadParam(aMsg, aIter, &aResult->mInIsolatedMozBrowser) && - ReadParam(aMsg, aIter, &aResult->mPrivateBrowsingId) && - ReadParam(aMsg, aIter, &aResult->mUserContextId) && - ReadParam(aMsg, aIter, &aResult->mGeckoViewSessionContextId); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mFirstPartyDomain) && + ReadParam(aReader, &aResult->mInIsolatedMozBrowser) && + ReadParam(aReader, &aResult->mPrivateBrowsingId) && + ReadParam(aReader, &aResult->mUserContextId) && + ReadParam(aReader, &aResult->mGeckoViewSessionContextId); } }; diff --git a/dom/security/featurepolicy/FeaturePolicyUtils.cpp b/dom/security/featurepolicy/FeaturePolicyUtils.cpp index a44fb1fed3df..1b2a383642cd 100644 --- a/dom/security/featurepolicy/FeaturePolicyUtils.cpp +++ b/dom/security/featurepolicy/FeaturePolicyUtils.cpp @@ -242,15 +242,15 @@ void FeaturePolicyUtils::ReportViolation(Document* aDocument, } // namespace dom namespace ipc { -void IPDLParamTraits::Write(IPC::Message* aMsg, +void IPDLParamTraits::Write(IPC::MessageWriter* aWriter, IProtocol* aActor, dom::FeaturePolicy* aParam) { if (!aParam) { - WriteIPDLParam(aMsg, aActor, false); + WriteIPDLParam(aWriter, aActor, false); return; } - WriteIPDLParam(aMsg, aActor, true); + WriteIPDLParam(aWriter, aActor, true); dom::FeaturePolicyInfo info; info.defaultOrigin() = aParam->DefaultOrigin(); @@ -263,15 +263,15 @@ void IPDLParamTraits::Write(IPC::Message* aMsg, info.attributeEnabledFeatureNames() = aParam->AttributeEnabledFeatureNames().Clone(); - WriteIPDLParam(aMsg, aActor, info); + WriteIPDLParam(aWriter, aActor, info); } bool IPDLParamTraits::Read( - const IPC::Message* aMsg, PickleIterator* aIter, IProtocol* aActor, + IPC::MessageReader* aReader, IProtocol* aActor, RefPtr* aResult) { *aResult = nullptr; bool notnull = false; - if (!ReadIPDLParam(aMsg, aIter, aActor, ¬null)) { + if (!ReadIPDLParam(aReader, aActor, ¬null)) { return false; } @@ -280,7 +280,7 @@ bool IPDLParamTraits::Read( } dom::FeaturePolicyInfo info; - if (!ReadIPDLParam(aMsg, aIter, aActor, &info)) { + if (!ReadIPDLParam(aReader, aActor, &info)) { return false; } diff --git a/dom/security/featurepolicy/FeaturePolicyUtils.h b/dom/security/featurepolicy/FeaturePolicyUtils.h index 9491f784698e..380806433d67 100644 --- a/dom/security/featurepolicy/FeaturePolicyUtils.h +++ b/dom/security/featurepolicy/FeaturePolicyUtils.h @@ -80,10 +80,9 @@ struct IPDLParamTraits; template <> struct IPDLParamTraits { - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, mozilla::dom::FeaturePolicy* aParam); - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, RefPtr* aResult); }; } // namespace ipc diff --git a/extensions/permissions/PermissionDelegateIPCUtils.h b/extensions/permissions/PermissionDelegateIPCUtils.h index 9553e3c1791d..c570a587f58f 100644 --- a/extensions/permissions/PermissionDelegateIPCUtils.h +++ b/extensions/permissions/PermissionDelegateIPCUtils.h @@ -18,16 +18,15 @@ struct ParamTraits< mozilla::PermissionDelegateHandler::DelegatedPermissionList> { typedef mozilla::PermissionDelegateHandler::DelegatedPermissionList paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { for (auto& permission : aParam.mPermissions) { - WriteParam(aMsg, permission); + WriteParam(aWriter, permission); } } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { for (auto& permission : aResult->mPermissions) { - if (!ReadParam(aMsg, aIter, &permission)) { + if (!ReadParam(aReader, &permission)) { return false; } } diff --git a/gfx/ipc/D3DMessageUtils.cpp b/gfx/ipc/D3DMessageUtils.cpp index 11c615ed0310..0d18d2ed00a5 100644 --- a/gfx/ipc/D3DMessageUtils.cpp +++ b/gfx/ipc/D3DMessageUtils.cpp @@ -27,40 +27,39 @@ const DXGI_ADAPTER_DESC& DxgiAdapterDesc::ToDesc() const { namespace IPC { -void ParamTraits::Write(Message* aMsg, +void ParamTraits::Write(MessageWriter* aWriter, const paramType& aParam) { #if defined(XP_WIN) - aMsg->WriteBytes(aParam.Description, sizeof(aParam.Description)); - WriteParam(aMsg, aParam.VendorId); - WriteParam(aMsg, aParam.DeviceId); - WriteParam(aMsg, aParam.SubSysId); - WriteParam(aMsg, aParam.Revision); - WriteParam(aMsg, aParam.DedicatedVideoMemory); - WriteParam(aMsg, aParam.DedicatedSystemMemory); - WriteParam(aMsg, aParam.SharedSystemMemory); - WriteParam(aMsg, aParam.AdapterLuid.LowPart); - WriteParam(aMsg, aParam.AdapterLuid.HighPart); + aWriter->WriteBytes(aParam.Description, sizeof(aParam.Description)); + WriteParam(aWriter, aParam.VendorId); + WriteParam(aWriter, aParam.DeviceId); + WriteParam(aWriter, aParam.SubSysId); + WriteParam(aWriter, aParam.Revision); + WriteParam(aWriter, aParam.DedicatedVideoMemory); + WriteParam(aWriter, aParam.DedicatedSystemMemory); + WriteParam(aWriter, aParam.SharedSystemMemory); + WriteParam(aWriter, aParam.AdapterLuid.LowPart); + WriteParam(aWriter, aParam.AdapterLuid.HighPart); #endif } -bool ParamTraits::Read(const Message* aMsg, - PickleIterator* aIter, +bool ParamTraits::Read(MessageReader* aReader, paramType* aResult) { #if defined(XP_WIN) - if (!aMsg->ReadBytesInto(aIter, aResult->Description, - sizeof(aResult->Description))) { + if (!aReader->ReadBytesInto(aResult->Description, + sizeof(aResult->Description))) { return false; } - if (ReadParam(aMsg, aIter, &aResult->VendorId) && - ReadParam(aMsg, aIter, &aResult->DeviceId) && - ReadParam(aMsg, aIter, &aResult->SubSysId) && - ReadParam(aMsg, aIter, &aResult->Revision) && - ReadParam(aMsg, aIter, &aResult->DedicatedVideoMemory) && - ReadParam(aMsg, aIter, &aResult->DedicatedSystemMemory) && - ReadParam(aMsg, aIter, &aResult->SharedSystemMemory) && - ReadParam(aMsg, aIter, &aResult->AdapterLuid.LowPart) && - ReadParam(aMsg, aIter, &aResult->AdapterLuid.HighPart)) { + if (ReadParam(aReader, &aResult->VendorId) && + ReadParam(aReader, &aResult->DeviceId) && + ReadParam(aReader, &aResult->SubSysId) && + ReadParam(aReader, &aResult->Revision) && + ReadParam(aReader, &aResult->DedicatedVideoMemory) && + ReadParam(aReader, &aResult->DedicatedSystemMemory) && + ReadParam(aReader, &aResult->SharedSystemMemory) && + ReadParam(aReader, &aResult->AdapterLuid.LowPart) && + ReadParam(aReader, &aResult->AdapterLuid.HighPart)) { return true; } return false; diff --git a/gfx/ipc/D3DMessageUtils.h b/gfx/ipc/D3DMessageUtils.h index ef10785e1575..60f4d244528f 100644 --- a/gfx/ipc/D3DMessageUtils.h +++ b/gfx/ipc/D3DMessageUtils.h @@ -37,9 +37,8 @@ namespace IPC { template <> struct ParamTraits { typedef DxgiAdapterDesc paramType; - static void Write(Message* aMsg, const paramType& aParam); - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult); + static void Write(MessageWriter* aWriter, const paramType& aParam); + static bool Read(MessageReader* aReader, paramType* aResult); }; } // namespace IPC diff --git a/gfx/ipc/GfxMessageUtils.h b/gfx/ipc/GfxMessageUtils.h index 4668533fc34b..92da56d70ca7 100644 --- a/gfx/ipc/GfxMessageUtils.h +++ b/gfx/ipc/GfxMessageUtils.h @@ -48,23 +48,21 @@ template <> struct ParamTraits { typedef mozilla::gfx::Matrix paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam._11); - WriteParam(aMsg, aParam._12); - WriteParam(aMsg, aParam._21); - WriteParam(aMsg, aParam._22); - WriteParam(aMsg, aParam._31); - WriteParam(aMsg, aParam._32); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam._11); + WriteParam(aWriter, aParam._12); + WriteParam(aWriter, aParam._21); + WriteParam(aWriter, aParam._22); + WriteParam(aWriter, aParam._31); + WriteParam(aWriter, aParam._32); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (ReadParam(aMsg, aIter, &aResult->_11) && - ReadParam(aMsg, aIter, &aResult->_12) && - ReadParam(aMsg, aIter, &aResult->_21) && - ReadParam(aMsg, aIter, &aResult->_22) && - ReadParam(aMsg, aIter, &aResult->_31) && - ReadParam(aMsg, aIter, &aResult->_32)) + static bool Read(MessageReader* aReader, paramType* aResult) { + if (ReadParam(aReader, &aResult->_11) && + ReadParam(aReader, &aResult->_12) && + ReadParam(aReader, &aResult->_21) && + ReadParam(aReader, &aResult->_22) && + ReadParam(aReader, &aResult->_31) && ReadParam(aReader, &aResult->_32)) return true; return false; @@ -81,8 +79,8 @@ template <> struct ParamTraits { typedef mozilla::gfx::Matrix4x4 paramType; - static void Write(Message* msg, const paramType& param) { -#define Wr(_f) WriteParam(msg, param._f) + static void Write(MessageWriter* writer, const paramType& param) { +#define Wr(_f) WriteParam(writer, param._f) Wr(_11); Wr(_12); Wr(_13); @@ -102,9 +100,8 @@ struct ParamTraits { #undef Wr } - static bool Read(const Message* msg, PickleIterator* iter, - paramType* result) { -#define Rd(_f) ReadParam(msg, iter, &result->_f) + static bool Read(MessageReader* reader, paramType* result) { +#define Rd(_f) ReadParam(reader, &result->_f) return (Rd(_11) && Rd(_12) && Rd(_13) && Rd(_14) && Rd(_21) && Rd(_22) && Rd(_23) && Rd(_24) && Rd(_31) && Rd(_32) && Rd(_33) && Rd(_34) && Rd(_41) && Rd(_42) && Rd(_43) && Rd(_44)); @@ -116,8 +113,8 @@ template <> struct ParamTraits { typedef mozilla::gfx::Matrix5x4 paramType; - static void Write(Message* msg, const paramType& param) { -#define Wr(_f) WriteParam(msg, param._f) + static void Write(MessageWriter* writer, const paramType& param) { +#define Wr(_f) WriteParam(writer, param._f) Wr(_11); Wr(_12); Wr(_13); @@ -141,9 +138,8 @@ struct ParamTraits { #undef Wr } - static bool Read(const Message* msg, PickleIterator* iter, - paramType* result) { -#define Rd(_f) ReadParam(msg, iter, &result->_f) + static bool Read(MessageReader* reader, paramType* result) { +#define Rd(_f) ReadParam(reader, &result->_f) return (Rd(_11) && Rd(_12) && Rd(_13) && Rd(_14) && Rd(_21) && Rd(_22) && Rd(_23) && Rd(_24) && Rd(_31) && Rd(_32) && Rd(_33) && Rd(_34) && Rd(_41) && Rd(_42) && Rd(_43) && Rd(_44) && Rd(_51) && Rd(_52) && @@ -156,15 +152,13 @@ template <> struct ParamTraits { typedef gfxPoint paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.x); - WriteParam(aMsg, aParam.y); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.x); + WriteParam(aWriter, aParam.y); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return (ReadParam(aMsg, aIter, &aResult->x) && - ReadParam(aMsg, aIter, &aResult->y)); + static bool Read(MessageReader* aReader, paramType* aResult) { + return (ReadParam(aReader, &aResult->x) && ReadParam(aReader, &aResult->y)); } }; @@ -172,15 +166,14 @@ template <> struct ParamTraits { typedef gfxSize paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.width); - WriteParam(aMsg, aParam.height); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.width); + WriteParam(aWriter, aParam.height); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (ReadParam(aMsg, aIter, &aResult->width) && - ReadParam(aMsg, aIter, &aResult->height)) + static bool Read(MessageReader* aReader, paramType* aResult) { + if (ReadParam(aReader, &aResult->width) && + ReadParam(aReader, &aResult->height)) return true; return false; @@ -191,22 +184,21 @@ template <> struct ParamTraits { typedef gfxRect paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.X()); - WriteParam(aMsg, aParam.Y()); - WriteParam(aMsg, aParam.Width()); - WriteParam(aMsg, aParam.Height()); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.X()); + WriteParam(aWriter, aParam.Y()); + WriteParam(aWriter, aParam.Width()); + WriteParam(aWriter, aParam.Height()); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { auto x = aResult->X(); auto y = aResult->Y(); auto w = aResult->Width(); auto h = aResult->Height(); - bool retVal = (ReadParam(aMsg, aIter, &x) && ReadParam(aMsg, aIter, &y) && - ReadParam(aMsg, aIter, &w) && ReadParam(aMsg, aIter, &h)); + bool retVal = (ReadParam(aReader, &x) && ReadParam(aReader, &y) && + ReadParam(aReader, &w) && ReadParam(aReader, &h)); aResult->SetRect(x, y, w, h); return retVal; } @@ -286,18 +278,16 @@ template <> struct ParamTraits { typedef mozilla::gfx::sRGBColor paramType; - static void Write(Message* msg, const paramType& param) { - WriteParam(msg, param.r); - WriteParam(msg, param.g); - WriteParam(msg, param.b); - WriteParam(msg, param.a); + static void Write(MessageWriter* writer, const paramType& param) { + WriteParam(writer, param.r); + WriteParam(writer, param.g); + WriteParam(writer, param.b); + WriteParam(writer, param.a); } - static bool Read(const Message* msg, PickleIterator* iter, - paramType* result) { - return ( - ReadParam(msg, iter, &result->r) && ReadParam(msg, iter, &result->g) && - ReadParam(msg, iter, &result->b) && ReadParam(msg, iter, &result->a)); + static bool Read(MessageReader* reader, paramType* result) { + return (ReadParam(reader, &result->r) && ReadParam(reader, &result->g) && + ReadParam(reader, &result->b) && ReadParam(reader, &result->a)); } }; @@ -305,18 +295,16 @@ template <> struct ParamTraits { typedef mozilla::gfx::DeviceColor paramType; - static void Write(Message* msg, const paramType& param) { - WriteParam(msg, param.r); - WriteParam(msg, param.g); - WriteParam(msg, param.b); - WriteParam(msg, param.a); + static void Write(MessageWriter* writer, const paramType& param) { + WriteParam(writer, param.r); + WriteParam(writer, param.g); + WriteParam(writer, param.b); + WriteParam(writer, param.a); } - static bool Read(const Message* msg, PickleIterator* iter, - paramType* result) { - return ( - ReadParam(msg, iter, &result->r) && ReadParam(msg, iter, &result->g) && - ReadParam(msg, iter, &result->b) && ReadParam(msg, iter, &result->a)); + static bool Read(MessageReader* reader, paramType* result) { + return (ReadParam(reader, &result->r) && ReadParam(reader, &result->g) && + ReadParam(reader, &result->b) && ReadParam(reader, &result->a)); } }; @@ -324,15 +312,13 @@ template <> struct ParamTraits { typedef nsPoint paramType; - static void Write(Message* msg, const paramType& param) { - WriteParam(msg, param.x); - WriteParam(msg, param.y); + static void Write(MessageWriter* writer, const paramType& param) { + WriteParam(writer, param.x); + WriteParam(writer, param.y); } - static bool Read(const Message* msg, PickleIterator* iter, - paramType* result) { - return (ReadParam(msg, iter, &result->x) && - ReadParam(msg, iter, &result->y)); + static bool Read(MessageReader* reader, paramType* result) { + return (ReadParam(reader, &result->x) && ReadParam(reader, &result->y)); } }; @@ -340,15 +326,13 @@ template <> struct ParamTraits { typedef nsIntPoint paramType; - static void Write(Message* msg, const paramType& param) { - WriteParam(msg, param.x); - WriteParam(msg, param.y); + static void Write(MessageWriter* writer, const paramType& param) { + WriteParam(writer, param.x); + WriteParam(writer, param.y); } - static bool Read(const Message* msg, PickleIterator* iter, - paramType* result) { - return (ReadParam(msg, iter, &result->x) && - ReadParam(msg, iter, &result->y)); + static bool Read(MessageReader* reader, paramType* result) { + return (ReadParam(reader, &result->x) && ReadParam(reader, &result->y)); } }; @@ -356,15 +340,14 @@ template struct ParamTraits> { typedef mozilla::gfx::IntSizeTyped paramType; - static void Write(Message* msg, const paramType& param) { - WriteParam(msg, param.width); - WriteParam(msg, param.height); + static void Write(MessageWriter* writer, const paramType& param) { + WriteParam(writer, param.width); + WriteParam(writer, param.height); } - static bool Read(const Message* msg, PickleIterator* iter, - paramType* result) { - return (ReadParam(msg, iter, &result->width) && - ReadParam(msg, iter, &result->height)); + static bool Read(MessageReader* reader, paramType* result) { + return (ReadParam(reader, &result->width) && + ReadParam(reader, &result->height)); } }; @@ -372,22 +355,21 @@ template struct RegionParamTraits { typedef Region paramType; - static void Write(Message* msg, const paramType& param) { + static void Write(MessageWriter* writer, const paramType& param) { for (auto iter = param.RectIter(); !iter.Done(); iter.Next()) { const Rect& r = iter.Get(); MOZ_RELEASE_ASSERT(!r.IsEmpty(), "GFX: rect is empty."); - WriteParam(msg, r); + WriteParam(writer, r); } // empty rects are sentinel values because nsRegions will never // contain them - WriteParam(msg, Rect()); + WriteParam(writer, Rect()); } - static bool Read(const Message* msg, PickleIterator* iter, - paramType* result) { + static bool Read(MessageReader* reader, paramType* result) { RegionBuilder builder; Rect rect; - while (ReadParam(msg, iter, &rect)) { + while (ReadParam(reader, &rect)) { if (rect.IsEmpty()) { *result = builder.ToRegion(); return true; @@ -410,15 +392,14 @@ template <> struct ParamTraits { typedef mozilla::gfx::IntSize paramType; - static void Write(Message* msg, const paramType& param) { - WriteParam(msg, param.width); - WriteParam(msg, param.height); + static void Write(MessageWriter* writer, const paramType& param) { + WriteParam(writer, param.width); + WriteParam(writer, param.height); } - static bool Read(const Message* msg, PickleIterator* iter, - paramType* result) { - return (ReadParam(msg, iter, &result->width) && - ReadParam(msg, iter, &result->height)); + static bool Read(MessageReader* reader, paramType* result) { + return (ReadParam(reader, &result->width) && + ReadParam(reader, &result->height)); } }; @@ -426,13 +407,12 @@ template struct ParamTraits> { typedef mozilla::gfx::CoordTyped paramType; - static void Write(Message* msg, const paramType& param) { - WriteParam(msg, param.value); + static void Write(MessageWriter* writer, const paramType& param) { + WriteParam(writer, param.value); } - static bool Read(const Message* msg, PickleIterator* iter, - paramType* result) { - return (ReadParam(msg, iter, &result->value)); + static bool Read(MessageReader* reader, paramType* result) { + return (ReadParam(reader, &result->value)); } }; @@ -440,13 +420,12 @@ template struct ParamTraits> { typedef mozilla::gfx::IntCoordTyped paramType; - static void Write(Message* msg, const paramType& param) { - WriteParam(msg, param.value); + static void Write(MessageWriter* writer, const paramType& param) { + WriteParam(writer, param.value); } - static bool Read(const Message* msg, PickleIterator* iter, - paramType* result) { - return (ReadParam(msg, iter, &result->value)); + static bool Read(MessageReader* reader, paramType* result) { + return (ReadParam(reader, &result->value)); } }; @@ -454,13 +433,12 @@ template struct ParamTraits> { typedef mozilla::gfx::ScaleFactor paramType; - static void Write(Message* msg, const paramType& param) { - WriteParam(msg, param.scale); + static void Write(MessageWriter* writer, const paramType& param) { + WriteParam(writer, param.scale); } - static bool Read(const Message* msg, PickleIterator* iter, - paramType* result) { - return (ReadParam(msg, iter, &result->scale)); + static bool Read(MessageReader* reader, paramType* result) { + return (ReadParam(reader, &result->scale)); } }; @@ -468,15 +446,14 @@ template struct ParamTraits> { typedef mozilla::gfx::ScaleFactors2D paramType; - static void Write(Message* msg, const paramType& param) { - WriteParam(msg, param.xScale); - WriteParam(msg, param.yScale); + static void Write(MessageWriter* writer, const paramType& param) { + WriteParam(writer, param.xScale); + WriteParam(writer, param.yScale); } - static bool Read(const Message* msg, PickleIterator* iter, - paramType* result) { - return (ReadParam(msg, iter, &result->xScale) && - ReadParam(msg, iter, &result->yScale)); + static bool Read(MessageReader* reader, paramType* result) { + return (ReadParam(reader, &result->xScale) && + ReadParam(reader, &result->yScale)); } }; @@ -484,15 +461,13 @@ template struct ParamTraits> { typedef mozilla::gfx::PointTyped paramType; - static void Write(Message* msg, const paramType& param) { - WriteParam(msg, param.x); - WriteParam(msg, param.y); + static void Write(MessageWriter* writer, const paramType& param) { + WriteParam(writer, param.x); + WriteParam(writer, param.y); } - static bool Read(const Message* msg, PickleIterator* iter, - paramType* result) { - return (ReadParam(msg, iter, &result->x) && - ReadParam(msg, iter, &result->y)); + static bool Read(MessageReader* reader, paramType* result) { + return (ReadParam(reader, &result->x) && ReadParam(reader, &result->y)); } }; @@ -500,17 +475,15 @@ template struct ParamTraits> { typedef mozilla::gfx::Point3DTyped paramType; - static void Write(Message* msg, const paramType& param) { - WriteParam(msg, param.x); - WriteParam(msg, param.y); - WriteParam(msg, param.z); + static void Write(MessageWriter* writer, const paramType& param) { + WriteParam(writer, param.x); + WriteParam(writer, param.y); + WriteParam(writer, param.z); } - static bool Read(const Message* msg, PickleIterator* iter, - paramType* result) { - return (ReadParam(msg, iter, &result->x) && - ReadParam(msg, iter, &result->y) && - ReadParam(msg, iter, &result->z)); + static bool Read(MessageReader* reader, paramType* result) { + return (ReadParam(reader, &result->x) && ReadParam(reader, &result->y) && + ReadParam(reader, &result->z)); } }; @@ -518,15 +491,13 @@ template struct ParamTraits> { typedef mozilla::gfx::IntPointTyped paramType; - static void Write(Message* msg, const paramType& param) { - WriteParam(msg, param.x); - WriteParam(msg, param.y); + static void Write(MessageWriter* writer, const paramType& param) { + WriteParam(writer, param.x); + WriteParam(writer, param.y); } - static bool Read(const Message* msg, PickleIterator* iter, - paramType* result) { - return (ReadParam(msg, iter, &result->x) && - ReadParam(msg, iter, &result->y)); + static bool Read(MessageReader* reader, paramType* result) { + return (ReadParam(reader, &result->x) && ReadParam(reader, &result->y)); } }; @@ -534,15 +505,14 @@ template struct ParamTraits> { typedef mozilla::gfx::SizeTyped paramType; - static void Write(Message* msg, const paramType& param) { - WriteParam(msg, param.width); - WriteParam(msg, param.height); + static void Write(MessageWriter* writer, const paramType& param) { + WriteParam(writer, param.width); + WriteParam(writer, param.height); } - static bool Read(const Message* msg, PickleIterator* iter, - paramType* result) { - return (ReadParam(msg, iter, &result->width) && - ReadParam(msg, iter, &result->height)); + static bool Read(MessageReader* reader, paramType* result) { + return (ReadParam(reader, &result->width) && + ReadParam(reader, &result->height)); } }; @@ -550,22 +520,21 @@ template struct ParamTraits> { typedef mozilla::gfx::RectTyped paramType; - static void Write(Message* msg, const paramType& param) { - WriteParam(msg, param.X()); - WriteParam(msg, param.Y()); - WriteParam(msg, param.Width()); - WriteParam(msg, param.Height()); + static void Write(MessageWriter* writer, const paramType& param) { + WriteParam(writer, param.X()); + WriteParam(writer, param.Y()); + WriteParam(writer, param.Width()); + WriteParam(writer, param.Height()); } - static bool Read(const Message* msg, PickleIterator* iter, - paramType* result) { + static bool Read(MessageReader* reader, paramType* result) { auto x = result->X(); auto y = result->Y(); auto w = result->Width(); auto h = result->Height(); - bool retVal = (ReadParam(msg, iter, &x) && ReadParam(msg, iter, &y) && - ReadParam(msg, iter, &w) && ReadParam(msg, iter, &h)); + bool retVal = (ReadParam(reader, &x) && ReadParam(reader, &y) && + ReadParam(reader, &w) && ReadParam(reader, &h)); result->SetRect(x, y, w, h); return retVal; } @@ -575,22 +544,21 @@ template struct ParamTraits> { typedef mozilla::gfx::RectAbsoluteTyped paramType; - static void Write(Message* msg, const paramType& param) { - WriteParam(msg, param.Left()); - WriteParam(msg, param.Top()); - WriteParam(msg, param.Right()); - WriteParam(msg, param.Bottom()); + static void Write(MessageWriter* writer, const paramType& param) { + WriteParam(writer, param.Left()); + WriteParam(writer, param.Top()); + WriteParam(writer, param.Right()); + WriteParam(writer, param.Bottom()); } - static bool Read(const Message* msg, PickleIterator* iter, - paramType* result) { + static bool Read(MessageReader* reader, paramType* result) { auto l = result->Left(); auto t = result->Top(); auto r = result->Right(); auto b = result->Bottom(); - bool retVal = (ReadParam(msg, iter, &l) && ReadParam(msg, iter, &t) && - ReadParam(msg, iter, &r) && ReadParam(msg, iter, &b)); + bool retVal = (ReadParam(reader, &l) && ReadParam(reader, &t) && + ReadParam(reader, &r) && ReadParam(reader, &b)); result->SetBox(l, t, r, b); return retVal; } @@ -600,22 +568,21 @@ template struct ParamTraits> { typedef mozilla::gfx::IntRectTyped paramType; - static void Write(Message* msg, const paramType& param) { - WriteParam(msg, param.X()); - WriteParam(msg, param.Y()); - WriteParam(msg, param.Width()); - WriteParam(msg, param.Height()); + static void Write(MessageWriter* writer, const paramType& param) { + WriteParam(writer, param.X()); + WriteParam(writer, param.Y()); + WriteParam(writer, param.Width()); + WriteParam(writer, param.Height()); } - static bool Read(const Message* msg, PickleIterator* iter, - paramType* result) { + static bool Read(MessageReader* reader, paramType* result) { auto x = result->X(); auto y = result->Y(); auto w = result->Width(); auto h = result->Height(); - bool retVal = (ReadParam(msg, iter, &x) && ReadParam(msg, iter, &y) && - ReadParam(msg, iter, &w) && ReadParam(msg, iter, &h)); + bool retVal = (ReadParam(reader, &x) && ReadParam(reader, &y) && + ReadParam(reader, &w) && ReadParam(reader, &h)); result->SetRect(x, y, w, h); return retVal; } @@ -625,19 +592,17 @@ template <> struct ParamTraits { typedef mozilla::gfx::Margin paramType; - static void Write(Message* msg, const paramType& param) { - WriteParam(msg, param.top); - WriteParam(msg, param.right); - WriteParam(msg, param.bottom); - WriteParam(msg, param.left); + static void Write(MessageWriter* writer, const paramType& param) { + WriteParam(writer, param.top); + WriteParam(writer, param.right); + WriteParam(writer, param.bottom); + WriteParam(writer, param.left); } - static bool Read(const Message* msg, PickleIterator* iter, - paramType* result) { - return (ReadParam(msg, iter, &result->top) && - ReadParam(msg, iter, &result->right) && - ReadParam(msg, iter, &result->bottom) && - ReadParam(msg, iter, &result->left)); + static bool Read(MessageReader* reader, paramType* result) { + return ( + ReadParam(reader, &result->top) && ReadParam(reader, &result->right) && + ReadParam(reader, &result->bottom) && ReadParam(reader, &result->left)); } }; @@ -645,19 +610,17 @@ template struct ParamTraits> { typedef mozilla::gfx::MarginTyped paramType; - static void Write(Message* msg, const paramType& param) { - WriteParam(msg, param.top); - WriteParam(msg, param.right); - WriteParam(msg, param.bottom); - WriteParam(msg, param.left); + static void Write(MessageWriter* writer, const paramType& param) { + WriteParam(writer, param.top); + WriteParam(writer, param.right); + WriteParam(writer, param.bottom); + WriteParam(writer, param.left); } - static bool Read(const Message* msg, PickleIterator* iter, - paramType* result) { - return (ReadParam(msg, iter, &result->top) && - ReadParam(msg, iter, &result->right) && - ReadParam(msg, iter, &result->bottom) && - ReadParam(msg, iter, &result->left)); + static bool Read(MessageReader* reader, paramType* result) { + return ( + ReadParam(reader, &result->top) && ReadParam(reader, &result->right) && + ReadParam(reader, &result->bottom) && ReadParam(reader, &result->left)); } }; @@ -665,19 +628,17 @@ template struct ParamTraits> { typedef mozilla::gfx::IntMarginTyped paramType; - static void Write(Message* msg, const paramType& param) { - WriteParam(msg, param.top); - WriteParam(msg, param.right); - WriteParam(msg, param.bottom); - WriteParam(msg, param.left); + static void Write(MessageWriter* writer, const paramType& param) { + WriteParam(writer, param.top); + WriteParam(writer, param.right); + WriteParam(writer, param.bottom); + WriteParam(writer, param.left); } - static bool Read(const Message* msg, PickleIterator* iter, - paramType* result) { - return (ReadParam(msg, iter, &result->top) && - ReadParam(msg, iter, &result->right) && - ReadParam(msg, iter, &result->bottom) && - ReadParam(msg, iter, &result->left)); + static bool Read(MessageReader* reader, paramType* result) { + return ( + ReadParam(reader, &result->top) && ReadParam(reader, &result->right) && + ReadParam(reader, &result->bottom) && ReadParam(reader, &result->left)); } }; @@ -685,21 +646,20 @@ template <> struct ParamTraits { typedef nsRect paramType; - static void Write(Message* msg, const paramType& param) { - WriteParam(msg, param.X()); - WriteParam(msg, param.Y()); - WriteParam(msg, param.Width()); - WriteParam(msg, param.Height()); + static void Write(MessageWriter* writer, const paramType& param) { + WriteParam(writer, param.X()); + WriteParam(writer, param.Y()); + WriteParam(writer, param.Width()); + WriteParam(writer, param.Height()); } - static bool Read(const Message* msg, PickleIterator* iter, - paramType* result) { + static bool Read(MessageReader* reader, paramType* result) { auto x = result->X(); auto y = result->Y(); auto w = result->Width(); auto h = result->Height(); - bool retVal = (ReadParam(msg, iter, &x) && ReadParam(msg, iter, &y) && - ReadParam(msg, iter, &w) && ReadParam(msg, iter, &h)); + bool retVal = (ReadParam(reader, &x) && ReadParam(reader, &y) && + ReadParam(reader, &w) && ReadParam(reader, &h)); result->SetRect(x, y, w, h); return retVal; } @@ -761,61 +721,48 @@ template <> struct ParamTraits { typedef mozilla::gfx::EmptyAttributes paramType; - static void Write(Message* aMsg, const paramType& aParam) {} + static void Write(MessageWriter* aWriter, const paramType& aParam) {} - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return true; - } + static bool Read(MessageReader* aReader, paramType* aResult) { return true; } }; template <> struct ParamTraits { typedef mozilla::gfx::MergeAttributes paramType; - static void Write(Message* aMsg, const paramType& aParam) {} + static void Write(MessageWriter* aWriter, const paramType& aParam) {} - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return true; - } + static bool Read(MessageReader* aReader, paramType* aResult) { return true; } }; template <> struct ParamTraits { typedef mozilla::gfx::ToAlphaAttributes paramType; - static void Write(Message* aMsg, const paramType& aParam) {} + static void Write(MessageWriter* aWriter, const paramType& aParam) {} - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return true; - } + static bool Read(MessageReader* aReader, paramType* aResult) { return true; } }; template <> struct ParamTraits { typedef mozilla::gfx::TileAttributes paramType; - static void Write(Message* aMsg, const paramType& aParam) {} + static void Write(MessageWriter* aWriter, const paramType& aParam) {} - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return true; - } + static bool Read(MessageReader* aReader, paramType* aResult) { return true; } }; template <> struct ParamTraits { typedef mozilla::gfx::BlendAttributes paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mBlendMode); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mBlendMode); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mBlendMode); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mBlendMode); } }; @@ -823,15 +770,14 @@ template <> struct ParamTraits { typedef mozilla::gfx::MorphologyAttributes paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mOperator); - WriteParam(aMsg, aParam.mRadii); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mOperator); + WriteParam(aWriter, aParam.mRadii); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &aResult->mOperator) || - !ReadParam(aMsg, aIter, &aResult->mRadii)) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &aResult->mOperator) || + !ReadParam(aReader, &aResult->mRadii)) { return false; } return true; @@ -842,13 +788,12 @@ template <> struct ParamTraits { typedef mozilla::gfx::FloodAttributes paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mColor); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mColor); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &aResult->mColor)) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &aResult->mColor)) { return false; } return true; @@ -859,13 +804,12 @@ template <> struct ParamTraits { typedef mozilla::gfx::OpacityAttributes paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mOpacity); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mOpacity); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &aResult->mOpacity)) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &aResult->mOpacity)) { return false; } return true; @@ -876,13 +820,12 @@ template <> struct ParamTraits { typedef mozilla::gfx::OffsetAttributes paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mValue); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mValue); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &aResult->mValue)) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &aResult->mValue)) { return false; } return true; @@ -893,17 +836,16 @@ template <> struct ParamTraits { typedef mozilla::gfx::DisplacementMapAttributes paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mScale); - WriteParam(aMsg, aParam.mXChannel); - WriteParam(aMsg, aParam.mYChannel); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mScale); + WriteParam(aWriter, aParam.mXChannel); + WriteParam(aWriter, aParam.mYChannel); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &aResult->mScale) || - !ReadParam(aMsg, aIter, &aResult->mXChannel) || - !ReadParam(aMsg, aIter, &aResult->mYChannel)) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &aResult->mScale) || + !ReadParam(aReader, &aResult->mXChannel) || + !ReadParam(aReader, &aResult->mYChannel)) { return false; } return true; @@ -914,23 +856,22 @@ template <> struct ParamTraits { typedef mozilla::gfx::TurbulenceAttributes paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mOffset); - WriteParam(aMsg, aParam.mBaseFrequency); - WriteParam(aMsg, aParam.mSeed); - WriteParam(aMsg, aParam.mOctaves); - WriteParam(aMsg, aParam.mStitchable); - WriteParam(aMsg, aParam.mType); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mOffset); + WriteParam(aWriter, aParam.mBaseFrequency); + WriteParam(aWriter, aParam.mSeed); + WriteParam(aWriter, aParam.mOctaves); + WriteParam(aWriter, aParam.mStitchable); + WriteParam(aWriter, aParam.mType); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &aResult->mOffset) || - !ReadParam(aMsg, aIter, &aResult->mBaseFrequency) || - !ReadParam(aMsg, aIter, &aResult->mSeed) || - !ReadParam(aMsg, aIter, &aResult->mOctaves) || - !ReadParam(aMsg, aIter, &aResult->mStitchable) || - !ReadParam(aMsg, aIter, &aResult->mType)) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &aResult->mOffset) || + !ReadParam(aReader, &aResult->mBaseFrequency) || + !ReadParam(aReader, &aResult->mSeed) || + !ReadParam(aReader, &aResult->mOctaves) || + !ReadParam(aReader, &aResult->mStitchable) || + !ReadParam(aReader, &aResult->mType)) { return false; } return true; @@ -941,17 +882,16 @@ template <> struct ParamTraits { typedef mozilla::gfx::ImageAttributes paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mFilter); - WriteParam(aMsg, aParam.mInputIndex); - WriteParam(aMsg, aParam.mTransform); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mFilter); + WriteParam(aWriter, aParam.mInputIndex); + WriteParam(aWriter, aParam.mTransform); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &aResult->mFilter) || - !ReadParam(aMsg, aIter, &aResult->mInputIndex) || - !ReadParam(aMsg, aIter, &aResult->mTransform)) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &aResult->mFilter) || + !ReadParam(aReader, &aResult->mInputIndex) || + !ReadParam(aReader, &aResult->mTransform)) { return false; } return true; @@ -962,13 +902,12 @@ template <> struct ParamTraits { typedef mozilla::gfx::GaussianBlurAttributes paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mStdDeviation); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mStdDeviation); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &aResult->mStdDeviation)) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &aResult->mStdDeviation)) { return false; } return true; @@ -979,17 +918,16 @@ template <> struct ParamTraits { typedef mozilla::gfx::DropShadowAttributes paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mStdDeviation); - WriteParam(aMsg, aParam.mOffset); - WriteParam(aMsg, aParam.mColor); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mStdDeviation); + WriteParam(aWriter, aParam.mOffset); + WriteParam(aWriter, aParam.mColor); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &aResult->mStdDeviation) || - !ReadParam(aMsg, aIter, &aResult->mOffset) || - !ReadParam(aMsg, aIter, &aResult->mColor)) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &aResult->mStdDeviation) || + !ReadParam(aReader, &aResult->mOffset) || + !ReadParam(aReader, &aResult->mColor)) { return false; } return true; @@ -1000,15 +938,14 @@ template <> struct ParamTraits { typedef mozilla::gfx::ColorMatrixAttributes paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mType); - WriteParam(aMsg, aParam.mValues); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mType); + WriteParam(aWriter, aParam.mValues); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &aResult->mType) || - !ReadParam(aMsg, aIter, &aResult->mValues)) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &aResult->mType) || + !ReadParam(aReader, &aResult->mValues)) { return false; } return true; @@ -1019,24 +956,23 @@ template <> struct ParamTraits { typedef mozilla::gfx::ComponentTransferAttributes paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { for (int i = 0; i < 4; ++i) { - WriteParam(aMsg, aParam.mTypes[i]); + WriteParam(aWriter, aParam.mTypes[i]); } for (int i = 0; i < 4; ++i) { - WriteParam(aMsg, aParam.mValues[i]); + WriteParam(aWriter, aParam.mValues[i]); } } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { for (int i = 0; i < 4; ++i) { - if (!ReadParam(aMsg, aIter, &aResult->mTypes[i])) { + if (!ReadParam(aReader, &aResult->mTypes[i])) { return false; } } for (int i = 0; i < 4; ++i) { - if (!ReadParam(aMsg, aIter, &aResult->mValues[i])) { + if (!ReadParam(aReader, &aResult->mValues[i])) { return false; } } @@ -1048,27 +984,26 @@ template <> struct ParamTraits { typedef mozilla::gfx::ConvolveMatrixAttributes paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mKernelSize); - WriteParam(aMsg, aParam.mKernelMatrix); - WriteParam(aMsg, aParam.mDivisor); - WriteParam(aMsg, aParam.mBias); - WriteParam(aMsg, aParam.mTarget); - WriteParam(aMsg, aParam.mEdgeMode); - WriteParam(aMsg, aParam.mKernelUnitLength); - WriteParam(aMsg, aParam.mPreserveAlpha); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mKernelSize); + WriteParam(aWriter, aParam.mKernelMatrix); + WriteParam(aWriter, aParam.mDivisor); + WriteParam(aWriter, aParam.mBias); + WriteParam(aWriter, aParam.mTarget); + WriteParam(aWriter, aParam.mEdgeMode); + WriteParam(aWriter, aParam.mKernelUnitLength); + WriteParam(aWriter, aParam.mPreserveAlpha); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &aResult->mKernelSize) || - !ReadParam(aMsg, aIter, &aResult->mKernelMatrix) || - !ReadParam(aMsg, aIter, &aResult->mDivisor) || - !ReadParam(aMsg, aIter, &aResult->mBias) || - !ReadParam(aMsg, aIter, &aResult->mTarget) || - !ReadParam(aMsg, aIter, &aResult->mEdgeMode) || - !ReadParam(aMsg, aIter, &aResult->mKernelUnitLength) || - !ReadParam(aMsg, aIter, &aResult->mPreserveAlpha)) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &aResult->mKernelSize) || + !ReadParam(aReader, &aResult->mKernelMatrix) || + !ReadParam(aReader, &aResult->mDivisor) || + !ReadParam(aReader, &aResult->mBias) || + !ReadParam(aReader, &aResult->mTarget) || + !ReadParam(aReader, &aResult->mEdgeMode) || + !ReadParam(aReader, &aResult->mKernelUnitLength) || + !ReadParam(aReader, &aResult->mPreserveAlpha)) { return false; } return true; @@ -1079,25 +1014,24 @@ template <> struct ParamTraits { typedef mozilla::gfx::DiffuseLightingAttributes paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mLightType); - WriteParam(aMsg, aParam.mLightValues); - WriteParam(aMsg, aParam.mSurfaceScale); - WriteParam(aMsg, aParam.mKernelUnitLength); - WriteParam(aMsg, aParam.mColor); - WriteParam(aMsg, aParam.mLightingConstant); - WriteParam(aMsg, aParam.mSpecularExponent); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mLightType); + WriteParam(aWriter, aParam.mLightValues); + WriteParam(aWriter, aParam.mSurfaceScale); + WriteParam(aWriter, aParam.mKernelUnitLength); + WriteParam(aWriter, aParam.mColor); + WriteParam(aWriter, aParam.mLightingConstant); + WriteParam(aWriter, aParam.mSpecularExponent); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &aResult->mLightType) || - !ReadParam(aMsg, aIter, &aResult->mLightValues) || - !ReadParam(aMsg, aIter, &aResult->mSurfaceScale) || - !ReadParam(aMsg, aIter, &aResult->mKernelUnitLength) || - !ReadParam(aMsg, aIter, &aResult->mColor) || - !ReadParam(aMsg, aIter, &aResult->mLightingConstant) || - !ReadParam(aMsg, aIter, &aResult->mSpecularExponent)) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &aResult->mLightType) || + !ReadParam(aReader, &aResult->mLightValues) || + !ReadParam(aReader, &aResult->mSurfaceScale) || + !ReadParam(aReader, &aResult->mKernelUnitLength) || + !ReadParam(aReader, &aResult->mColor) || + !ReadParam(aReader, &aResult->mLightingConstant) || + !ReadParam(aReader, &aResult->mSpecularExponent)) { return false; } return true; @@ -1108,25 +1042,24 @@ template <> struct ParamTraits { typedef mozilla::gfx::SpecularLightingAttributes paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mLightType); - WriteParam(aMsg, aParam.mLightValues); - WriteParam(aMsg, aParam.mSurfaceScale); - WriteParam(aMsg, aParam.mKernelUnitLength); - WriteParam(aMsg, aParam.mColor); - WriteParam(aMsg, aParam.mLightingConstant); - WriteParam(aMsg, aParam.mSpecularExponent); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mLightType); + WriteParam(aWriter, aParam.mLightValues); + WriteParam(aWriter, aParam.mSurfaceScale); + WriteParam(aWriter, aParam.mKernelUnitLength); + WriteParam(aWriter, aParam.mColor); + WriteParam(aWriter, aParam.mLightingConstant); + WriteParam(aWriter, aParam.mSpecularExponent); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &aResult->mLightType) || - !ReadParam(aMsg, aIter, &aResult->mLightValues) || - !ReadParam(aMsg, aIter, &aResult->mSurfaceScale) || - !ReadParam(aMsg, aIter, &aResult->mKernelUnitLength) || - !ReadParam(aMsg, aIter, &aResult->mColor) || - !ReadParam(aMsg, aIter, &aResult->mLightingConstant) || - !ReadParam(aMsg, aIter, &aResult->mSpecularExponent)) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &aResult->mLightType) || + !ReadParam(aReader, &aResult->mLightValues) || + !ReadParam(aReader, &aResult->mSurfaceScale) || + !ReadParam(aReader, &aResult->mKernelUnitLength) || + !ReadParam(aReader, &aResult->mColor) || + !ReadParam(aReader, &aResult->mLightingConstant) || + !ReadParam(aReader, &aResult->mSpecularExponent)) { return false; } return true; @@ -1137,15 +1070,14 @@ template <> struct ParamTraits { typedef mozilla::gfx::CompositeAttributes paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mOperator); - WriteParam(aMsg, aParam.mCoefficients); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mOperator); + WriteParam(aWriter, aParam.mCoefficients); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &aResult->mOperator) || - !ReadParam(aMsg, aIter, &aResult->mCoefficients)) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &aResult->mOperator) || + !ReadParam(aReader, &aResult->mCoefficients)) { return false; } return true; @@ -1155,31 +1087,29 @@ struct ParamTraits { template <> struct ParamTraits { typedef mozilla::gfx::Glyph paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mIndex); - WriteParam(aMsg, aParam.mPosition); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mIndex); + WriteParam(aWriter, aParam.mPosition); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return (ReadParam(aMsg, aIter, &aResult->mIndex) && - ReadParam(aMsg, aIter, &aResult->mPosition)); + static bool Read(MessageReader* aReader, paramType* aResult) { + return (ReadParam(aReader, &aResult->mIndex) && + ReadParam(aReader, &aResult->mPosition)); } }; template struct ParamTraits> { typedef mozilla::Array paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { for (size_t i = 0; i < Length; i++) { - WriteParam(aMsg, aParam[i]); + WriteParam(aWriter, aParam[i]); } } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { for (size_t i = 0; i < Length; i++) { - if (!ReadParam(aMsg, aIter, &aResult->operator[](i))) { + if (!ReadParam(aReader, &aResult->operator[](i))) { return false; } } @@ -1200,34 +1130,35 @@ namespace ipc { template <> struct IPDLParamTraits { typedef mozilla::gfx::PaintFragment paramType; - static void Write(IPC::Message* aMsg, IProtocol* aActor, paramType&& aParam) { + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, + paramType&& aParam) { Shmem shmem; if (aParam.mSize.IsEmpty() || !aActor->AllocShmem(aParam.mRecording.mLen, SharedMemory::TYPE_BASIC, &shmem)) { - WriteParam(aMsg, gfx::IntSize(0, 0)); + WriteParam(aWriter, gfx::IntSize(0, 0)); return; } memcpy(shmem.get(), aParam.mRecording.mData, aParam.mRecording.mLen); - WriteParam(aMsg, aParam.mSize); - WriteIPDLParam(aMsg, aActor, std::move(shmem)); - WriteParam(aMsg, aParam.mDependencies); + WriteParam(aWriter, aParam.mSize); + WriteIPDLParam(aWriter, aActor, std::move(shmem)); + WriteParam(aWriter, aParam.mDependencies); } - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, paramType* aResult) { - if (!ReadParam(aMsg, aIter, &aResult->mSize)) { + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + paramType* aResult) { + if (!ReadParam(aReader, &aResult->mSize)) { return false; } if (aResult->mSize.IsEmpty()) { return true; } Shmem shmem; - if (!ReadIPDLParam(aMsg, aIter, aActor, &shmem) || - !ReadParam(aMsg, aIter, &aResult->mDependencies)) { + if (!ReadIPDLParam(aReader, aActor, &shmem) || + !ReadParam(aReader, &aResult->mDependencies)) { aActor->DeallocShmem(shmem); return false; } diff --git a/gfx/layers/apz/testutil/APZTestData.h b/gfx/layers/apz/testutil/APZTestData.h index 83d47478aa6e..e2bd1c4b2a81 100644 --- a/gfx/layers/apz/testutil/APZTestData.h +++ b/gfx/layers/apz/testutil/APZTestData.h @@ -180,21 +180,20 @@ template <> struct ParamTraits { typedef mozilla::layers::APZTestData paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mPaints); - WriteParam(aMsg, aParam.mRepaintRequests); - WriteParam(aMsg, aParam.mHitResults); - WriteParam(aMsg, aParam.mSampledResults); - WriteParam(aMsg, aParam.mAdditionalData); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mPaints); + WriteParam(aWriter, aParam.mRepaintRequests); + WriteParam(aWriter, aParam.mHitResults); + WriteParam(aWriter, aParam.mSampledResults); + WriteParam(aWriter, aParam.mAdditionalData); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return (ReadParam(aMsg, aIter, &aResult->mPaints) && - ReadParam(aMsg, aIter, &aResult->mRepaintRequests) && - ReadParam(aMsg, aIter, &aResult->mHitResults) && - ReadParam(aMsg, aIter, &aResult->mSampledResults) && - ReadParam(aMsg, aIter, &aResult->mAdditionalData)); + static bool Read(MessageReader* aReader, paramType* aResult) { + return (ReadParam(aReader, &aResult->mPaints) && + ReadParam(aReader, &aResult->mRepaintRequests) && + ReadParam(aReader, &aResult->mHitResults) && + ReadParam(aReader, &aResult->mSampledResults) && + ReadParam(aReader, &aResult->mAdditionalData)); } }; @@ -214,19 +213,18 @@ template <> struct ParamTraits { typedef mozilla::layers::APZTestData::HitResult paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.point); - WriteParam(aMsg, aParam.result); - WriteParam(aMsg, aParam.layersId); - WriteParam(aMsg, aParam.scrollId); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.point); + WriteParam(aWriter, aParam.result); + WriteParam(aWriter, aParam.layersId); + WriteParam(aWriter, aParam.scrollId); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return (ReadParam(aMsg, aIter, &aResult->point) && - ReadParam(aMsg, aIter, &aResult->result) && - ReadParam(aMsg, aIter, &aResult->layersId) && - ReadParam(aMsg, aIter, &aResult->scrollId)); + static bool Read(MessageReader* aReader, paramType* aResult) { + return (ReadParam(aReader, &aResult->point) && + ReadParam(aReader, &aResult->result) && + ReadParam(aReader, &aResult->layersId) && + ReadParam(aReader, &aResult->scrollId)); } }; @@ -234,19 +232,18 @@ template <> struct ParamTraits { typedef mozilla::layers::APZTestData::SampledResult paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.scrollOffset); - WriteParam(aMsg, aParam.sampledTimeStamp); - WriteParam(aMsg, aParam.layersId); - WriteParam(aMsg, aParam.scrollId); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.scrollOffset); + WriteParam(aWriter, aParam.sampledTimeStamp); + WriteParam(aWriter, aParam.layersId); + WriteParam(aWriter, aParam.scrollId); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return (ReadParam(aMsg, aIter, &aResult->scrollOffset) && - ReadParam(aMsg, aIter, &aResult->sampledTimeStamp) && - ReadParam(aMsg, aIter, &aResult->layersId) && - ReadParam(aMsg, aIter, &aResult->scrollId)); + static bool Read(MessageReader* aReader, paramType* aResult) { + return (ReadParam(aReader, &aResult->scrollOffset) && + ReadParam(aReader, &aResult->sampledTimeStamp) && + ReadParam(aReader, &aResult->layersId) && + ReadParam(aReader, &aResult->scrollId)); } }; diff --git a/gfx/layers/composite/FrameUniformityData.h b/gfx/layers/composite/FrameUniformityData.h index 58926e80e46c..3e2ad4939e37 100644 --- a/gfx/layers/composite/FrameUniformityData.h +++ b/gfx/layers/composite/FrameUniformityData.h @@ -34,14 +34,13 @@ template <> struct ParamTraits { typedef mozilla::layers::FrameUniformityData paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mUniformities); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mUniformities); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { return ParamTraitsStd>::Read( - aMsg, aIter, &aResult->mUniformities); + aReader, &aResult->mUniformities); } }; diff --git a/gfx/layers/ipc/LayersMessageUtils.h b/gfx/layers/ipc/LayersMessageUtils.h index ea69f684303a..87b8524f1b52 100644 --- a/gfx/layers/ipc/LayersMessageUtils.h +++ b/gfx/layers/ipc/LayersMessageUtils.h @@ -60,16 +60,15 @@ template <> struct ParamTraits { typedef mozilla::VsyncEvent paramType; - static void Write(Message* msg, const paramType& param) { - WriteParam(msg, param.mId); - WriteParam(msg, param.mTime); - WriteParam(msg, param.mOutputTime); + static void Write(MessageWriter* writer, const paramType& param) { + WriteParam(writer, param.mId); + WriteParam(writer, param.mTime); + WriteParam(writer, param.mOutputTime); } - static bool Read(const Message* msg, PickleIterator* iter, - paramType* result) { - return ReadParam(msg, iter, &result->mId) && - ReadParam(msg, iter, &result->mTime) && - ReadParam(msg, iter, &result->mOutputTime); + static bool Read(MessageReader* reader, paramType* result) { + return ReadParam(reader, &result->mId) && + ReadParam(reader, &result->mTime) && + ReadParam(reader, &result->mOutputTime); } }; @@ -77,17 +76,16 @@ template <> struct ParamTraits { typedef mozilla::layers::MatrixMessage paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mMatrix); - WriteParam(aMsg, aParam.mTopLevelViewportVisibleRectInBrowserCoords); - WriteParam(aMsg, aParam.mLayersId); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mMatrix); + WriteParam(aWriter, aParam.mTopLevelViewportVisibleRectInBrowserCoords); + WriteParam(aWriter, aParam.mLayersId); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mMatrix) && - ReadParam(aMsg, aIter, + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mMatrix) && + ReadParam(aReader, &aResult->mTopLevelViewportVisibleRectInBrowserCoords) && - ReadParam(aMsg, aIter, &aResult->mLayersId); + ReadParam(aReader, &aResult->mLayersId); } }; @@ -184,12 +182,11 @@ template <> struct ParamTraits { typedef mozilla::layers::LayerHandle paramType; - static void Write(Message* msg, const paramType& param) { - WriteParam(msg, param.mHandle); + static void Write(MessageWriter* writer, const paramType& param) { + WriteParam(writer, param.mHandle); } - static bool Read(const Message* msg, PickleIterator* iter, - paramType* result) { - return ReadParam(msg, iter, &result->mHandle); + static bool Read(MessageReader* reader, paramType* result) { + return ReadParam(reader, &result->mHandle); } }; @@ -197,12 +194,11 @@ template <> struct ParamTraits { typedef mozilla::layers::CompositableHandle paramType; - static void Write(Message* msg, const paramType& param) { - WriteParam(msg, param.mHandle); + static void Write(MessageWriter* writer, const paramType& param) { + WriteParam(writer, param.mHandle); } - static bool Read(const Message* msg, PickleIterator* iter, - paramType* result) { - return ReadParam(msg, iter, &result->mHandle); + static bool Read(MessageReader* reader, paramType* result) { + return ReadParam(reader, &result->mHandle); } }; @@ -218,65 +214,63 @@ struct ParamTraits : BitfieldHelper { typedef mozilla::layers::FrameMetrics paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mScrollId); - WriteParam(aMsg, aParam.mPresShellResolution); - WriteParam(aMsg, aParam.mCompositionBounds); - WriteParam(aMsg, aParam.mCompositionBoundsWidthIgnoringScrollbars); - WriteParam(aMsg, aParam.mDisplayPort); - WriteParam(aMsg, aParam.mScrollableRect); - WriteParam(aMsg, aParam.mCumulativeResolution); - WriteParam(aMsg, aParam.mDevPixelsPerCSSPixel); - WriteParam(aMsg, aParam.mScrollOffset); - WriteParam(aMsg, aParam.mZoom); - WriteParam(aMsg, aParam.mScrollGeneration); - WriteParam(aMsg, aParam.mBoundingCompositionSize); - WriteParam(aMsg, aParam.mPresShellId); - WriteParam(aMsg, aParam.mLayoutViewport); - WriteParam(aMsg, aParam.mTransformToAncestorScale); - WriteParam(aMsg, aParam.mPaintRequestTime); - WriteParam(aMsg, aParam.mVisualDestination); - WriteParam(aMsg, aParam.mVisualScrollUpdateType); - WriteParam(aMsg, aParam.mFixedLayerMargins); - WriteParam(aMsg, aParam.mCompositionSizeWithoutDynamicToolbar); - WriteParam(aMsg, aParam.mIsRootContent); - WriteParam(aMsg, aParam.mIsScrollInfoLayer); - WriteParam(aMsg, aParam.mHasNonZeroDisplayPortMargins); - WriteParam(aMsg, aParam.mMinimalDisplayPort); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mScrollId); + WriteParam(aWriter, aParam.mPresShellResolution); + WriteParam(aWriter, aParam.mCompositionBounds); + WriteParam(aWriter, aParam.mCompositionBoundsWidthIgnoringScrollbars); + WriteParam(aWriter, aParam.mDisplayPort); + WriteParam(aWriter, aParam.mScrollableRect); + WriteParam(aWriter, aParam.mCumulativeResolution); + WriteParam(aWriter, aParam.mDevPixelsPerCSSPixel); + WriteParam(aWriter, aParam.mScrollOffset); + WriteParam(aWriter, aParam.mZoom); + WriteParam(aWriter, aParam.mScrollGeneration); + WriteParam(aWriter, aParam.mBoundingCompositionSize); + WriteParam(aWriter, aParam.mPresShellId); + WriteParam(aWriter, aParam.mLayoutViewport); + WriteParam(aWriter, aParam.mTransformToAncestorScale); + WriteParam(aWriter, aParam.mPaintRequestTime); + WriteParam(aWriter, aParam.mVisualDestination); + WriteParam(aWriter, aParam.mVisualScrollUpdateType); + WriteParam(aWriter, aParam.mFixedLayerMargins); + WriteParam(aWriter, aParam.mCompositionSizeWithoutDynamicToolbar); + WriteParam(aWriter, aParam.mIsRootContent); + WriteParam(aWriter, aParam.mIsScrollInfoLayer); + WriteParam(aWriter, aParam.mHasNonZeroDisplayPortMargins); + WriteParam(aWriter, aParam.mMinimalDisplayPort); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return (ReadParam(aMsg, aIter, &aResult->mScrollId) && - ReadParam(aMsg, aIter, &aResult->mPresShellResolution) && - ReadParam(aMsg, aIter, &aResult->mCompositionBounds) && - ReadParam(aMsg, aIter, - &aResult->mCompositionBoundsWidthIgnoringScrollbars) && - ReadParam(aMsg, aIter, &aResult->mDisplayPort) && - ReadParam(aMsg, aIter, &aResult->mScrollableRect) && - ReadParam(aMsg, aIter, &aResult->mCumulativeResolution) && - ReadParam(aMsg, aIter, &aResult->mDevPixelsPerCSSPixel) && - ReadParam(aMsg, aIter, &aResult->mScrollOffset) && - ReadParam(aMsg, aIter, &aResult->mZoom) && - ReadParam(aMsg, aIter, &aResult->mScrollGeneration) && - ReadParam(aMsg, aIter, &aResult->mBoundingCompositionSize) && - ReadParam(aMsg, aIter, &aResult->mPresShellId) && - ReadParam(aMsg, aIter, &aResult->mLayoutViewport) && - ReadParam(aMsg, aIter, &aResult->mTransformToAncestorScale) && - ReadParam(aMsg, aIter, &aResult->mPaintRequestTime) && - ReadParam(aMsg, aIter, &aResult->mVisualDestination) && - ReadParam(aMsg, aIter, &aResult->mVisualScrollUpdateType) && - ReadParam(aMsg, aIter, &aResult->mFixedLayerMargins) && - ReadParam(aMsg, aIter, - &aResult->mCompositionSizeWithoutDynamicToolbar) && - ReadBoolForBitfield(aMsg, aIter, aResult, - ¶mType::SetIsRootContent) && - ReadBoolForBitfield(aMsg, aIter, aResult, - ¶mType::SetIsScrollInfoLayer) && - ReadBoolForBitfield(aMsg, aIter, aResult, - ¶mType::SetHasNonZeroDisplayPortMargins) && - ReadBoolForBitfield(aMsg, aIter, aResult, - ¶mType::SetMinimalDisplayPort)); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ( + ReadParam(aReader, &aResult->mScrollId) && + ReadParam(aReader, &aResult->mPresShellResolution) && + ReadParam(aReader, &aResult->mCompositionBounds) && + ReadParam(aReader, + &aResult->mCompositionBoundsWidthIgnoringScrollbars) && + ReadParam(aReader, &aResult->mDisplayPort) && + ReadParam(aReader, &aResult->mScrollableRect) && + ReadParam(aReader, &aResult->mCumulativeResolution) && + ReadParam(aReader, &aResult->mDevPixelsPerCSSPixel) && + ReadParam(aReader, &aResult->mScrollOffset) && + ReadParam(aReader, &aResult->mZoom) && + ReadParam(aReader, &aResult->mScrollGeneration) && + ReadParam(aReader, &aResult->mBoundingCompositionSize) && + ReadParam(aReader, &aResult->mPresShellId) && + ReadParam(aReader, &aResult->mLayoutViewport) && + ReadParam(aReader, &aResult->mTransformToAncestorScale) && + ReadParam(aReader, &aResult->mPaintRequestTime) && + ReadParam(aReader, &aResult->mVisualDestination) && + ReadParam(aReader, &aResult->mVisualScrollUpdateType) && + ReadParam(aReader, &aResult->mFixedLayerMargins) && + ReadParam(aReader, &aResult->mCompositionSizeWithoutDynamicToolbar) && + ReadBoolForBitfield(aReader, aResult, ¶mType::SetIsRootContent) && + ReadBoolForBitfield(aReader, aResult, + ¶mType::SetIsScrollInfoLayer) && + ReadBoolForBitfield(aReader, aResult, + ¶mType::SetHasNonZeroDisplayPortMargins) && + ReadBoolForBitfield(aReader, aResult, + ¶mType::SetMinimalDisplayPort)); } }; @@ -291,49 +285,48 @@ struct ParamTraits : BitfieldHelper { typedef mozilla::layers::RepaintRequest paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mScrollId); - WriteParam(aMsg, aParam.mPresShellResolution); - WriteParam(aMsg, aParam.mCompositionBounds); - WriteParam(aMsg, aParam.mCumulativeResolution); - WriteParam(aMsg, aParam.mDevPixelsPerCSSPixel); - WriteParam(aMsg, aParam.mScrollOffset); - WriteParam(aMsg, aParam.mZoom); - WriteParam(aMsg, aParam.mScrollGeneration); - WriteParam(aMsg, aParam.mScrollGenerationOnApz); - WriteParam(aMsg, aParam.mDisplayPortMargins); - WriteParam(aMsg, aParam.mPresShellId); - WriteParam(aMsg, aParam.mLayoutViewport); - WriteParam(aMsg, aParam.mTransformToAncestorScale); - WriteParam(aMsg, aParam.mPaintRequestTime); - WriteParam(aMsg, aParam.mScrollUpdateType); - WriteParam(aMsg, aParam.mScrollAnimationType); - WriteParam(aMsg, aParam.mIsRootContent); - WriteParam(aMsg, aParam.mIsScrollInfoLayer); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mScrollId); + WriteParam(aWriter, aParam.mPresShellResolution); + WriteParam(aWriter, aParam.mCompositionBounds); + WriteParam(aWriter, aParam.mCumulativeResolution); + WriteParam(aWriter, aParam.mDevPixelsPerCSSPixel); + WriteParam(aWriter, aParam.mScrollOffset); + WriteParam(aWriter, aParam.mZoom); + WriteParam(aWriter, aParam.mScrollGeneration); + WriteParam(aWriter, aParam.mScrollGenerationOnApz); + WriteParam(aWriter, aParam.mDisplayPortMargins); + WriteParam(aWriter, aParam.mPresShellId); + WriteParam(aWriter, aParam.mLayoutViewport); + WriteParam(aWriter, aParam.mTransformToAncestorScale); + WriteParam(aWriter, aParam.mPaintRequestTime); + WriteParam(aWriter, aParam.mScrollUpdateType); + WriteParam(aWriter, aParam.mScrollAnimationType); + WriteParam(aWriter, aParam.mIsRootContent); + WriteParam(aWriter, aParam.mIsScrollInfoLayer); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return (ReadParam(aMsg, aIter, &aResult->mScrollId) && - ReadParam(aMsg, aIter, &aResult->mPresShellResolution) && - ReadParam(aMsg, aIter, &aResult->mCompositionBounds) && - ReadParam(aMsg, aIter, &aResult->mCumulativeResolution) && - ReadParam(aMsg, aIter, &aResult->mDevPixelsPerCSSPixel) && - ReadParam(aMsg, aIter, &aResult->mScrollOffset) && - ReadParam(aMsg, aIter, &aResult->mZoom) && - ReadParam(aMsg, aIter, &aResult->mScrollGeneration) && - ReadParam(aMsg, aIter, &aResult->mScrollGenerationOnApz) && - ReadParam(aMsg, aIter, &aResult->mDisplayPortMargins) && - ReadParam(aMsg, aIter, &aResult->mPresShellId) && - ReadParam(aMsg, aIter, &aResult->mLayoutViewport) && - ReadParam(aMsg, aIter, &aResult->mTransformToAncestorScale) && - ReadParam(aMsg, aIter, &aResult->mPaintRequestTime) && - ReadParam(aMsg, aIter, &aResult->mScrollUpdateType) && - ReadParam(aMsg, aIter, &aResult->mScrollAnimationType) && - ReadBoolForBitfield(aMsg, aIter, aResult, - ¶mType::SetIsRootContent) && - ReadBoolForBitfield(aMsg, aIter, aResult, - ¶mType::SetIsScrollInfoLayer)); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ( + ReadParam(aReader, &aResult->mScrollId) && + ReadParam(aReader, &aResult->mPresShellResolution) && + ReadParam(aReader, &aResult->mCompositionBounds) && + ReadParam(aReader, &aResult->mCumulativeResolution) && + ReadParam(aReader, &aResult->mDevPixelsPerCSSPixel) && + ReadParam(aReader, &aResult->mScrollOffset) && + ReadParam(aReader, &aResult->mZoom) && + ReadParam(aReader, &aResult->mScrollGeneration) && + ReadParam(aReader, &aResult->mScrollGenerationOnApz) && + ReadParam(aReader, &aResult->mDisplayPortMargins) && + ReadParam(aReader, &aResult->mPresShellId) && + ReadParam(aReader, &aResult->mLayoutViewport) && + ReadParam(aReader, &aResult->mTransformToAncestorScale) && + ReadParam(aReader, &aResult->mPaintRequestTime) && + ReadParam(aReader, &aResult->mScrollUpdateType) && + ReadParam(aReader, &aResult->mScrollAnimationType) && + ReadBoolForBitfield(aReader, aResult, ¶mType::SetIsRootContent) && + ReadBoolForBitfield(aReader, aResult, + ¶mType::SetIsScrollInfoLayer)); } }; @@ -341,15 +334,14 @@ template <> struct ParamTraits { typedef nsSize paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.width); - WriteParam(aMsg, aParam.height); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.width); + WriteParam(aWriter, aParam.height); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->width) && - ReadParam(aMsg, aIter, &aResult->height); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->width) && + ReadParam(aReader, &aResult->height); } }; @@ -357,15 +349,14 @@ template <> struct ParamTraits { typedef mozilla::layers::ScrollSnapInfo::ScrollSnapRange paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mStart); - WriteParam(aMsg, aParam.mEnd); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mStart); + WriteParam(aWriter, aParam.mEnd); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mStart) && - ReadParam(aMsg, aIter, &aResult->mEnd); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mStart) && + ReadParam(aReader, &aResult->mEnd); } }; @@ -373,25 +364,24 @@ template <> struct ParamTraits { typedef mozilla::layers::ScrollSnapInfo paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mScrollSnapStrictnessX); - WriteParam(aMsg, aParam.mScrollSnapStrictnessY); - WriteParam(aMsg, aParam.mSnapPositionX); - WriteParam(aMsg, aParam.mSnapPositionY); - WriteParam(aMsg, aParam.mXRangeWiderThanSnapport); - WriteParam(aMsg, aParam.mYRangeWiderThanSnapport); - WriteParam(aMsg, aParam.mSnapportSize); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mScrollSnapStrictnessX); + WriteParam(aWriter, aParam.mScrollSnapStrictnessY); + WriteParam(aWriter, aParam.mSnapPositionX); + WriteParam(aWriter, aParam.mSnapPositionY); + WriteParam(aWriter, aParam.mXRangeWiderThanSnapport); + WriteParam(aWriter, aParam.mYRangeWiderThanSnapport); + WriteParam(aWriter, aParam.mSnapportSize); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return (ReadParam(aMsg, aIter, &aResult->mScrollSnapStrictnessX) && - ReadParam(aMsg, aIter, &aResult->mScrollSnapStrictnessY) && - ReadParam(aMsg, aIter, &aResult->mSnapPositionX) && - ReadParam(aMsg, aIter, &aResult->mSnapPositionY) && - ReadParam(aMsg, aIter, &aResult->mXRangeWiderThanSnapport) && - ReadParam(aMsg, aIter, &aResult->mYRangeWiderThanSnapport) && - ReadParam(aMsg, aIter, &aResult->mSnapportSize)); + static bool Read(MessageReader* aReader, paramType* aResult) { + return (ReadParam(aReader, &aResult->mScrollSnapStrictnessX) && + ReadParam(aReader, &aResult->mScrollSnapStrictnessY) && + ReadParam(aReader, &aResult->mSnapPositionX) && + ReadParam(aReader, &aResult->mSnapPositionY) && + ReadParam(aReader, &aResult->mXRangeWiderThanSnapport) && + ReadParam(aReader, &aResult->mYRangeWiderThanSnapport) && + ReadParam(aReader, &aResult->mSnapportSize)); } }; @@ -402,15 +392,14 @@ struct ParamTraits { typedef mozilla::layers::OverscrollBehaviorInfo paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mBehaviorX); - WriteParam(aMsg, aParam.mBehaviorY); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mBehaviorX); + WriteParam(aWriter, aParam.mBehaviorY); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return (ReadParam(aMsg, aIter, &aResult->mBehaviorX) && - ReadParam(aMsg, aIter, &aResult->mBehaviorY)); + static bool Read(MessageReader* aReader, paramType* aResult) { + return (ReadParam(aReader, &aResult->mBehaviorX) && + ReadParam(aReader, &aResult->mBehaviorY)); } }; @@ -427,72 +416,71 @@ struct ParamTraits : BitfieldHelper { typedef mozilla::layers::ScrollMetadata paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mMetrics); - WriteParam(aMsg, aParam.mSnapInfo); - WriteParam(aMsg, aParam.mScrollParentId); - WriteParam(aMsg, aParam.mBackgroundColor); - WriteParam(aMsg, aParam.GetContentDescription()); - WriteParam(aMsg, aParam.mLineScrollAmount); - WriteParam(aMsg, aParam.mPageScrollAmount); - WriteParam(aMsg, aParam.mHasScrollgrab); - WriteParam(aMsg, aParam.mIsLayersIdRoot); - WriteParam(aMsg, aParam.mIsAutoDirRootContentRTL); - WriteParam(aMsg, aParam.mForceDisableApz); - WriteParam(aMsg, aParam.mResolutionUpdated); - WriteParam(aMsg, aParam.mIsRDMTouchSimulationActive); - WriteParam(aMsg, aParam.mDidContentGetPainted); - WriteParam(aMsg, aParam.mPrefersReducedMotion); - WriteParam(aMsg, aParam.mForceMousewheelAutodir); - WriteParam(aMsg, aParam.mForceMousewheelAutodirHonourRoot); - WriteParam(aMsg, aParam.mDisregardedDirection); - WriteParam(aMsg, aParam.mOverscrollBehavior); - WriteParam(aMsg, aParam.mScrollUpdates); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mMetrics); + WriteParam(aWriter, aParam.mSnapInfo); + WriteParam(aWriter, aParam.mScrollParentId); + WriteParam(aWriter, aParam.mBackgroundColor); + WriteParam(aWriter, aParam.GetContentDescription()); + WriteParam(aWriter, aParam.mLineScrollAmount); + WriteParam(aWriter, aParam.mPageScrollAmount); + WriteParam(aWriter, aParam.mHasScrollgrab); + WriteParam(aWriter, aParam.mIsLayersIdRoot); + WriteParam(aWriter, aParam.mIsAutoDirRootContentRTL); + WriteParam(aWriter, aParam.mForceDisableApz); + WriteParam(aWriter, aParam.mResolutionUpdated); + WriteParam(aWriter, aParam.mIsRDMTouchSimulationActive); + WriteParam(aWriter, aParam.mDidContentGetPainted); + WriteParam(aWriter, aParam.mPrefersReducedMotion); + WriteParam(aWriter, aParam.mForceMousewheelAutodir); + WriteParam(aWriter, aParam.mForceMousewheelAutodirHonourRoot); + WriteParam(aWriter, aParam.mDisregardedDirection); + WriteParam(aWriter, aParam.mOverscrollBehavior); + WriteParam(aWriter, aParam.mScrollUpdates); } - static bool ReadContentDescription(const Message* aMsg, PickleIterator* aIter, + static bool ReadContentDescription(MessageReader* aReader, paramType* aResult) { nsCString str; - if (!ReadParam(aMsg, aIter, &str)) { + if (!ReadParam(aReader, &str)) { return false; } aResult->SetContentDescription(str); return true; } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return (ReadParam(aMsg, aIter, &aResult->mMetrics) && - ReadParam(aMsg, aIter, &aResult->mSnapInfo) && - ReadParam(aMsg, aIter, &aResult->mScrollParentId) && - ReadParam(aMsg, aIter, &aResult->mBackgroundColor) && - ReadContentDescription(aMsg, aIter, aResult) && - ReadParam(aMsg, aIter, &aResult->mLineScrollAmount) && - ReadParam(aMsg, aIter, &aResult->mPageScrollAmount) && - ReadBoolForBitfield(aMsg, aIter, aResult, + static bool Read(MessageReader* aReader, paramType* aResult) { + return (ReadParam(aReader, &aResult->mMetrics) && + ReadParam(aReader, &aResult->mSnapInfo) && + ReadParam(aReader, &aResult->mScrollParentId) && + ReadParam(aReader, &aResult->mBackgroundColor) && + ReadContentDescription(aReader, aResult) && + ReadParam(aReader, &aResult->mLineScrollAmount) && + ReadParam(aReader, &aResult->mPageScrollAmount) && + ReadBoolForBitfield(aReader, aResult, ¶mType::SetHasScrollgrab) && - ReadBoolForBitfield(aMsg, aIter, aResult, + ReadBoolForBitfield(aReader, aResult, ¶mType::SetIsLayersIdRoot) && - ReadBoolForBitfield(aMsg, aIter, aResult, + ReadBoolForBitfield(aReader, aResult, ¶mType::SetIsAutoDirRootContentRTL) && - ReadBoolForBitfield(aMsg, aIter, aResult, + ReadBoolForBitfield(aReader, aResult, ¶mType::SetForceDisableApz) && - ReadBoolForBitfield(aMsg, aIter, aResult, + ReadBoolForBitfield(aReader, aResult, ¶mType::SetResolutionUpdated) && - ReadBoolForBitfield(aMsg, aIter, aResult, + ReadBoolForBitfield(aReader, aResult, ¶mType::SetIsRDMTouchSimulationActive)) && - ReadBoolForBitfield(aMsg, aIter, aResult, + ReadBoolForBitfield(aReader, aResult, ¶mType::SetDidContentGetPainted) && - ReadBoolForBitfield(aMsg, aIter, aResult, + ReadBoolForBitfield(aReader, aResult, ¶mType::SetPrefersReducedMotion) && - ReadBoolForBitfield(aMsg, aIter, aResult, + ReadBoolForBitfield(aReader, aResult, ¶mType::SetForceMousewheelAutodir) && ReadBoolForBitfield( - aMsg, aIter, aResult, + aReader, aResult, ¶mType::SetForceMousewheelAutodirHonourRoot) && - ReadParam(aMsg, aIter, &aResult->mDisregardedDirection) && - ReadParam(aMsg, aIter, &aResult->mOverscrollBehavior) && - ReadParam(aMsg, aIter, &aResult->mScrollUpdates); + ReadParam(aReader, &aResult->mDisregardedDirection) && + ReadParam(aReader, &aResult->mOverscrollBehavior) && + ReadParam(aReader, &aResult->mScrollUpdates); } }; @@ -500,35 +488,34 @@ template <> struct ParamTraits { typedef mozilla::layers::TextureFactoryIdentifier paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mParentBackend); - WriteParam(aMsg, aParam.mWebRenderBackend); - WriteParam(aMsg, aParam.mWebRenderCompositor); - WriteParam(aMsg, aParam.mParentProcessType); - WriteParam(aMsg, aParam.mMaxTextureSize); - WriteParam(aMsg, aParam.mCompositorUseANGLE); - WriteParam(aMsg, aParam.mCompositorUseDComp); - WriteParam(aMsg, aParam.mUseCompositorWnd); - WriteParam(aMsg, aParam.mSupportsTextureBlitting); - WriteParam(aMsg, aParam.mSupportsPartialUploads); - WriteParam(aMsg, aParam.mSupportsComponentAlpha); - WriteParam(aMsg, aParam.mSyncHandle); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mParentBackend); + WriteParam(aWriter, aParam.mWebRenderBackend); + WriteParam(aWriter, aParam.mWebRenderCompositor); + WriteParam(aWriter, aParam.mParentProcessType); + WriteParam(aWriter, aParam.mMaxTextureSize); + WriteParam(aWriter, aParam.mCompositorUseANGLE); + WriteParam(aWriter, aParam.mCompositorUseDComp); + WriteParam(aWriter, aParam.mUseCompositorWnd); + WriteParam(aWriter, aParam.mSupportsTextureBlitting); + WriteParam(aWriter, aParam.mSupportsPartialUploads); + WriteParam(aWriter, aParam.mSupportsComponentAlpha); + WriteParam(aWriter, aParam.mSyncHandle); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - bool result = ReadParam(aMsg, aIter, &aResult->mParentBackend) && - ReadParam(aMsg, aIter, &aResult->mWebRenderBackend) && - ReadParam(aMsg, aIter, &aResult->mWebRenderCompositor) && - ReadParam(aMsg, aIter, &aResult->mParentProcessType) && - ReadParam(aMsg, aIter, &aResult->mMaxTextureSize) && - ReadParam(aMsg, aIter, &aResult->mCompositorUseANGLE) && - ReadParam(aMsg, aIter, &aResult->mCompositorUseDComp) && - ReadParam(aMsg, aIter, &aResult->mUseCompositorWnd) && - ReadParam(aMsg, aIter, &aResult->mSupportsTextureBlitting) && - ReadParam(aMsg, aIter, &aResult->mSupportsPartialUploads) && - ReadParam(aMsg, aIter, &aResult->mSupportsComponentAlpha) && - ReadParam(aMsg, aIter, &aResult->mSyncHandle); + static bool Read(MessageReader* aReader, paramType* aResult) { + bool result = ReadParam(aReader, &aResult->mParentBackend) && + ReadParam(aReader, &aResult->mWebRenderBackend) && + ReadParam(aReader, &aResult->mWebRenderCompositor) && + ReadParam(aReader, &aResult->mParentProcessType) && + ReadParam(aReader, &aResult->mMaxTextureSize) && + ReadParam(aReader, &aResult->mCompositorUseANGLE) && + ReadParam(aReader, &aResult->mCompositorUseDComp) && + ReadParam(aReader, &aResult->mUseCompositorWnd) && + ReadParam(aReader, &aResult->mSupportsTextureBlitting) && + ReadParam(aReader, &aResult->mSupportsPartialUploads) && + ReadParam(aReader, &aResult->mSupportsComponentAlpha) && + ReadParam(aReader, &aResult->mSyncHandle); return result; } }; @@ -537,15 +524,14 @@ template <> struct ParamTraits { typedef mozilla::layers::TextureInfo paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mCompositableType); - WriteParam(aMsg, aParam.mTextureFlags); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mCompositableType); + WriteParam(aWriter, aParam.mTextureFlags); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mCompositableType) && - ReadParam(aMsg, aIter, &aResult->mTextureFlags); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mCompositableType) && + ReadParam(aReader, &aResult->mTextureFlags); } }; @@ -560,17 +546,16 @@ template <> struct ParamTraits { typedef mozilla::layers::ScrollableLayerGuid paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mLayersId); - WriteParam(aMsg, aParam.mPresShellId); - WriteParam(aMsg, aParam.mScrollId); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mLayersId); + WriteParam(aWriter, aParam.mPresShellId); + WriteParam(aWriter, aParam.mScrollId); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return (ReadParam(aMsg, aIter, &aResult->mLayersId) && - ReadParam(aMsg, aIter, &aResult->mPresShellId) && - ReadParam(aMsg, aIter, &aResult->mScrollId)); + static bool Read(MessageReader* aReader, paramType* aResult) { + return (ReadParam(aReader, &aResult->mLayersId) && + ReadParam(aReader, &aResult->mPresShellId) && + ReadParam(aReader, &aResult->mScrollId)); } }; @@ -590,14 +575,13 @@ template <> struct ParamTraits { typedef mozilla::layers::ScrollDirections paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.serialize()); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.serialize()); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { uint8_t value; - if (!ReadParam(aMsg, aIter, &value)) { + if (!ReadParam(aReader, &value)) { return false; } aResult->deserialize(value); @@ -609,17 +593,16 @@ template <> struct ParamTraits { typedef mozilla::layers::APZHandledResult paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mPlace); - WriteParam(aMsg, aParam.mScrollableDirections); - WriteParam(aMsg, aParam.mOverscrollDirections); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mPlace); + WriteParam(aWriter, aParam.mScrollableDirections); + WriteParam(aWriter, aParam.mOverscrollDirections); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return (ReadParam(aMsg, aIter, &aResult->mPlace) && - ReadParam(aMsg, aIter, &aResult->mScrollableDirections) && - ReadParam(aMsg, aIter, &aResult->mOverscrollDirections)); + static bool Read(MessageReader* aReader, paramType* aResult) { + return (ReadParam(aReader, &aResult->mPlace) && + ReadParam(aReader, &aResult->mScrollableDirections) && + ReadParam(aReader, &aResult->mOverscrollDirections)); } }; @@ -627,29 +610,28 @@ template <> struct ParamTraits { typedef mozilla::layers::APZEventResult paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.GetStatus()); - WriteParam(aMsg, aParam.GetHandledResult()); - WriteParam(aMsg, aParam.mTargetGuid); - WriteParam(aMsg, aParam.mInputBlockId); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.GetStatus()); + WriteParam(aWriter, aParam.GetHandledResult()); + WriteParam(aWriter, aParam.mTargetGuid); + WriteParam(aWriter, aParam.mInputBlockId); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { nsEventStatus status; - if (!ReadParam(aMsg, aIter, &status)) { + if (!ReadParam(aReader, &status)) { return false; } aResult->UpdateStatus(status); mozilla::Maybe handledResult; - if (!ReadParam(aMsg, aIter, &handledResult)) { + if (!ReadParam(aReader, &handledResult)) { return false; } aResult->UpdateHandledResult(handledResult); - return (ReadParam(aMsg, aIter, &aResult->mTargetGuid) && - ReadParam(aMsg, aIter, &aResult->mInputBlockId)); + return (ReadParam(aReader, &aResult->mTargetGuid) && + ReadParam(aReader, &aResult->mInputBlockId)); } }; @@ -657,19 +639,18 @@ template <> struct ParamTraits { typedef mozilla::layers::ZoomConstraints paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mAllowZoom); - WriteParam(aMsg, aParam.mAllowDoubleTapZoom); - WriteParam(aMsg, aParam.mMinZoom); - WriteParam(aMsg, aParam.mMaxZoom); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mAllowZoom); + WriteParam(aWriter, aParam.mAllowDoubleTapZoom); + WriteParam(aWriter, aParam.mMinZoom); + WriteParam(aWriter, aParam.mMaxZoom); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return (ReadParam(aMsg, aIter, &aResult->mAllowZoom) && - ReadParam(aMsg, aIter, &aResult->mAllowDoubleTapZoom) && - ReadParam(aMsg, aIter, &aResult->mMinZoom) && - ReadParam(aMsg, aIter, &aResult->mMaxZoom)); + static bool Read(MessageReader* aReader, paramType* aResult) { + return (ReadParam(aReader, &aResult->mAllowZoom) && + ReadParam(aReader, &aResult->mAllowDoubleTapZoom) && + ReadParam(aReader, &aResult->mMinZoom) && + ReadParam(aReader, &aResult->mMaxZoom)); } }; @@ -677,15 +658,14 @@ template <> struct ParamTraits { typedef mozilla::layers::FocusTarget::ScrollTargets paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mHorizontal); - WriteParam(aMsg, aParam.mVertical); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mHorizontal); + WriteParam(aWriter, aParam.mVertical); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mHorizontal) && - ReadParam(aMsg, aIter, &aResult->mVertical); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mHorizontal) && + ReadParam(aReader, &aResult->mVertical); } }; @@ -698,17 +678,16 @@ template <> struct ParamTraits { typedef mozilla::layers::FocusTarget paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mSequenceNumber); - WriteParam(aMsg, aParam.mFocusHasKeyEventListeners); - WriteParam(aMsg, aParam.mData); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mSequenceNumber); + WriteParam(aWriter, aParam.mFocusHasKeyEventListeners); + WriteParam(aWriter, aParam.mData); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &aResult->mSequenceNumber) || - !ReadParam(aMsg, aIter, &aResult->mFocusHasKeyEventListeners) || - !ReadParam(aMsg, aIter, &aResult->mData)) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &aResult->mSequenceNumber) || + !ReadParam(aReader, &aResult->mFocusHasKeyEventListeners) || + !ReadParam(aReader, &aResult->mData)) { return false; } return true; @@ -729,15 +708,14 @@ template <> struct ParamTraits { typedef mozilla::layers::KeyboardScrollAction paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mType); - WriteParam(aMsg, aParam.mForward); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mType); + WriteParam(aWriter, aParam.mForward); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mType) && - ReadParam(aMsg, aIter, &aResult->mForward); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mType) && + ReadParam(aReader, &aResult->mForward); } }; @@ -745,25 +723,24 @@ template <> struct ParamTraits { typedef mozilla::layers::KeyboardShortcut paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mAction); - WriteParam(aMsg, aParam.mKeyCode); - WriteParam(aMsg, aParam.mCharCode); - WriteParam(aMsg, aParam.mModifiers); - WriteParam(aMsg, aParam.mModifiersMask); - WriteParam(aMsg, aParam.mEventType); - WriteParam(aMsg, aParam.mDispatchToContent); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mAction); + WriteParam(aWriter, aParam.mKeyCode); + WriteParam(aWriter, aParam.mCharCode); + WriteParam(aWriter, aParam.mModifiers); + WriteParam(aWriter, aParam.mModifiersMask); + WriteParam(aWriter, aParam.mEventType); + WriteParam(aWriter, aParam.mDispatchToContent); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mAction) && - ReadParam(aMsg, aIter, &aResult->mKeyCode) && - ReadParam(aMsg, aIter, &aResult->mCharCode) && - ReadParam(aMsg, aIter, &aResult->mModifiers) && - ReadParam(aMsg, aIter, &aResult->mModifiersMask) && - ReadParam(aMsg, aIter, &aResult->mEventType) && - ReadParam(aMsg, aIter, &aResult->mDispatchToContent); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mAction) && + ReadParam(aReader, &aResult->mKeyCode) && + ReadParam(aReader, &aResult->mCharCode) && + ReadParam(aReader, &aResult->mModifiers) && + ReadParam(aReader, &aResult->mModifiersMask) && + ReadParam(aReader, &aResult->mEventType) && + ReadParam(aReader, &aResult->mDispatchToContent); } }; @@ -771,14 +748,13 @@ template <> struct ParamTraits { typedef mozilla::layers::KeyboardMap paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.Shortcuts()); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.Shortcuts()); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { nsTArray shortcuts; - if (!ReadParam(aMsg, aIter, &shortcuts)) { + if (!ReadParam(aReader, &shortcuts)) { return false; } *aResult = mozilla::layers::KeyboardMap(std::move(shortcuts)); @@ -811,21 +787,20 @@ template <> struct ParamTraits { typedef mozilla::layers::AsyncDragMetrics paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mViewId); - WriteParam(aMsg, aParam.mPresShellId); - WriteParam(aMsg, aParam.mDragStartSequenceNumber); - WriteParam(aMsg, aParam.mScrollbarDragOffset); - WriteParam(aMsg, aParam.mDirection); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mViewId); + WriteParam(aWriter, aParam.mPresShellId); + WriteParam(aWriter, aParam.mDragStartSequenceNumber); + WriteParam(aWriter, aParam.mScrollbarDragOffset); + WriteParam(aWriter, aParam.mDirection); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return (ReadParam(aMsg, aIter, &aResult->mViewId) && - ReadParam(aMsg, aIter, &aResult->mPresShellId) && - ReadParam(aMsg, aIter, &aResult->mDragStartSequenceNumber) && - ReadParam(aMsg, aIter, &aResult->mScrollbarDragOffset) && - ReadParam(aMsg, aIter, &aResult->mDirection)); + static bool Read(MessageReader* aReader, paramType* aResult) { + return (ReadParam(aReader, &aResult->mViewId) && + ReadParam(aReader, &aResult->mPresShellId) && + ReadParam(aReader, &aResult->mDragStartSequenceNumber) && + ReadParam(aReader, &aResult->mScrollbarDragOffset) && + ReadParam(aReader, &aResult->mDirection)); } }; @@ -833,23 +808,22 @@ template <> struct ParamTraits { typedef mozilla::layers::CompositorOptions paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mUseAPZ); - WriteParam(aMsg, aParam.mUseSoftwareWebRender); - WriteParam(aMsg, aParam.mAllowSoftwareWebRenderD3D11); - WriteParam(aMsg, aParam.mAllowSoftwareWebRenderOGL); - WriteParam(aMsg, aParam.mUseWebGPU); - WriteParam(aMsg, aParam.mInitiallyPaused); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mUseAPZ); + WriteParam(aWriter, aParam.mUseSoftwareWebRender); + WriteParam(aWriter, aParam.mAllowSoftwareWebRenderD3D11); + WriteParam(aWriter, aParam.mAllowSoftwareWebRenderOGL); + WriteParam(aWriter, aParam.mUseWebGPU); + WriteParam(aWriter, aParam.mInitiallyPaused); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mUseAPZ) && - ReadParam(aMsg, aIter, &aResult->mUseSoftwareWebRender) && - ReadParam(aMsg, aIter, &aResult->mAllowSoftwareWebRenderD3D11) && - ReadParam(aMsg, aIter, &aResult->mAllowSoftwareWebRenderOGL) && - ReadParam(aMsg, aIter, &aResult->mUseWebGPU) && - ReadParam(aMsg, aIter, &aResult->mInitiallyPaused); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mUseAPZ) && + ReadParam(aReader, &aResult->mUseSoftwareWebRender) && + ReadParam(aReader, &aResult->mAllowSoftwareWebRenderD3D11) && + ReadParam(aReader, &aResult->mAllowSoftwareWebRenderOGL) && + ReadParam(aReader, &aResult->mUseWebGPU) && + ReadParam(aReader, &aResult->mInitiallyPaused); } }; @@ -864,29 +838,28 @@ template <> struct ParamTraits { typedef mozilla::layers::ScrollbarData paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mDirection); - WriteParam(aMsg, aParam.mScrollbarLayerType); - WriteParam(aMsg, aParam.mThumbRatio); - WriteParam(aMsg, aParam.mThumbStart); - WriteParam(aMsg, aParam.mThumbLength); - WriteParam(aMsg, aParam.mThumbIsAsyncDraggable); - WriteParam(aMsg, aParam.mScrollTrackStart); - WriteParam(aMsg, aParam.mScrollTrackLength); - WriteParam(aMsg, aParam.mTargetViewId); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mDirection); + WriteParam(aWriter, aParam.mScrollbarLayerType); + WriteParam(aWriter, aParam.mThumbRatio); + WriteParam(aWriter, aParam.mThumbStart); + WriteParam(aWriter, aParam.mThumbLength); + WriteParam(aWriter, aParam.mThumbIsAsyncDraggable); + WriteParam(aWriter, aParam.mScrollTrackStart); + WriteParam(aWriter, aParam.mScrollTrackLength); + WriteParam(aWriter, aParam.mTargetViewId); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mDirection) && - ReadParam(aMsg, aIter, &aResult->mScrollbarLayerType) && - ReadParam(aMsg, aIter, &aResult->mThumbRatio) && - ReadParam(aMsg, aIter, &aResult->mThumbStart) && - ReadParam(aMsg, aIter, &aResult->mThumbLength) && - ReadParam(aMsg, aIter, &aResult->mThumbIsAsyncDraggable) && - ReadParam(aMsg, aIter, &aResult->mScrollTrackStart) && - ReadParam(aMsg, aIter, &aResult->mScrollTrackLength) && - ReadParam(aMsg, aIter, &aResult->mTargetViewId); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mDirection) && + ReadParam(aReader, &aResult->mScrollbarLayerType) && + ReadParam(aReader, &aResult->mThumbRatio) && + ReadParam(aReader, &aResult->mThumbStart) && + ReadParam(aReader, &aResult->mThumbLength) && + ReadParam(aReader, &aResult->mThumbIsAsyncDraggable) && + ReadParam(aReader, &aResult->mScrollTrackStart) && + ReadParam(aReader, &aResult->mScrollTrackLength) && + ReadParam(aReader, &aResult->mTargetViewId); } }; @@ -901,15 +874,14 @@ template <> struct ParamTraits { typedef mozilla::layers::CompositionPayload paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mType); - WriteParam(aMsg, aParam.mTimeStamp); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mType); + WriteParam(aWriter, aParam.mTimeStamp); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mType) && - ReadParam(aMsg, aIter, &aResult->mTimeStamp); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mType) && + ReadParam(aReader, &aResult->mTimeStamp); } }; @@ -917,15 +889,14 @@ template <> struct ParamTraits { typedef mozilla::RayReferenceData paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mInitialPosition); - WriteParam(aMsg, aParam.mContainingBlockRect); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mInitialPosition); + WriteParam(aWriter, aParam.mContainingBlockRect); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return (ReadParam(aMsg, aIter, &aResult->mInitialPosition) && - ReadParam(aMsg, aIter, &aResult->mContainingBlockRect)); + static bool Read(MessageReader* aReader, paramType* aResult) { + return (ReadParam(aReader, &aResult->mInitialPosition) && + ReadParam(aReader, &aResult->mContainingBlockRect)); } }; @@ -940,19 +911,18 @@ template <> struct ParamTraits { typedef mozilla::layers::ZoomTarget paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.targetRect); - WriteParam(aMsg, aParam.cantZoomOutBehavior); - WriteParam(aMsg, aParam.elementBoundingRect); - WriteParam(aMsg, aParam.documentRelativePointerPosition); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.targetRect); + WriteParam(aWriter, aParam.cantZoomOutBehavior); + WriteParam(aWriter, aParam.elementBoundingRect); + WriteParam(aWriter, aParam.documentRelativePointerPosition); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return (ReadParam(aMsg, aIter, &aResult->targetRect) && - ReadParam(aMsg, aIter, &aResult->cantZoomOutBehavior) && - ReadParam(aMsg, aIter, &aResult->elementBoundingRect) && - ReadParam(aMsg, aIter, &aResult->documentRelativePointerPosition)); + static bool Read(MessageReader* aReader, paramType* aResult) { + return (ReadParam(aReader, &aResult->targetRect) && + ReadParam(aReader, &aResult->cantZoomOutBehavior) && + ReadParam(aReader, &aResult->elementBoundingRect) && + ReadParam(aReader, &aResult->documentRelativePointerPosition)); } }; @@ -960,16 +930,15 @@ struct ParamTraits { template <> \ struct ParamTraits { \ typedef mozilla::type_ paramType; \ - static void Write(Message* aMsg, const paramType& aParam) { \ + static void Write(MessageWriter* aWriter, const paramType& aParam) { \ mozilla::ipc::ByteBuf v; \ mozilla::DebugOnly rv = Servo_##type_##_Serialize(&aParam, &v); \ MOZ_ASSERT(rv, "Serialize ##type_## failed"); \ - WriteParam(aMsg, std::move(v)); \ + WriteParam(aWriter, std::move(v)); \ } \ - static bool Read(const Message* aMsg, PickleIterator* aIter, \ - paramType* aResult) { \ + static bool Read(MessageReader* aReader, paramType* aResult) { \ mozilla::ipc::ByteBuf in; \ - bool rv = ReadParam(aMsg, aIter, &in); \ + bool rv = ReadParam(aReader, &in); \ if (!rv) { \ return false; \ } \ diff --git a/gfx/layers/ipc/SharedSurfacesMemoryReport.h b/gfx/layers/ipc/SharedSurfacesMemoryReport.h index 57d9edddb772..81baf1349f03 100644 --- a/gfx/layers/ipc/SharedSurfacesMemoryReport.h +++ b/gfx/layers/ipc/SharedSurfacesMemoryReport.h @@ -40,13 +40,12 @@ template <> struct ParamTraits { typedef mozilla::layers::SharedSurfacesMemoryReport paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mSurfaces); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mSurfaces); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mSurfaces); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mSurfaces); } }; diff --git a/gfx/layers/wr/RenderRootTypes.cpp b/gfx/layers/wr/RenderRootTypes.cpp index bb95f824fc58..18385fa85e11 100644 --- a/gfx/layers/wr/RenderRootTypes.cpp +++ b/gfx/layers/wr/RenderRootTypes.cpp @@ -12,57 +12,56 @@ namespace mozilla { namespace ipc { void IPDLParamTraits::Write( - IPC::Message* aMsg, IProtocol* aActor, paramType&& aParam) { - WriteIPDLParam(aMsg, aActor, aParam.mIdNamespace); - WriteIPDLParam(aMsg, aActor, aParam.mRect); - WriteIPDLParam(aMsg, aActor, aParam.mCommands); - WriteIPDLParam(aMsg, aActor, std::move(aParam.mDLItems)); - WriteIPDLParam(aMsg, aActor, std::move(aParam.mDLCache)); - WriteIPDLParam(aMsg, aActor, std::move(aParam.mDLSpatialTree)); - WriteIPDLParam(aMsg, aActor, aParam.mDLDesc); - WriteIPDLParam(aMsg, aActor, aParam.mRemotePipelineIds); - WriteIPDLParam(aMsg, aActor, aParam.mResourceUpdates); - WriteIPDLParam(aMsg, aActor, aParam.mSmallShmems); - WriteIPDLParam(aMsg, aActor, std::move(aParam.mLargeShmems)); - WriteIPDLParam(aMsg, aActor, aParam.mScrollData); + IPC::MessageWriter* aWriter, IProtocol* aActor, paramType&& aParam) { + WriteIPDLParam(aWriter, aActor, aParam.mIdNamespace); + WriteIPDLParam(aWriter, aActor, aParam.mRect); + WriteIPDLParam(aWriter, aActor, aParam.mCommands); + WriteIPDLParam(aWriter, aActor, std::move(aParam.mDLItems)); + WriteIPDLParam(aWriter, aActor, std::move(aParam.mDLCache)); + WriteIPDLParam(aWriter, aActor, std::move(aParam.mDLSpatialTree)); + WriteIPDLParam(aWriter, aActor, aParam.mDLDesc); + WriteIPDLParam(aWriter, aActor, aParam.mRemotePipelineIds); + WriteIPDLParam(aWriter, aActor, aParam.mResourceUpdates); + WriteIPDLParam(aWriter, aActor, aParam.mSmallShmems); + WriteIPDLParam(aWriter, aActor, std::move(aParam.mLargeShmems)); + WriteIPDLParam(aWriter, aActor, aParam.mScrollData); } bool IPDLParamTraits::Read( - const IPC::Message* aMsg, PickleIterator* aIter, IProtocol* aActor, - paramType* aResult) { - if (ReadIPDLParam(aMsg, aIter, aActor, &aResult->mIdNamespace) && - ReadIPDLParam(aMsg, aIter, aActor, &aResult->mRect) && - ReadIPDLParam(aMsg, aIter, aActor, &aResult->mCommands) && - ReadIPDLParam(aMsg, aIter, aActor, &aResult->mDLItems) && - ReadIPDLParam(aMsg, aIter, aActor, &aResult->mDLCache) && - ReadIPDLParam(aMsg, aIter, aActor, &aResult->mDLSpatialTree) && - ReadIPDLParam(aMsg, aIter, aActor, &aResult->mDLDesc) && - ReadIPDLParam(aMsg, aIter, aActor, &aResult->mRemotePipelineIds) && - ReadIPDLParam(aMsg, aIter, aActor, &aResult->mResourceUpdates) && - ReadIPDLParam(aMsg, aIter, aActor, &aResult->mSmallShmems) && - ReadIPDLParam(aMsg, aIter, aActor, &aResult->mLargeShmems) && - ReadIPDLParam(aMsg, aIter, aActor, &aResult->mScrollData)) { + IPC::MessageReader* aReader, IProtocol* aActor, paramType* aResult) { + if (ReadIPDLParam(aReader, aActor, &aResult->mIdNamespace) && + ReadIPDLParam(aReader, aActor, &aResult->mRect) && + ReadIPDLParam(aReader, aActor, &aResult->mCommands) && + ReadIPDLParam(aReader, aActor, &aResult->mDLItems) && + ReadIPDLParam(aReader, aActor, &aResult->mDLCache) && + ReadIPDLParam(aReader, aActor, &aResult->mDLSpatialTree) && + ReadIPDLParam(aReader, aActor, &aResult->mDLDesc) && + ReadIPDLParam(aReader, aActor, &aResult->mRemotePipelineIds) && + ReadIPDLParam(aReader, aActor, &aResult->mResourceUpdates) && + ReadIPDLParam(aReader, aActor, &aResult->mSmallShmems) && + ReadIPDLParam(aReader, aActor, &aResult->mLargeShmems) && + ReadIPDLParam(aReader, aActor, &aResult->mScrollData)) { return true; } return false; } -void WriteScrollUpdates(IPC::Message* aMsg, IProtocol* aActor, +void WriteScrollUpdates(IPC::MessageWriter* aWriter, IProtocol* aActor, layers::ScrollUpdatesMap& aParam) { // ICK: we need to manually serialize this map because // nsDataHashTable doesn't support it (and other maps cause other issues) - WriteIPDLParam(aMsg, aActor, aParam.Count()); + WriteIPDLParam(aWriter, aActor, aParam.Count()); for (auto it = aParam.ConstIter(); !it.Done(); it.Next()) { - WriteIPDLParam(aMsg, aActor, it.Key()); - WriteIPDLParam(aMsg, aActor, it.Data()); + WriteIPDLParam(aWriter, aActor, it.Key()); + WriteIPDLParam(aWriter, aActor, it.Data()); } } -bool ReadScrollUpdates(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, layers::ScrollUpdatesMap* aResult) { +bool ReadScrollUpdates(IPC::MessageReader* aReader, IProtocol* aActor, + layers::ScrollUpdatesMap* aResult) { // Manually deserialize mScrollUpdates as a stream of K,V pairs uint32_t count; - if (!ReadIPDLParam(aMsg, aIter, aActor, &count)) { + if (!ReadIPDLParam(aReader, aActor, &count)) { return false; } @@ -70,8 +69,8 @@ bool ReadScrollUpdates(const IPC::Message* aMsg, PickleIterator* aIter, for (size_t i = 0; i < count; ++i) { layers::ScrollableLayerGuid::ViewID key; nsTArray data; - if (!ReadIPDLParam(aMsg, aIter, aActor, &key) || - !ReadIPDLParam(aMsg, aIter, aActor, &data)) { + if (!ReadIPDLParam(aReader, aActor, &key) || + !ReadIPDLParam(aReader, aActor, &data)) { return false; } map.InsertOrUpdate(key, std::move(data)); @@ -83,26 +82,25 @@ bool ReadScrollUpdates(const IPC::Message* aMsg, PickleIterator* aIter, } void IPDLParamTraits::Write( - IPC::Message* aMsg, IProtocol* aActor, paramType&& aParam) { - WriteIPDLParam(aMsg, aActor, aParam.mIdNamespace); - WriteIPDLParam(aMsg, aActor, aParam.mCommands); - WriteIPDLParam(aMsg, aActor, aParam.mResourceUpdates); - WriteIPDLParam(aMsg, aActor, aParam.mSmallShmems); - WriteIPDLParam(aMsg, aActor, std::move(aParam.mLargeShmems)); - WriteScrollUpdates(aMsg, aActor, aParam.mScrollUpdates); - WriteIPDLParam(aMsg, aActor, aParam.mPaintSequenceNumber); + IPC::MessageWriter* aWriter, IProtocol* aActor, paramType&& aParam) { + WriteIPDLParam(aWriter, aActor, aParam.mIdNamespace); + WriteIPDLParam(aWriter, aActor, aParam.mCommands); + WriteIPDLParam(aWriter, aActor, aParam.mResourceUpdates); + WriteIPDLParam(aWriter, aActor, aParam.mSmallShmems); + WriteIPDLParam(aWriter, aActor, std::move(aParam.mLargeShmems)); + WriteScrollUpdates(aWriter, aActor, aParam.mScrollUpdates); + WriteIPDLParam(aWriter, aActor, aParam.mPaintSequenceNumber); } bool IPDLParamTraits::Read( - const IPC::Message* aMsg, PickleIterator* aIter, IProtocol* aActor, - paramType* aResult) { - if (ReadIPDLParam(aMsg, aIter, aActor, &aResult->mIdNamespace) && - ReadIPDLParam(aMsg, aIter, aActor, &aResult->mCommands) && - ReadIPDLParam(aMsg, aIter, aActor, &aResult->mResourceUpdates) && - ReadIPDLParam(aMsg, aIter, aActor, &aResult->mSmallShmems) && - ReadIPDLParam(aMsg, aIter, aActor, &aResult->mLargeShmems) && - ReadScrollUpdates(aMsg, aIter, aActor, &aResult->mScrollUpdates) && - ReadIPDLParam(aMsg, aIter, aActor, &aResult->mPaintSequenceNumber)) { + IPC::MessageReader* aReader, IProtocol* aActor, paramType* aResult) { + if (ReadIPDLParam(aReader, aActor, &aResult->mIdNamespace) && + ReadIPDLParam(aReader, aActor, &aResult->mCommands) && + ReadIPDLParam(aReader, aActor, &aResult->mResourceUpdates) && + ReadIPDLParam(aReader, aActor, &aResult->mSmallShmems) && + ReadIPDLParam(aReader, aActor, &aResult->mLargeShmems) && + ReadScrollUpdates(aReader, aActor, &aResult->mScrollUpdates) && + ReadIPDLParam(aReader, aActor, &aResult->mPaintSequenceNumber)) { return true; } return false; diff --git a/gfx/layers/wr/RenderRootTypes.h b/gfx/layers/wr/RenderRootTypes.h index 2c490cea313f..9921a98f0e52 100644 --- a/gfx/layers/wr/RenderRootTypes.h +++ b/gfx/layers/wr/RenderRootTypes.h @@ -51,20 +51,22 @@ template <> struct IPDLParamTraits { typedef mozilla::layers::DisplayListData paramType; - static void Write(IPC::Message* aMsg, IProtocol* aActor, paramType&& aParam); + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, + paramType&& aParam); - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, paramType* aResult); + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + paramType* aResult); }; template <> struct IPDLParamTraits { typedef mozilla::layers::TransactionData paramType; - static void Write(IPC::Message* aMsg, IProtocol* aActor, paramType&& aParam); + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, + paramType&& aParam); - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, paramType* aResult); + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + paramType* aResult); }; } // namespace ipc diff --git a/gfx/layers/wr/WebRenderMessageUtils.h b/gfx/layers/wr/WebRenderMessageUtils.h index 3e7f31f46092..6a170b9b5a14 100644 --- a/gfx/layers/wr/WebRenderMessageUtils.h +++ b/gfx/layers/wr/WebRenderMessageUtils.h @@ -21,16 +21,15 @@ template <> struct ParamTraits { typedef mozilla::wr::ByteBuffer paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mLength); - aMsg->WriteBytes(aParam.mData, aParam.mLength); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mLength); + aWriter->WriteBytes(aParam.mData, aParam.mLength); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { size_t length; - return ReadParam(aMsg, aIter, &length) && aResult->Allocate(length) && - aMsg->ReadBytesInto(aIter, aResult->mData, length); + return ReadParam(aReader, &length) && aResult->Allocate(length) && + aReader->ReadBytesInto(aResult->mData, length); } }; @@ -38,21 +37,20 @@ template <> struct ParamTraits { typedef mozilla::wr::ImageDescriptor paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.format); - WriteParam(aMsg, aParam.width); - WriteParam(aMsg, aParam.height); - WriteParam(aMsg, aParam.stride); - WriteParam(aMsg, aParam.opacity); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.format); + WriteParam(aWriter, aParam.width); + WriteParam(aWriter, aParam.height); + WriteParam(aWriter, aParam.stride); + WriteParam(aWriter, aParam.opacity); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->format) && - ReadParam(aMsg, aIter, &aResult->width) && - ReadParam(aMsg, aIter, &aResult->height) && - ReadParam(aMsg, aIter, &aResult->stride) && - ReadParam(aMsg, aIter, &aResult->opacity); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->format) && + ReadParam(aReader, &aResult->width) && + ReadParam(aReader, &aResult->height) && + ReadParam(aReader, &aResult->stride) && + ReadParam(aReader, &aResult->opacity); } }; diff --git a/gfx/layers/wr/WebRenderScrollData.cpp b/gfx/layers/wr/WebRenderScrollData.cpp index 80b89dbcfdfc..a58ee0ff8a59 100644 --- a/gfx/layers/wr/WebRenderScrollData.cpp +++ b/gfx/layers/wr/WebRenderScrollData.cpp @@ -354,71 +354,71 @@ bool WebRenderScrollData::RepopulateMap() { namespace IPC { void ParamTraits::Write( - Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mDescendantCount); - WriteParam(aMsg, aParam.mScrollIds); - WriteParam(aMsg, aParam.mAncestorTransform); - WriteParam(aMsg, aParam.mAncestorTransformId); - WriteParam(aMsg, aParam.mTransform); - WriteParam(aMsg, aParam.mTransformIsPerspective); - WriteParam(aMsg, aParam.mResolution); - WriteParam(aMsg, aParam.mVisibleRegion); - WriteParam(aMsg, aParam.mRemoteDocumentSize); - WriteParam(aMsg, aParam.mReferentId); - WriteParam(aMsg, aParam.mEventRegionsOverride); - WriteParam(aMsg, aParam.mScrollbarData); - WriteParam(aMsg, aParam.mScrollbarAnimationId); - WriteParam(aMsg, aParam.mFixedPositionAnimationId); - WriteParam(aMsg, aParam.mFixedPositionSides); - WriteParam(aMsg, aParam.mFixedPosScrollContainerId); - WriteParam(aMsg, aParam.mStickyPosScrollContainerId); - WriteParam(aMsg, aParam.mStickyScrollRangeOuter); - WriteParam(aMsg, aParam.mStickyScrollRangeInner); - WriteParam(aMsg, aParam.mStickyPositionAnimationId); - WriteParam(aMsg, aParam.mZoomAnimationId); - WriteParam(aMsg, aParam.mAsyncZoomContainerId); + MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mDescendantCount); + WriteParam(aWriter, aParam.mScrollIds); + WriteParam(aWriter, aParam.mAncestorTransform); + WriteParam(aWriter, aParam.mAncestorTransformId); + WriteParam(aWriter, aParam.mTransform); + WriteParam(aWriter, aParam.mTransformIsPerspective); + WriteParam(aWriter, aParam.mResolution); + WriteParam(aWriter, aParam.mVisibleRegion); + WriteParam(aWriter, aParam.mRemoteDocumentSize); + WriteParam(aWriter, aParam.mReferentId); + WriteParam(aWriter, aParam.mEventRegionsOverride); + WriteParam(aWriter, aParam.mScrollbarData); + WriteParam(aWriter, aParam.mScrollbarAnimationId); + WriteParam(aWriter, aParam.mFixedPositionAnimationId); + WriteParam(aWriter, aParam.mFixedPositionSides); + WriteParam(aWriter, aParam.mFixedPosScrollContainerId); + WriteParam(aWriter, aParam.mStickyPosScrollContainerId); + WriteParam(aWriter, aParam.mStickyScrollRangeOuter); + WriteParam(aWriter, aParam.mStickyScrollRangeInner); + WriteParam(aWriter, aParam.mStickyPositionAnimationId); + WriteParam(aWriter, aParam.mZoomAnimationId); + WriteParam(aWriter, aParam.mAsyncZoomContainerId); } bool ParamTraits::Read( - const Message* aMsg, PickleIterator* aIter, paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mDescendantCount) && - ReadParam(aMsg, aIter, &aResult->mScrollIds) && - ReadParam(aMsg, aIter, &aResult->mAncestorTransform) && - ReadParam(aMsg, aIter, &aResult->mAncestorTransformId) && - ReadParam(aMsg, aIter, &aResult->mTransform) && - ReadParam(aMsg, aIter, &aResult->mTransformIsPerspective) && - ReadParam(aMsg, aIter, &aResult->mResolution) && - ReadParam(aMsg, aIter, &aResult->mVisibleRegion) && - ReadParam(aMsg, aIter, &aResult->mRemoteDocumentSize) && - ReadParam(aMsg, aIter, &aResult->mReferentId) && - ReadParam(aMsg, aIter, &aResult->mEventRegionsOverride) && - ReadParam(aMsg, aIter, &aResult->mScrollbarData) && - ReadParam(aMsg, aIter, &aResult->mScrollbarAnimationId) && - ReadParam(aMsg, aIter, &aResult->mFixedPositionAnimationId) && - ReadParam(aMsg, aIter, &aResult->mFixedPositionSides) && - ReadParam(aMsg, aIter, &aResult->mFixedPosScrollContainerId) && - ReadParam(aMsg, aIter, &aResult->mStickyPosScrollContainerId) && - ReadParam(aMsg, aIter, &aResult->mStickyScrollRangeOuter) && - ReadParam(aMsg, aIter, &aResult->mStickyScrollRangeInner) && - ReadParam(aMsg, aIter, &aResult->mStickyPositionAnimationId) && - ReadParam(aMsg, aIter, &aResult->mZoomAnimationId) && - ReadParam(aMsg, aIter, &aResult->mAsyncZoomContainerId); + MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mDescendantCount) && + ReadParam(aReader, &aResult->mScrollIds) && + ReadParam(aReader, &aResult->mAncestorTransform) && + ReadParam(aReader, &aResult->mAncestorTransformId) && + ReadParam(aReader, &aResult->mTransform) && + ReadParam(aReader, &aResult->mTransformIsPerspective) && + ReadParam(aReader, &aResult->mResolution) && + ReadParam(aReader, &aResult->mVisibleRegion) && + ReadParam(aReader, &aResult->mRemoteDocumentSize) && + ReadParam(aReader, &aResult->mReferentId) && + ReadParam(aReader, &aResult->mEventRegionsOverride) && + ReadParam(aReader, &aResult->mScrollbarData) && + ReadParam(aReader, &aResult->mScrollbarAnimationId) && + ReadParam(aReader, &aResult->mFixedPositionAnimationId) && + ReadParam(aReader, &aResult->mFixedPositionSides) && + ReadParam(aReader, &aResult->mFixedPosScrollContainerId) && + ReadParam(aReader, &aResult->mStickyPosScrollContainerId) && + ReadParam(aReader, &aResult->mStickyScrollRangeOuter) && + ReadParam(aReader, &aResult->mStickyScrollRangeInner) && + ReadParam(aReader, &aResult->mStickyPositionAnimationId) && + ReadParam(aReader, &aResult->mZoomAnimationId) && + ReadParam(aReader, &aResult->mAsyncZoomContainerId); } void ParamTraits::Write( - Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mScrollMetadatas); - WriteParam(aMsg, aParam.mLayerScrollData); - WriteParam(aMsg, aParam.mIsFirstPaint); - WriteParam(aMsg, aParam.mPaintSequenceNumber); + MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mScrollMetadatas); + WriteParam(aWriter, aParam.mLayerScrollData); + WriteParam(aWriter, aParam.mIsFirstPaint); + WriteParam(aWriter, aParam.mPaintSequenceNumber); } bool ParamTraits::Read( - const Message* aMsg, PickleIterator* aIter, paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mScrollMetadatas) && - ReadParam(aMsg, aIter, &aResult->mLayerScrollData) && - ReadParam(aMsg, aIter, &aResult->mIsFirstPaint) && - ReadParam(aMsg, aIter, &aResult->mPaintSequenceNumber) && + MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mScrollMetadatas) && + ReadParam(aReader, &aResult->mLayerScrollData) && + ReadParam(aReader, &aResult->mIsFirstPaint) && + ReadParam(aReader, &aResult->mPaintSequenceNumber) && aResult->RepopulateMap(); } diff --git a/gfx/layers/wr/WebRenderScrollData.h b/gfx/layers/wr/WebRenderScrollData.h index c9074e93ea0f..5324ff9f19e3 100644 --- a/gfx/layers/wr/WebRenderScrollData.h +++ b/gfx/layers/wr/WebRenderScrollData.h @@ -328,20 +328,18 @@ template <> struct ParamTraits { typedef mozilla::layers::WebRenderLayerScrollData paramType; - static void Write(Message* aMsg, const paramType& aParam); + static void Write(MessageWriter* aWriter, const paramType& aParam); - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult); + static bool Read(MessageReader* aReader, paramType* aResult); }; template <> struct ParamTraits { typedef mozilla::layers::WebRenderScrollData paramType; - static void Write(Message* aMsg, const paramType& aParam); + static void Write(MessageWriter* aWriter, const paramType& aParam); - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult); + static bool Read(MessageReader* aReader, paramType* aResult); }; } // namespace IPC diff --git a/gfx/thebes/SharedFontList.h b/gfx/thebes/SharedFontList.h index 534dbeef6e1b..41858a309322 100644 --- a/gfx/thebes/SharedFontList.h +++ b/gfx/thebes/SharedFontList.h @@ -385,14 +385,13 @@ namespace IPC { template <> struct ParamTraits { typedef mozilla::fontlist::Pointer paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { uint32_t v = aParam.mBlockAndOffset; - WriteParam(aMsg, v); + WriteParam(aWriter, v); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { uint32_t v; - if (ReadParam(aMsg, aIter, &v)) { + if (ReadParam(aReader, &v)) { aResult->mBlockAndOffset.store(v); return true; } diff --git a/gfx/thebes/gfxFontUtils.h b/gfx/thebes/gfxFontUtils.h index 57cb3d235a65..e0d4b211a848 100644 --- a/gfx/thebes/gfxFontUtils.h +++ b/gfx/thebes/gfxFontUtils.h @@ -341,26 +341,24 @@ namespace IPC { template <> struct ParamTraits { typedef gfxSparseBitSet paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mBlockIndex); - WriteParam(aMsg, aParam.mBlocks); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mBlockIndex); + WriteParam(aWriter, aParam.mBlocks); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mBlockIndex) && - ReadParam(aMsg, aIter, &aResult->mBlocks); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mBlockIndex) && + ReadParam(aReader, &aResult->mBlocks); } }; template <> struct ParamTraits { typedef gfxSparseBitSet::Block paramType; - static void Write(Message* aMsg, const paramType& aParam) { - aMsg->WriteBytes(&aParam, sizeof(aParam)); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + aWriter->WriteBytes(&aParam, sizeof(aParam)); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return aMsg->ReadBytesInto(aIter, aResult, sizeof(*aResult)); + static bool Read(MessageReader* aReader, paramType* aResult) { + return aReader->ReadBytesInto(aResult, sizeof(*aResult)); } }; } // namespace IPC diff --git a/gfx/vr/ipc/VRMessageUtils.h b/gfx/vr/ipc/VRMessageUtils.h index df18456b51fd..0d19c9e4ecff 100644 --- a/gfx/vr/ipc/VRMessageUtils.h +++ b/gfx/vr/ipc/VRMessageUtils.h @@ -41,21 +41,20 @@ template <> struct ParamTraits { typedef mozilla::gfx::VRSubmitFrameResultInfo paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mBase64Image); - WriteParam(aMsg, aParam.mFormat); - WriteParam(aMsg, aParam.mWidth); - WriteParam(aMsg, aParam.mHeight); - WriteParam(aMsg, aParam.mFrameNum); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mBase64Image); + WriteParam(aWriter, aParam.mFormat); + WriteParam(aWriter, aParam.mWidth); + WriteParam(aWriter, aParam.mHeight); + WriteParam(aWriter, aParam.mFrameNum); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &(aResult->mBase64Image)) || - !ReadParam(aMsg, aIter, &(aResult->mFormat)) || - !ReadParam(aMsg, aIter, &(aResult->mWidth)) || - !ReadParam(aMsg, aIter, &(aResult->mHeight)) || - !ReadParam(aMsg, aIter, &(aResult->mFrameNum))) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &(aResult->mBase64Image)) || + !ReadParam(aReader, &(aResult->mFormat)) || + !ReadParam(aReader, &(aResult->mWidth)) || + !ReadParam(aReader, &(aResult->mHeight)) || + !ReadParam(aReader, &(aResult->mFrameNum))) { return false; } diff --git a/ipc/chromium/src/chrome/common/ipc_message_utils.h b/ipc/chromium/src/chrome/common/ipc_message_utils.h index f28c6673dd13..2ee9b8c60e41 100644 --- a/ipc/chromium/src/chrome/common/ipc_message_utils.h +++ b/ipc/chromium/src/chrome/common/ipc_message_utils.h @@ -276,14 +276,13 @@ template struct ParamTraits; template -static inline void WriteParam(Message* m, P&& p) { - ParamTraits>::Write(m, std::forward

(p)); +static inline void WriteParam(MessageWriter* writer, P&& p) { + ParamTraits>::Write(writer, std::forward

(p)); } template -static inline bool WARN_UNUSED_RESULT ReadParam(const Message* m, - PickleIterator* iter, P* p) { - return ParamTraits

::Read(m, iter, p); +static inline bool WARN_UNUSED_RESULT ReadParam(MessageReader* reader, P* p) { + return ParamTraits

::Read(reader, p); } template @@ -299,9 +298,11 @@ struct ParamTraitsFundamental {}; template <> struct ParamTraitsFundamental { typedef bool param_type; - static void Write(Message* m, const param_type& p) { m->WriteBool(p); } - static bool Read(const Message* m, PickleIterator* iter, param_type* r) { - return m->ReadBool(iter, r); + static void Write(MessageWriter* writer, const param_type& p) { + writer->WriteBool(p); + } + static bool Read(MessageReader* reader, param_type* r) { + return reader->ReadBool(r); } static void Log(const param_type& p, std::wstring* l) { l->append(p ? L"true" : L"false"); @@ -311,9 +312,11 @@ struct ParamTraitsFundamental { template <> struct ParamTraitsFundamental { typedef int param_type; - static void Write(Message* m, const param_type& p) { m->WriteInt(p); } - static bool Read(const Message* m, PickleIterator* iter, param_type* r) { - return m->ReadInt(iter, r); + static void Write(MessageWriter* writer, const param_type& p) { + writer->WriteInt(p); + } + static bool Read(MessageReader* reader, param_type* r) { + return reader->ReadInt(r); } static void Log(const param_type& p, std::wstring* l) { l->append(StringPrintf(L"%d", p)); @@ -323,9 +326,11 @@ struct ParamTraitsFundamental { template <> struct ParamTraitsFundamental { typedef long param_type; - static void Write(Message* m, const param_type& p) { m->WriteLong(p); } - static bool Read(const Message* m, PickleIterator* iter, param_type* r) { - return m->ReadLong(iter, r); + static void Write(MessageWriter* writer, const param_type& p) { + writer->WriteLong(p); + } + static bool Read(MessageReader* reader, param_type* r) { + return reader->ReadLong(r); } static void Log(const param_type& p, std::wstring* l) { l->append(StringPrintf(L"%l", p)); @@ -335,9 +340,11 @@ struct ParamTraitsFundamental { template <> struct ParamTraitsFundamental { typedef unsigned long param_type; - static void Write(Message* m, const param_type& p) { m->WriteULong(p); } - static bool Read(const Message* m, PickleIterator* iter, param_type* r) { - return m->ReadULong(iter, r); + static void Write(MessageWriter* writer, const param_type& p) { + writer->WriteULong(p); + } + static bool Read(MessageReader* reader, param_type* r) { + return reader->ReadULong(r); } static void Log(const param_type& p, std::wstring* l) { l->append(StringPrintf(L"%ul", p)); @@ -347,11 +354,11 @@ struct ParamTraitsFundamental { template <> struct ParamTraitsFundamental { typedef long long param_type; - static void Write(Message* m, const param_type& p) { - m->WriteBytes(&p, sizeof(param_type)); + static void Write(MessageWriter* writer, const param_type& p) { + writer->WriteBytes(&p, sizeof(param_type)); } - static bool Read(const Message* m, PickleIterator* iter, param_type* r) { - return m->ReadBytesInto(iter, r, sizeof(*r)); + static bool Read(MessageReader* reader, param_type* r) { + return reader->ReadBytesInto(r, sizeof(*r)); } static void Log(const param_type& p, std::wstring* l) { l->append(StringPrintf(L"%ll", p)); @@ -361,11 +368,11 @@ struct ParamTraitsFundamental { template <> struct ParamTraitsFundamental { typedef unsigned long long param_type; - static void Write(Message* m, const param_type& p) { - m->WriteBytes(&p, sizeof(param_type)); + static void Write(MessageWriter* writer, const param_type& p) { + writer->WriteBytes(&p, sizeof(param_type)); } - static bool Read(const Message* m, PickleIterator* iter, param_type* r) { - return m->ReadBytesInto(iter, r, sizeof(*r)); + static bool Read(MessageReader* reader, param_type* r) { + return reader->ReadBytesInto(r, sizeof(*r)); } static void Log(const param_type& p, std::wstring* l) { l->append(StringPrintf(L"%ull", p)); @@ -375,9 +382,11 @@ struct ParamTraitsFundamental { template <> struct ParamTraitsFundamental { typedef double param_type; - static void Write(Message* m, const param_type& p) { m->WriteDouble(p); } - static bool Read(const Message* m, PickleIterator* iter, param_type* r) { - return m->ReadDouble(iter, r); + static void Write(MessageWriter* writer, const param_type& p) { + writer->WriteDouble(p); + } + static bool Read(MessageReader* reader, param_type* r) { + return reader->ReadDouble(r); } static void Log(const param_type& p, std::wstring* l) { l->append(StringPrintf(L"e", p)); @@ -392,9 +401,11 @@ struct ParamTraitsFixed : ParamTraitsFundamental

{}; template <> struct ParamTraitsFixed { typedef int16_t param_type; - static void Write(Message* m, const param_type& p) { m->WriteInt16(p); } - static bool Read(const Message* m, PickleIterator* iter, param_type* r) { - return m->ReadInt16(iter, r); + static void Write(MessageWriter* writer, const param_type& p) { + writer->WriteInt16(p); + } + static bool Read(MessageReader* reader, param_type* r) { + return reader->ReadInt16(r); } static void Log(const param_type& p, std::wstring* l) { l->append(StringPrintf(L"%hd", p)); @@ -404,9 +415,11 @@ struct ParamTraitsFixed { template <> struct ParamTraitsFixed { typedef uint16_t param_type; - static void Write(Message* m, const param_type& p) { m->WriteUInt16(p); } - static bool Read(const Message* m, PickleIterator* iter, param_type* r) { - return m->ReadUInt16(iter, r); + static void Write(MessageWriter* writer, const param_type& p) { + writer->WriteUInt16(p); + } + static bool Read(MessageReader* reader, param_type* r) { + return reader->ReadUInt16(r); } static void Log(const param_type& p, std::wstring* l) { l->append(StringPrintf(L"%hu", p)); @@ -416,9 +429,11 @@ struct ParamTraitsFixed { template <> struct ParamTraitsFixed { typedef uint32_t param_type; - static void Write(Message* m, const param_type& p) { m->WriteUInt32(p); } - static bool Read(const Message* m, PickleIterator* iter, param_type* r) { - return m->ReadUInt32(iter, r); + static void Write(MessageWriter* writer, const param_type& p) { + writer->WriteUInt32(p); + } + static bool Read(MessageReader* reader, param_type* r) { + return reader->ReadUInt32(r); } static void Log(const param_type& p, std::wstring* l) { l->append(StringPrintf(L"%u", p)); @@ -428,9 +443,11 @@ struct ParamTraitsFixed { template <> struct ParamTraitsFixed { typedef int64_t param_type; - static void Write(Message* m, const param_type& p) { m->WriteInt64(p); } - static bool Read(const Message* m, PickleIterator* iter, param_type* r) { - return m->ReadInt64(iter, r); + static void Write(MessageWriter* writer, const param_type& p) { + writer->WriteInt64(p); + } + static bool Read(MessageReader* reader, param_type* r) { + return reader->ReadInt64(r); } static void Log(const param_type& p, std::wstring* l) { l->append(StringPrintf(L"%" PRId64L, p)); @@ -440,11 +457,11 @@ struct ParamTraitsFixed { template <> struct ParamTraitsFixed { typedef uint64_t param_type; - static void Write(Message* m, const param_type& p) { - m->WriteInt64(static_cast(p)); + static void Write(MessageWriter* writer, const param_type& p) { + writer->WriteInt64(static_cast(p)); } - static bool Read(const Message* m, PickleIterator* iter, param_type* r) { - return m->ReadInt64(iter, reinterpret_cast(r)); + static bool Read(MessageReader* reader, param_type* r) { + return reader->ReadInt64(reinterpret_cast(r)); } static void Log(const param_type& p, std::wstring* l) { l->append(StringPrintf(L"%" PRIu64L, p)); @@ -459,9 +476,11 @@ struct ParamTraitsStd : ParamTraitsFixed

{}; template <> struct ParamTraitsStd { typedef std::string param_type; - static void Write(Message* m, const param_type& p) { m->WriteString(p); } - static bool Read(const Message* m, PickleIterator* iter, param_type* r) { - return m->ReadString(iter, r); + static void Write(MessageWriter* writer, const param_type& p) { + writer->WriteString(p); + } + static bool Read(MessageReader* reader, param_type* r) { + return reader->ReadString(r); } static void Log(const param_type& p, std::wstring* l) { l->append(UTF8ToWide(p)); @@ -471,9 +490,11 @@ struct ParamTraitsStd { template <> struct ParamTraitsStd { typedef std::wstring param_type; - static void Write(Message* m, const param_type& p) { m->WriteWString(p); } - static bool Read(const Message* m, PickleIterator* iter, param_type* r) { - return m->ReadWString(iter, r); + static void Write(MessageWriter* writer, const param_type& p) { + writer->WriteWString(p); + } + static bool Read(MessageReader* reader, param_type* r) { + return reader->ReadWString(r); } static void Log(const param_type& p, std::wstring* l) { l->append(p); } }; @@ -481,22 +502,22 @@ struct ParamTraitsStd { template struct ParamTraitsStd> { typedef std::map param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, static_cast(p.size())); + static void Write(MessageWriter* writer, const param_type& p) { + WriteParam(writer, static_cast(p.size())); typename param_type::const_iterator iter; for (iter = p.begin(); iter != p.end(); ++iter) { - WriteParam(m, iter->first); - WriteParam(m, iter->second); + WriteParam(writer, iter->first); + WriteParam(writer, iter->second); } } - static bool Read(const Message* m, PickleIterator* iter, param_type* r) { + static bool Read(MessageReader* reader, param_type* r) { int size; - if (!ReadParam(m, iter, &size) || size < 0) return false; + if (!ReadParam(reader, &size) || size < 0) return false; for (int i = 0; i < size; ++i) { K k; - if (!ReadParam(m, iter, &k)) return false; + if (!ReadParam(reader, &k)) return false; V& value = (*r)[k]; - if (!ReadParam(m, iter, &value)) return false; + if (!ReadParam(reader, &value)) return false; } return true; } @@ -515,11 +536,11 @@ template <> struct ParamTraitsWindows { static_assert(sizeof(HANDLE) == sizeof(intptr_t), "Wrong size for HANDLE?"); - static void Write(Message* m, HANDLE p) { - m->WriteIntPtr(reinterpret_cast(p)); + static void Write(MessageWriter* writer, HANDLE p) { + writer->WriteIntPtr(reinterpret_cast(p)); } - static bool Read(const Message* m, PickleIterator* iter, HANDLE* r) { - return m->ReadIntPtr(iter, reinterpret_cast(r)); + static bool Read(MessageReader* reader, HANDLE* r) { + return reader->ReadIntPtr(reinterpret_cast(r)); } static void Log(const HANDLE& p, std::wstring* l) { l->append(StringPrintf(L"0x%X", p)); @@ -530,11 +551,11 @@ template <> struct ParamTraitsWindows { static_assert(sizeof(HWND) == sizeof(intptr_t), "Wrong size for HWND?"); - static void Write(Message* m, HWND p) { - m->WriteIntPtr(reinterpret_cast(p)); + static void Write(MessageWriter* writer, HWND p) { + writer->WriteIntPtr(reinterpret_cast(p)); } - static bool Read(const Message* m, PickleIterator* iter, HWND* r) { - return m->ReadIntPtr(iter, reinterpret_cast(r)); + static bool Read(MessageReader* reader, HWND* r) { + return reader->ReadIntPtr(reinterpret_cast(r)); } static void Log(const HWND& p, std::wstring* l) { l->append(StringPrintf(L"0x%X", p)); @@ -560,18 +581,18 @@ struct ParamTraitsIPC : ParamTraitsWindows

{}; template <> struct ParamTraitsIPC { typedef mozilla::UniqueFileHandle param_type; - static void Write(Message* m, param_type&& p) { + static void Write(MessageWriter* writer, param_type&& p) { const bool valid = p != nullptr; - WriteParam(m, valid); + WriteParam(writer, valid); if (valid) { - if (!m->WriteFileHandle(std::move(p))) { + if (!writer->WriteFileHandle(std::move(p))) { NOTREACHED() << "Too many file handles for one message!"; } } } - static bool Read(const Message* m, PickleIterator* iter, param_type* r) { + static bool Read(MessageReader* reader, param_type* r) { bool valid; - if (!ReadParam(m, iter, &valid)) { + if (!ReadParam(reader, &valid)) { return false; } @@ -580,7 +601,7 @@ struct ParamTraitsIPC { return true; } - return m->ConsumeFileHandle(iter, r); + return reader->ConsumeFileHandle(r); } }; @@ -598,18 +619,18 @@ struct ParamTraitsIPC { template <> struct ParamTraitsIPC { typedef mozilla::UniqueMachSendRight param_type; - static void Write(Message* m, param_type&& p) { + static void Write(MessageWriter* writer, param_type&& p) { const bool valid = p != nullptr; - WriteParam(m, valid); + WriteParam(writer, valid); if (valid) { - if (!m->WriteMachSendRight(std::move(p))) { + if (!writer->WriteMachSendRight(std::move(p))) { NOTREACHED() << "Too many mach send rights for one message!"; } } } - static bool Read(const Message* m, PickleIterator* iter, param_type* r) { + static bool Read(MessageReader* reader, param_type* r) { bool valid; - if (!ReadParam(m, iter, &valid)) { + if (!ReadParam(reader, &valid)) { return false; } @@ -618,7 +639,7 @@ struct ParamTraitsIPC { return true; } - return m->ConsumeMachSendRight(iter, r); + return reader->ConsumeMachSendRight(r); } }; #endif @@ -631,11 +652,11 @@ struct ParamTraitsMozilla : ParamTraitsIPC

{}; template <> struct ParamTraitsMozilla { typedef nsresult param_type; - static void Write(Message* m, const param_type& p) { - m->WriteUInt32(static_cast(p)); + static void Write(MessageWriter* writer, const param_type& p) { + writer->WriteUInt32(static_cast(p)); } - static bool Read(const Message* m, PickleIterator* iter, param_type* r) { - return m->ReadUInt32(iter, reinterpret_cast(r)); + static bool Read(MessageReader* reader, param_type* r) { + return reader->ReadUInt32(reinterpret_cast(r)); } static void Log(const param_type& p, std::wstring* l) { l->append(StringPrintf(L"%u", static_cast(p))); @@ -646,24 +667,24 @@ struct ParamTraitsMozilla { // nsCOMPtr for more details. template struct ParamTraitsMozilla> { - static void Write(Message* m, const RefPtr& p) { - ParamTraits::Write(m, p.get()); + static void Write(MessageWriter* writer, const RefPtr& p) { + ParamTraits::Write(writer, p.get()); } - static bool Read(const Message* m, PickleIterator* iter, RefPtr* r) { - return ParamTraits::Read(m, iter, r); + static bool Read(MessageReader* reader, RefPtr* r) { + return ParamTraits::Read(reader, r); } }; template struct ParamTraitsMozilla> { - static void Write(Message* m, const nsCOMPtr& p) { - ParamTraits::Write(m, p.get()); + static void Write(MessageWriter* writer, const nsCOMPtr& p) { + ParamTraits::Write(writer, p.get()); } - static bool Read(const Message* m, PickleIterator* iter, nsCOMPtr* r) { + static bool Read(MessageReader* reader, nsCOMPtr* r) { RefPtr refptr; - if (!ParamTraits::Read(m, iter, &refptr)) { + if (!ParamTraits::Read(reader, &refptr)) { return false; } *r = std::move(refptr); diff --git a/ipc/chromium/src/mojo/core/ports/name.cc b/ipc/chromium/src/mojo/core/ports/name.cc index 2911b32a8e5a..17a787d93348 100644 --- a/ipc/chromium/src/mojo/core/ports/name.cc +++ b/ipc/chromium/src/mojo/core/ports/name.cc @@ -32,27 +32,23 @@ mozilla::Logger& operator<<(mozilla::Logger& log, const Name& name) { } // namespace mojo void IPC::ParamTraits::Write( - Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.v1); - WriteParam(aMsg, aParam.v2); + MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.v1); + WriteParam(aWriter, aParam.v2); } -bool IPC::ParamTraits::Read(const Message* aMsg, - PickleIterator* aIter, +bool IPC::ParamTraits::Read(MessageReader* aReader, paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->v1) && - ReadParam(aMsg, aIter, &aResult->v2); + return ReadParam(aReader, &aResult->v1) && ReadParam(aReader, &aResult->v2); } void IPC::ParamTraits::Write( - Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.v1); - WriteParam(aMsg, aParam.v2); + MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.v1); + WriteParam(aWriter, aParam.v2); } -bool IPC::ParamTraits::Read(const Message* aMsg, - PickleIterator* aIter, +bool IPC::ParamTraits::Read(MessageReader* aReader, paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->v1) && - ReadParam(aMsg, aIter, &aResult->v2); + return ReadParam(aReader, &aResult->v1) && ReadParam(aReader, &aResult->v2); } diff --git a/ipc/chromium/src/mojo/core/ports/name.h b/ipc/chromium/src/mojo/core/ports/name.h index 30a9ffa18f11..0e668ebc4019 100644 --- a/ipc/chromium/src/mojo/core/ports/name.h +++ b/ipc/chromium/src/mojo/core/ports/name.h @@ -106,17 +106,15 @@ class MessageWriter; template <> struct ParamTraits { using paramType = mojo::core::ports::PortName; - static void Write(Message* aMsg, const paramType& aParam); - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult); + static void Write(MessageWriter* aWriter, const paramType& aParam); + static bool Read(MessageReader* aReader, paramType* aResult); }; template <> struct ParamTraits { using paramType = mojo::core::ports::NodeName; - static void Write(Message* aMsg, const paramType& aParam); - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult); + static void Write(MessageWriter* aWriter, const paramType& aParam); + static bool Read(MessageReader* aReader, paramType* aResult); }; } // namespace IPC diff --git a/ipc/glue/BackgroundUtils.h b/ipc/glue/BackgroundUtils.h index 8a9c4e2aa0fa..518f8a29fe93 100644 --- a/ipc/glue/BackgroundUtils.h +++ b/ipc/glue/BackgroundUtils.h @@ -26,17 +26,15 @@ template struct OriginAttributesParamTraits { typedef ParamType paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { nsAutoCString suffix; aParam.CreateSuffix(suffix); - WriteParam(aMsg, suffix); + WriteParam(aWriter, suffix); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { nsAutoCString suffix; - return ReadParam(aMsg, aIter, &suffix) && - aResult->PopulateFromSuffix(suffix); + return ReadParam(aReader, &suffix) && aResult->PopulateFromSuffix(suffix); } }; } // namespace detail diff --git a/ipc/glue/ByteBufUtils.h b/ipc/glue/ByteBufUtils.h index 05af74cb534b..813068dc907e 100644 --- a/ipc/glue/ByteBufUtils.h +++ b/ipc/glue/ByteBufUtils.h @@ -24,34 +24,33 @@ struct ParamTraits { // this is where we transfer the memory from the ByteBuf to IPDL, avoiding a // copy - static void Write(Message* aMsg, paramType&& aParam) { + static void Write(MessageWriter* aWriter, paramType&& aParam) { // We need to send the length as a 32-bit value, not a size_t, because on // ARM64 Windows we end up with a 32-bit GMP process sending a ByteBuf to // a 64-bit parent process. WriteBytesZeroCopy takes a uint32_t as an // argument, so it would end up getting truncated anyways. See bug 1757534. mozilla::CheckedInt length = aParam.mLen; MOZ_RELEASE_ASSERT(length.isValid()); - WriteParam(aMsg, length.value()); + WriteParam(aWriter, length.value()); // hand over ownership of the buffer to the Message - aMsg->WriteBytesZeroCopy(aParam.mData, length.value(), aParam.mCapacity); + aWriter->WriteBytesZeroCopy(aParam.mData, length.value(), aParam.mCapacity); aParam.mData = nullptr; aParam.mCapacity = 0; aParam.mLen = 0; } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { // We make a copy from the BufferList so that we get a contigous result. // For users the can handle a non-contiguous result using ExtractBuffers // is an option, alternatively if the users don't need to take ownership of // the data they can use the removed FlattenBytes (bug 1297981) uint32_t length; - if (!ReadParam(aMsg, aIter, &length)) return false; + if (!ReadParam(aReader, &length)) return false; if (!aResult->Allocate(length)) { mozalloc_handle_oom(length); return false; } - return aMsg->ReadBytesInto(aIter, aResult->mData, length); + return aReader->ReadBytesInto(aResult->mData, length); } static void Log(const paramType& aParam, std::wstring* aLog) { diff --git a/ipc/glue/DataPipe.cpp b/ipc/glue/DataPipe.cpp index 8a43598e1222..a91855184720 100644 --- a/ipc/glue/DataPipe.cpp +++ b/ipc/glue/DataPipe.cpp @@ -413,12 +413,12 @@ nsCString DataPipeBase::Describe(DataPipeAutoLock& aLock) { } template -void DataPipeWrite(IPC::Message* aMsg, T* aParam) { +void DataPipeWrite(IPC::MessageWriter* aWriter, T* aParam) { DataPipeAutoLock lock(*aParam->mMutex); MOZ_LOG(gDataPipeLog, LogLevel::Debug, ("IPC Write: %s", aParam->Describe(lock).get())); - WriteParam(aMsg, aParam->mStatus); + WriteParam(aWriter, aParam->mStatus); if (NS_FAILED(aParam->mStatus)) { return; } @@ -427,12 +427,12 @@ void DataPipeWrite(IPC::Message* aMsg, T* aParam) { "cannot transfer while processing a segment"); // Serialize relevant parameters to our peer. - WriteParam(aMsg, std::move(aParam->mLink->mPort)); - MOZ_ALWAYS_TRUE(aParam->mLink->mShmem->WriteHandle(aMsg)); - WriteParam(aMsg, aParam->mLink->mCapacity); - WriteParam(aMsg, aParam->mLink->mPeerStatus); - WriteParam(aMsg, aParam->mLink->mOffset); - WriteParam(aMsg, aParam->mLink->mAvailable); + WriteParam(aWriter, std::move(aParam->mLink->mPort)); + MOZ_ALWAYS_TRUE(aParam->mLink->mShmem->WriteHandle(aWriter)); + WriteParam(aWriter, aParam->mLink->mCapacity); + WriteParam(aWriter, aParam->mLink->mPeerStatus); + WriteParam(aWriter, aParam->mLink->mOffset); + WriteParam(aWriter, aParam->mLink->mAvailable); // Mark our peer as closed so we don't try to send to it when closing. aParam->mLink->mPeerStatus = NS_ERROR_NOT_INITIALIZED; @@ -440,10 +440,9 @@ void DataPipeWrite(IPC::Message* aMsg, T* aParam) { } template -bool DataPipeRead(const IPC::Message* aMsg, PickleIterator* aIter, - RefPtr* aResult) { +bool DataPipeRead(IPC::MessageReader* aReader, RefPtr* aResult) { nsresult rv = NS_OK; - if (!ReadParam(aMsg, aIter, &rv)) { + if (!ReadParam(aReader, &rv)) { NS_WARNING("failed to read status!"); return false; } @@ -460,10 +459,9 @@ bool DataPipeRead(const IPC::Message* aMsg, PickleIterator* aIter, nsresult peerStatus = NS_OK; uint32_t offset = 0; uint32_t available = 0; - if (!ReadParam(aMsg, aIter, &port) || !shmem->ReadHandle(aMsg, aIter) || - !ReadParam(aMsg, aIter, &capacity) || - !ReadParam(aMsg, aIter, &peerStatus) || - !ReadParam(aMsg, aIter, &offset) || !ReadParam(aMsg, aIter, &available)) { + if (!ReadParam(aReader, &port) || !shmem->ReadHandle(aReader) || + !ReadParam(aReader, &capacity) || !ReadParam(aReader, &peerStatus) || + !ReadParam(aReader, &offset) || !ReadParam(aReader, &available)) { NS_WARNING("failed to read fields!"); return false; } @@ -685,23 +683,21 @@ nsresult NewDataPipe(uint32_t aCapacity, DataPipeSender** aSender, } // namespace mozilla void IPC::ParamTraits::Write( - Message* aMsg, mozilla::ipc::DataPipeSender* aParam) { - mozilla::ipc::data_pipe_detail::DataPipeWrite(aMsg, aParam); + MessageWriter* aWriter, mozilla::ipc::DataPipeSender* aParam) { + mozilla::ipc::data_pipe_detail::DataPipeWrite(aWriter, aParam); } bool IPC::ParamTraits::Read( - const Message* aMsg, PickleIterator* aIter, - RefPtr* aResult) { - return mozilla::ipc::data_pipe_detail::DataPipeRead(aMsg, aIter, aResult); + MessageReader* aReader, RefPtr* aResult) { + return mozilla::ipc::data_pipe_detail::DataPipeRead(aReader, aResult); } void IPC::ParamTraits::Write( - Message* aMsg, mozilla::ipc::DataPipeReceiver* aParam) { - mozilla::ipc::data_pipe_detail::DataPipeWrite(aMsg, aParam); + MessageWriter* aWriter, mozilla::ipc::DataPipeReceiver* aParam) { + mozilla::ipc::data_pipe_detail::DataPipeWrite(aWriter, aParam); } bool IPC::ParamTraits::Read( - const Message* aMsg, PickleIterator* aIter, - RefPtr* aResult) { - return mozilla::ipc::data_pipe_detail::DataPipeRead(aMsg, aIter, aResult); + MessageReader* aReader, RefPtr* aResult) { + return mozilla::ipc::data_pipe_detail::DataPipeRead(aReader, aResult); } diff --git a/ipc/glue/DataPipe.h b/ipc/glue/DataPipe.h index fa2c2336b7d6..51d4e1c855d5 100644 --- a/ipc/glue/DataPipe.h +++ b/ipc/glue/DataPipe.h @@ -59,11 +59,10 @@ class DataPipeBase { }; template -void DataPipeWrite(IPC::Message* aMsg, T* aParam); +void DataPipeWrite(IPC::MessageWriter* aWriter, T* aParam); template -bool DataPipeRead(const IPC::Message* aMsg, PickleIterator* aIter, - RefPtr* aResult); +bool DataPipeRead(IPC::MessageReader* aReader, RefPtr* aResult); } // namespace data_pipe_detail @@ -89,10 +88,9 @@ class DataPipeSender final : public nsIAsyncOutputStream, private: friend nsresult NewDataPipe(uint32_t, DataPipeSender**, DataPipeReceiver**); friend void data_pipe_detail::DataPipeWrite( - IPC::Message* aMsg, DataPipeSender* aParam); + IPC::MessageWriter* aWriter, DataPipeSender* aParam); friend bool data_pipe_detail::DataPipeRead( - const IPC::Message* aMsg, PickleIterator* aIter, - RefPtr* aResult); + IPC::MessageReader* aReader, RefPtr* aResult); explicit DataPipeSender(nsresult aError) : data_pipe_detail::DataPipeBase(/* aReceiverSide */ false, aError) {} @@ -128,10 +126,9 @@ class DataPipeReceiver final : public nsIAsyncInputStream, private: friend nsresult NewDataPipe(uint32_t, DataPipeSender**, DataPipeReceiver**); friend void data_pipe_detail::DataPipeWrite( - IPC::Message* aMsg, DataPipeReceiver* aParam); + IPC::MessageWriter* aWriter, DataPipeReceiver* aParam); friend bool data_pipe_detail::DataPipeRead( - const IPC::Message* aMsg, PickleIterator* aIter, - RefPtr* aResult); + IPC::MessageReader* aReader, RefPtr* aResult); explicit DataPipeReceiver(nsresult aError) : data_pipe_detail::DataPipeBase(/* aReceiverSide */ true, aError) {} @@ -164,15 +161,17 @@ namespace IPC { template <> struct ParamTraits { - static void Write(Message* aMsg, mozilla::ipc::DataPipeSender* aParam); - static bool Read(const Message* aMsg, PickleIterator* aIter, + static void Write(MessageWriter* aWriter, + mozilla::ipc::DataPipeSender* aParam); + static bool Read(MessageReader* aReader, RefPtr* aResult); }; template <> struct ParamTraits { - static void Write(Message* aMsg, mozilla::ipc::DataPipeReceiver* aParam); - static bool Read(const Message* aMsg, PickleIterator* aIter, + static void Write(MessageWriter* aWriter, + mozilla::ipc::DataPipeReceiver* aParam); + static bool Read(MessageReader* aReader, RefPtr* aResult); }; diff --git a/ipc/glue/Endpoint.cpp b/ipc/glue/Endpoint.cpp index e6fa5727a7af..38af3c3915b2 100644 --- a/ipc/glue/Endpoint.cpp +++ b/ipc/glue/Endpoint.cpp @@ -96,11 +96,11 @@ bool UntypedManagedEndpoint::BindCommon(IProtocol* aActor, } /* static */ -void IPDLParamTraits::Write(IPC::Message* aMsg, +void IPDLParamTraits::Write(IPC::MessageWriter* aWriter, IProtocol* aActor, paramType&& aParam) { bool isValid = aParam.mInner.isSome(); - WriteIPDLParam(aMsg, aActor, isValid); + WriteIPDLParam(aWriter, aActor, isValid); if (!isValid) { return; } @@ -116,20 +116,19 @@ void IPDLParamTraits::Write(IPC::Message* aMsg, aActor->ToplevelProtocol(), "Must be being sent over the same toplevel protocol"); - WriteIPDLParam(aMsg, aActor, inner.mId); - WriteIPDLParam(aMsg, aActor, inner.mType); - WriteIPDLParam(aMsg, aActor, inner.mManagerId); - WriteIPDLParam(aMsg, aActor, inner.mManagerType); + WriteIPDLParam(aWriter, aActor, inner.mId); + WriteIPDLParam(aWriter, aActor, inner.mType); + WriteIPDLParam(aWriter, aActor, inner.mManagerId); + WriteIPDLParam(aWriter, aActor, inner.mManagerType); } /* static */ -bool IPDLParamTraits::Read(const IPC::Message* aMsg, - PickleIterator* aIter, +bool IPDLParamTraits::Read(IPC::MessageReader* aReader, IProtocol* aActor, paramType* aResult) { *aResult = UntypedManagedEndpoint{}; bool isValid = false; - if (!aActor || !ReadIPDLParam(aMsg, aIter, aActor, &isValid)) { + if (!aActor || !ReadIPDLParam(aReader, aActor, &isValid)) { return false; } if (!isValid) { @@ -139,10 +138,10 @@ bool IPDLParamTraits::Read(const IPC::Message* aMsg, aResult->mInner.emplace(); auto& inner = *aResult->mInner; inner.mToplevel = aActor->ToplevelProtocol()->GetWeakLifecycleProxy(); - return ReadIPDLParam(aMsg, aIter, aActor, &inner.mId) && - ReadIPDLParam(aMsg, aIter, aActor, &inner.mType) && - ReadIPDLParam(aMsg, aIter, aActor, &inner.mManagerId) && - ReadIPDLParam(aMsg, aIter, aActor, &inner.mManagerType); + return ReadIPDLParam(aReader, aActor, &inner.mId) && + ReadIPDLParam(aReader, aActor, &inner.mType) && + ReadIPDLParam(aReader, aActor, &inner.mManagerId) && + ReadIPDLParam(aReader, aActor, &inner.mManagerType); } } // namespace mozilla::ipc diff --git a/ipc/glue/EnumSerializer.h b/ipc/glue/EnumSerializer.h index 7f3e7a6d849a..13c1de3841ed 100644 --- a/ipc/glue/EnumSerializer.h +++ b/ipc/glue/EnumSerializer.h @@ -53,19 +53,18 @@ struct EnumSerializer { typedef typename mozilla::UnsignedStdintTypeForSize::Type uintParamType; - static void Write(Message* aMsg, const paramType& aValue) { + static void Write(MessageWriter* aWriter, const paramType& aValue) { // XXX This assertion is somewhat meaningless at least for E that don't have // a fixed underlying type: if aValue weren't a legal value, we would // already have UB where this function is called. MOZ_RELEASE_ASSERT(EnumValidator::IsLegalValue( static_cast>(aValue))); - WriteParam(aMsg, uintParamType(aValue)); + WriteParam(aWriter, uintParamType(aValue)); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { uintParamType value; - if (!ReadParam(aMsg, aIter, &value)) { + if (!ReadParam(aReader, &value)) { CrashReporter::AnnotateCrashReport( CrashReporter::Annotation::IPCReadErrorReason, "Bad iter"_ns); return false; diff --git a/ipc/glue/FileDescriptor.cpp b/ipc/glue/FileDescriptor.cpp index a0e4b6f87293..697de4cc6350 100644 --- a/ipc/glue/FileDescriptor.cpp +++ b/ipc/glue/FileDescriptor.cpp @@ -92,18 +92,17 @@ FileDescriptor::UniquePlatformHandle FileDescriptor::Clone( return UniqueFileHandle(); } -void IPDLParamTraits::Write(IPC::Message* aMsg, +void IPDLParamTraits::Write(IPC::MessageWriter* aWriter, IProtocol* aActor, const FileDescriptor& aParam) { - WriteIPDLParam(aMsg, aActor, aParam.ClonePlatformHandle()); + WriteIPDLParam(aWriter, aActor, aParam.ClonePlatformHandle()); } -bool IPDLParamTraits::Read(const IPC::Message* aMsg, - PickleIterator* aIter, +bool IPDLParamTraits::Read(IPC::MessageReader* aReader, IProtocol* aActor, FileDescriptor* aResult) { UniqueFileHandle handle; - if (!ReadIPDLParam(aMsg, aIter, aActor, &handle)) { + if (!ReadIPDLParam(aReader, aActor, &handle)) { return false; } diff --git a/ipc/glue/IPCMessageUtils.h b/ipc/glue/IPCMessageUtils.h index afcc5305a77c..b78c36f737fb 100644 --- a/ipc/glue/IPCMessageUtils.h +++ b/ipc/glue/IPCMessageUtils.h @@ -69,13 +69,12 @@ struct PlainOldDataSerializer { typedef T paramType; - static void Write(Message* aMsg, const paramType& aParam) { - aMsg->WriteBytes(&aParam, sizeof(aParam)); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + aWriter->WriteBytes(&aParam, sizeof(aParam)); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return aMsg->ReadBytesInto(aIter, aResult, sizeof(paramType)); + static bool Read(MessageReader* aReader, paramType* aResult) { + return aReader->ReadBytesInto(aResult, sizeof(paramType)); } }; @@ -87,10 +86,9 @@ template struct EmptyStructSerializer { typedef T paramType; - static void Write(Message* aMsg, const paramType& aParam) {} + static void Write(MessageWriter* aWriter, const paramType& aParam) {} - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { *aResult = {}; return true; } @@ -100,13 +98,12 @@ template <> struct ParamTraits { typedef int8_t paramType; - static void Write(Message* aMsg, const paramType& aParam) { - aMsg->WriteBytes(&aParam, sizeof(aParam)); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + aWriter->WriteBytes(&aParam, sizeof(aParam)); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return aMsg->ReadBytesInto(aIter, aResult, sizeof(*aResult)); + static bool Read(MessageReader* aReader, paramType* aResult) { + return aReader->ReadBytesInto(aResult, sizeof(*aResult)); } static void Log(const paramType& aParam, std::wstring* aLog) { @@ -119,13 +116,12 @@ template <> struct ParamTraits { typedef uint8_t paramType; - static void Write(Message* aMsg, const paramType& aParam) { - aMsg->WriteBytes(&aParam, sizeof(aParam)); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + aWriter->WriteBytes(&aParam, sizeof(aParam)); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return aMsg->ReadBytesInto(aIter, aResult, sizeof(*aResult)); + static bool Read(MessageReader* aReader, paramType* aResult) { + return aReader->ReadBytesInto(aResult, sizeof(*aResult)); } static void Log(const paramType& aParam, std::wstring* aLog) { @@ -138,11 +134,10 @@ struct ParamTraits { template <> struct ParamTraits { typedef base::FileDescriptor paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { MOZ_CRASH("FileDescriptor isn't meaningful on this platform"); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { MOZ_CRASH("FileDescriptor isn't meaningful on this platform"); return false; } @@ -152,9 +147,8 @@ struct ParamTraits { template <> struct ParamTraits { typedef mozilla::void_t paramType; - static void Write(Message* aMsg, const paramType& aParam) {} - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static void Write(MessageWriter* aWriter, const paramType& aParam) {} + static bool Read(MessageReader* aReader, paramType* aResult) { *aResult = paramType(); return true; } @@ -163,9 +157,8 @@ struct ParamTraits { template <> struct ParamTraits { typedef mozilla::null_t paramType; - static void Write(Message* aMsg, const paramType& aParam) {} - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static void Write(MessageWriter* aWriter, const paramType& aParam) {} + static bool Read(MessageReader* aReader, paramType* aResult) { *aResult = paramType(); return true; } @@ -178,11 +171,10 @@ struct BitfieldHelper { // We need this helper because we can't get the address of a bitfield to // pass directly to ReadParam. So instead we read it into a temporary bool // and set the bitfield using a setter function - static bool ReadBoolForBitfield(const Message* aMsg, PickleIterator* aIter, - ParamType* aResult, + static bool ReadBoolForBitfield(MessageReader* aReader, ParamType* aResult, void (ParamType::*aSetter)(bool)) { bool value; - if (ReadParam(aMsg, aIter, &value)) { + if (ReadParam(aReader, &value)) { (aResult->*aSetter)(value); return true; } @@ -195,14 +187,13 @@ struct BitfieldHelper { // ReadParams(aMsg, aIter, aParam.foo, aParam.bar, aParam.baz) template -static void WriteParams(Message* aMsg, const Ts&... aArgs) { - (WriteParam(aMsg, aArgs), ...); +static void WriteParams(MessageWriter* aWriter, const Ts&... aArgs) { + (WriteParam(aWriter, aArgs), ...); } template -static bool ReadParams(const Message* aMsg, PickleIterator* aIter, - Ts&... aArgs) { - return (ReadParam(aMsg, aIter, &aArgs) && ...); +static bool ReadParams(MessageReader* aReader, Ts&... aArgs) { + return (ReadParam(aReader, &aArgs) && ...); } // Macros that allow syntax like: @@ -215,15 +206,14 @@ static bool ReadParams(const Message* aMsg, PickleIterator* aIter, template <> \ struct ParamTraits { \ typedef Type paramType; \ - static void Write(Message* aMsg, const paramType& aParam) { \ - WriteParams(aMsg, MOZ_FOR_EACH_SEPARATED(ACCESS_PARAM_FIELD, (, ), (), \ - (__VA_ARGS__))); \ + static void Write(MessageWriter* aWriter, const paramType& aParam) { \ + WriteParams(aWriter, MOZ_FOR_EACH_SEPARATED(ACCESS_PARAM_FIELD, (, ), \ + (), (__VA_ARGS__))); \ } \ \ - static bool Read(const Message* aMsg, PickleIterator* aIter, \ - paramType* aResult) { \ + static bool Read(MessageReader* aReader, paramType* aResult) { \ paramType& aParam = *aResult; \ - return ReadParams(aMsg, aIter, \ + return ReadParams(aReader, \ MOZ_FOR_EACH_SEPARATED(ACCESS_PARAM_FIELD, (, ), (), \ (__VA_ARGS__))); \ } \ @@ -239,17 +229,16 @@ static bool ReadParams(const Message* aMsg, PickleIterator* aIter, template <> \ struct ParamTraits { \ typedef Type paramType; \ - static void Write(Message* aMsg, const paramType& aParam) { \ - WriteParam(aMsg, static_cast(aParam)); \ - WriteParams(aMsg, MOZ_FOR_EACH_SEPARATED(ACCESS_PARAM_FIELD, (, ), (), \ - (__VA_ARGS__))); \ + static void Write(MessageWriter* aWriter, const paramType& aParam) { \ + WriteParam(aWriter, static_cast(aParam)); \ + WriteParams(aWriter, MOZ_FOR_EACH_SEPARATED(ACCESS_PARAM_FIELD, (, ), \ + (), (__VA_ARGS__))); \ } \ \ - static bool Read(const Message* aMsg, PickleIterator* aIter, \ - paramType* aResult) { \ + static bool Read(MessageReader* aReader, paramType* aResult) { \ paramType& aParam = *aResult; \ - return ReadParam(aMsg, aIter, static_cast(aResult)) && \ - ReadParams(aMsg, aIter, \ + return ReadParam(aReader, static_cast(aResult)) && \ + ReadParams(aReader, \ MOZ_FOR_EACH_SEPARATED(ACCESS_PARAM_FIELD, (, ), (), \ (__VA_ARGS__))); \ } \ diff --git a/ipc/glue/IPCMessageUtilsSpecializations.cpp b/ipc/glue/IPCMessageUtilsSpecializations.cpp index e62a343a1a6a..410b1e730ff8 100644 --- a/ipc/glue/IPCMessageUtilsSpecializations.cpp +++ b/ipc/glue/IPCMessageUtilsSpecializations.cpp @@ -21,29 +21,29 @@ static_assert(kDynamicAtomToken >= kAtomsCount, "Exceeded supported number of static atoms"); /* static */ -void ParamTraits::Write(Message* aMsg, const nsAtom* aParam) { +void ParamTraits::Write(MessageWriter* aWriter, const nsAtom* aParam) { MOZ_ASSERT(aParam); if (aParam->IsStatic()) { const nsStaticAtom* atom = aParam->AsStatic(); uint16_t index = static_cast(nsGkAtoms::IndexOf(atom)); MOZ_ASSERT(index < kAtomsCount); - WriteParam(aMsg, index); + WriteParam(aWriter, index); return; } - WriteParam(aMsg, kDynamicAtomToken); + WriteParam(aWriter, kDynamicAtomToken); nsDependentAtomString atomStr(aParam); // nsDependentAtomString is serialized as its base, nsString, but we // can be explicit about it. nsString& str = atomStr; - WriteParam(aMsg, str); + WriteParam(aWriter, str); } /* static */ -bool ParamTraits::Read(const Message* aMsg, PickleIterator* aIter, +bool ParamTraits::Read(MessageReader* aReader, RefPtr* aResult) { uint16_t token; - if (!ReadParam(aMsg, aIter, &token)) { + if (!ReadParam(aReader, &token)) { return false; } if (token != kDynamicAtomToken) { @@ -55,7 +55,7 @@ bool ParamTraits::Read(const Message* aMsg, PickleIterator* aIter, } nsAutoString str; - if (!ReadParam(aMsg, aIter, static_cast(&str))) { + if (!ReadParam(aReader, static_cast(&str))) { return false; } diff --git a/ipc/glue/IPCMessageUtilsSpecializations.h b/ipc/glue/IPCMessageUtilsSpecializations.h index aa0a62a821a5..a9748b77230b 100644 --- a/ipc/glue/IPCMessageUtilsSpecializations.h +++ b/ipc/glue/IPCMessageUtilsSpecializations.h @@ -77,23 +77,22 @@ template <> struct ParamTraits { typedef nsACString paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { bool isVoid = aParam.IsVoid(); - aMsg->WriteBool(isVoid); + aWriter->WriteBool(isVoid); if (isVoid) // represents a nullptr pointer return; uint32_t length = aParam.Length(); - WriteParam(aMsg, length); - aMsg->WriteBytes(aParam.BeginReading(), length); + WriteParam(aWriter, length); + aWriter->WriteBytes(aParam.BeginReading(), length); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { bool isVoid; - if (!aMsg->ReadBool(aIter, &isVoid)) return false; + if (!aReader->ReadBool(&isVoid)) return false; if (isVoid) { aResult->SetIsVoid(true); @@ -101,15 +100,15 @@ struct ParamTraits { } uint32_t length; - if (!ReadParam(aMsg, aIter, &length)) { + if (!ReadParam(aReader, &length)) { return false; } - if (!aMsg->HasBytesAvailable(aIter, length)) { + if (!aReader->HasBytesAvailable(length)) { return false; } aResult->SetLength(length); - return aMsg->ReadBytesInto(aIter, aResult->BeginWriting(), length); + return aReader->ReadBytesInto(aResult->BeginWriting(), length); } static void Log(const paramType& aParam, std::wstring* aLog) { @@ -124,23 +123,22 @@ template <> struct ParamTraits { typedef nsAString paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { bool isVoid = aParam.IsVoid(); - aMsg->WriteBool(isVoid); + aWriter->WriteBool(isVoid); if (isVoid) // represents a nullptr pointer return; uint32_t length = aParam.Length(); - WriteParam(aMsg, length); - aMsg->WriteBytes(aParam.BeginReading(), length * sizeof(char16_t)); + WriteParam(aWriter, length); + aWriter->WriteBytes(aParam.BeginReading(), length * sizeof(char16_t)); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { bool isVoid; - if (!aMsg->ReadBool(aIter, &isVoid)) return false; + if (!aReader->ReadBool(&isVoid)) return false; if (isVoid) { aResult->SetIsVoid(true); @@ -148,21 +146,20 @@ struct ParamTraits { } uint32_t length; - if (!ReadParam(aMsg, aIter, &length)) { + if (!ReadParam(aReader, &length)) { return false; } mozilla::CheckedInt byteLength = mozilla::CheckedInt(length) * sizeof(char16_t); if (!byteLength.isValid() || - !aMsg->HasBytesAvailable(aIter, byteLength.value())) { + !aReader->HasBytesAvailable(byteLength.value())) { return false; } aResult->SetLength(length); - return aMsg->ReadBytesInto(aIter, aResult->BeginWriting(), - byteLength.value()); + return aReader->ReadBytesInto(aResult->BeginWriting(), byteLength.value()); } static void Log(const paramType& aParam, std::wstring* aLog) { @@ -236,24 +233,23 @@ template <> struct ParamTraits> { typedef nsTHashSet paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { uint32_t count = aParam.Count(); - WriteParam(aMsg, count); + WriteParam(aWriter, count); for (const auto& key : aParam) { - WriteParam(aMsg, key); + WriteParam(aWriter, key); } } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { uint32_t count; - if (!ReadParam(aMsg, aIter, &count)) { + if (!ReadParam(aReader, &count)) { return false; } paramType table(count); for (uint32_t i = 0; i < count; ++i) { uint64_t key; - if (!ReadParam(aMsg, aIter, &key)) { + if (!ReadParam(aReader, &key)) { return false; } table.Insert(key); @@ -285,28 +281,27 @@ struct ParamTraits> { static const bool sUseWriteBytes = (std::is_integral_v || std::is_floating_point_v); - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { uint32_t length = aParam.Length(); - WriteParam(aMsg, length); + WriteParam(aWriter, length); if (sUseWriteBytes) { int pickledLength = 0; MOZ_RELEASE_ASSERT(ByteLengthIsValid(length, sizeof(E), &pickledLength)); - aMsg->WriteBytes(aParam.Elements(), pickledLength); + aWriter->WriteBytes(aParam.Elements(), pickledLength); } else { const E* elems = aParam.Elements(); for (uint32_t index = 0; index < length; index++) { - WriteParam(aMsg, elems[index]); + WriteParam(aWriter, elems[index]); } } } // This method uses infallible allocation so that an OOM failure will // show up as an OOM crash rather than an IPC FatalError. - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { uint32_t length; - if (!ReadParam(aMsg, aIter, &length)) { + if (!ReadParam(aReader, &length)) { return false; } @@ -317,12 +312,12 @@ struct ParamTraits> { } E* elements = aResult->AppendElements(length); - return aMsg->ReadBytesInto(aIter, elements, pickledLength); + return aReader->ReadBytesInto(elements, pickledLength); } else { // Each ReadParam may read more than 1 byte each; this is an attempt // to minimally validate that the length isn't much larger than what's - // actually available in aMsg. - if (!aMsg->HasBytesAvailable(aIter, length)) { + // actually available in aReader. + if (!aReader->HasBytesAvailable(length)) { return false; } @@ -330,7 +325,7 @@ struct ParamTraits> { for (uint32_t index = 0; index < length; index++) { E* element = aResult->AppendElement(); - if (!ReadParam(aMsg, aIter, element)) { + if (!ReadParam(aReader, element)) { return false; } } @@ -355,15 +350,14 @@ template struct ParamTraits> { typedef FallibleTArray paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, static_cast&>(aParam)); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, static_cast&>(aParam)); } // Deserialize the array infallibly, but return a FallibleTArray. - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { nsTArray temp; - if (!ReadParam(aMsg, aIter, &temp)) return false; + if (!ReadParam(aReader, &temp)) return false; *aResult = std::move(temp); return true; @@ -398,26 +392,25 @@ struct ParamTraits> { static const bool sUseWriteBytes = (std::is_integral_v || std::is_floating_point_v); - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { uint32_t length = aParam.length(); - WriteParam(aMsg, length); + WriteParam(aWriter, length); if (sUseWriteBytes) { int pickledLength = 0; MOZ_RELEASE_ASSERT(ByteLengthIsValid(length, sizeof(E), &pickledLength)); - aMsg->WriteBytes(aParam.begin(), pickledLength); + aWriter->WriteBytes(aParam.begin(), pickledLength); return; } for (const E& elem : aParam) { - WriteParam(aMsg, elem); + WriteParam(aWriter, elem); } } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { uint32_t length; - if (!ReadParam(aMsg, aIter, &length)) { + if (!ReadParam(aReader, &length)) { return false; } @@ -433,13 +426,13 @@ struct ParamTraits> { } E* elements = aResult->begin(); - return aMsg->ReadBytesInto(aIter, elements, pickledLength); + return aReader->ReadBytesInto(elements, pickledLength); } // Each ReadParam may read more than 1 byte each; this is an attempt // to minimally validate that the length isn't much larger than what's - // actually available in aMsg. - if (!aMsg->HasBytesAvailable(aIter, length)) { + // actually available in aReader. + if (!aReader->HasBytesAvailable(length)) { return false; } @@ -449,7 +442,7 @@ struct ParamTraits> { } for (uint32_t index = 0; index < length; ++index) { - if (!ReadParam(aMsg, aIter, &((*aResult)[index]))) { + if (!ReadParam(aReader, &((*aResult)[index]))) { return false; } } @@ -479,26 +472,25 @@ struct ParamTraits> { static const bool sUseWriteBytes = (std::is_integral_v || std::is_floating_point_v); - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { uint32_t length = aParam.size(); - WriteParam(aMsg, length); + WriteParam(aWriter, length); if (sUseWriteBytes) { int pickledLength = 0; MOZ_RELEASE_ASSERT(ByteLengthIsValid(length, sizeof(E), &pickledLength)); - aMsg->WriteBytes(aParam.data(), pickledLength); + aWriter->WriteBytes(aParam.data(), pickledLength); return; } for (const E& elem : aParam) { - WriteParam(aMsg, elem); + WriteParam(aWriter, elem); } } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { uint32_t length; - if (!ReadParam(aMsg, aIter, &length)) { + if (!ReadParam(aReader, &length)) { return false; } @@ -511,20 +503,20 @@ struct ParamTraits> { aResult->resize(length); E* elements = aResult->data(); - return aMsg->ReadBytesInto(aIter, elements, pickledLength); + return aReader->ReadBytesInto(elements, pickledLength); } // Each ReadParam may read more than 1 byte each; this is an attempt // to minimally validate that the length isn't much larger than what's - // actually available in aMsg. - if (!aMsg->HasBytesAvailable(aIter, length)) { + // actually available in aReader. + if (!aReader->HasBytesAvailable(length)) { return false; } aResult->resize(length); for (uint32_t index = 0; index < length; ++index) { - if (!ReadParam(aMsg, aIter, &((*aResult)[index]))) { + if (!ReadParam(aReader, &((*aResult)[index]))) { return false; } } @@ -546,25 +538,24 @@ template struct ParamTraits> final { using T = std::unordered_map; - static void Write(Message* const msg, const T& in) { - WriteParam(msg, in.size()); + static void Write(MessageWriter* const writer, const T& in) { + WriteParam(writer, in.size()); for (const auto& pair : in) { - WriteParam(msg, pair.first); - WriteParam(msg, pair.second); + WriteParam(writer, pair.first); + WriteParam(writer, pair.second); } } - static bool Read(const Message* const msg, PickleIterator* const itr, - T* const out) { + static bool Read(MessageReader* const reader, T* const out) { size_t size = 0; - if (!ReadParam(msg, itr, &size)) return false; + if (!ReadParam(reader, &size)) return false; T map; map.reserve(size); for (const auto i : mozilla::IntegerRange(size)) { std::pair pair; mozilla::Unused << i; - if (!ReadParam(msg, itr, &(pair.first)) || - !ReadParam(msg, itr, &(pair.second))) { + if (!ReadParam(reader, &(pair.first)) || + !ReadParam(reader, &(pair.second))) { return false; } map.insert(std::move(pair)); @@ -578,13 +569,12 @@ template <> struct ParamTraits { typedef float paramType; - static void Write(Message* aMsg, const paramType& aParam) { - aMsg->WriteBytes(&aParam, sizeof(paramType)); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + aWriter->WriteBytes(&aParam, sizeof(paramType)); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return aMsg->ReadBytesInto(aIter, aResult, sizeof(*aResult)); + static bool Read(MessageReader* aReader, paramType* aResult) { + return aReader->ReadBytesInto(aResult, sizeof(*aResult)); } static void Log(const paramType& aParam, std::wstring* aLog) { @@ -601,24 +591,23 @@ template <> struct ParamTraits { typedef nsID paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.m0); - WriteParam(aMsg, aParam.m1); - WriteParam(aMsg, aParam.m2); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.m0); + WriteParam(aWriter, aParam.m1); + WriteParam(aWriter, aParam.m2); for (unsigned int i = 0; i < mozilla::ArrayLength(aParam.m3); i++) { - WriteParam(aMsg, aParam.m3[i]); + WriteParam(aWriter, aParam.m3[i]); } } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &(aResult->m0)) || - !ReadParam(aMsg, aIter, &(aResult->m1)) || - !ReadParam(aMsg, aIter, &(aResult->m2))) + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &(aResult->m0)) || + !ReadParam(aReader, &(aResult->m1)) || + !ReadParam(aReader, &(aResult->m2))) return false; for (unsigned int i = 0; i < mozilla::ArrayLength(aResult->m3); i++) - if (!ReadParam(aMsg, aIter, &(aResult->m3[i]))) return false; + if (!ReadParam(aReader, &(aResult->m3[i]))) return false; return true; } @@ -642,24 +631,22 @@ struct ParamTraits template <> struct ParamTraits { typedef mozilla::TimeDuration paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mValue); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mValue); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mValue); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mValue); }; }; template <> struct ParamTraits { typedef mozilla::TimeStamp paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mValue); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mValue); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mValue); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mValue); }; }; @@ -668,18 +655,17 @@ struct ParamTraits { template <> struct ParamTraits { typedef mozilla::TimeStampValue paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mGTC); - WriteParam(aMsg, aParam.mQPC); - WriteParam(aMsg, aParam.mIsNull); - WriteParam(aMsg, aParam.mHasQPC); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mGTC); + WriteParam(aWriter, aParam.mQPC); + WriteParam(aWriter, aParam.mIsNull); + WriteParam(aWriter, aParam.mHasQPC); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return (ReadParam(aMsg, aIter, &aResult->mGTC) && - ReadParam(aMsg, aIter, &aResult->mQPC) && - ReadParam(aMsg, aIter, &aResult->mIsNull) && - ReadParam(aMsg, aIter, &aResult->mHasQPC)); + static bool Read(MessageReader* aReader, paramType* aResult) { + return (ReadParam(aReader, &aResult->mGTC) && + ReadParam(aReader, &aResult->mQPC) && + ReadParam(aReader, &aResult->mIsNull) && + ReadParam(aReader, &aResult->mHasQPC)); } }; @@ -689,13 +675,12 @@ template <> struct ParamTraits { typedef mozilla::dom::ipc::StructuredCloneData paramType; - static void Write(Message* aMsg, const paramType& aParam) { - aParam.WriteIPCParams(aMsg); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + aParam.WriteIPCParams(aWriter); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return aResult->ReadIPCParams(aMsg, aIter); + static bool Read(MessageReader* aReader, paramType* aResult) { + return aResult->ReadIPCParams(aReader); } static void Log(const paramType& aParam, std::wstring* aLog) { @@ -707,24 +692,23 @@ template struct ParamTraits> { typedef mozilla::Maybe paramType; - static void Write(Message* msg, const paramType& param) { + static void Write(MessageWriter* writer, const paramType& param) { if (param.isSome()) { - WriteParam(msg, true); - WriteParam(msg, param.value()); + WriteParam(writer, true); + WriteParam(writer, param.value()); } else { - WriteParam(msg, false); + WriteParam(writer, false); } } - static bool Read(const Message* msg, PickleIterator* iter, - paramType* result) { + static bool Read(MessageReader* reader, paramType* result) { bool isSome; - if (!ReadParam(msg, iter, &isSome)) { + if (!ReadParam(reader, &isSome)) { return false; } if (isSome) { T tmp; - if (!ReadParam(msg, iter, &tmp)) { + if (!ReadParam(reader, &tmp)) { return false; } *result = mozilla::Some(std::move(tmp)); @@ -740,16 +724,15 @@ struct ParamTraits> { typedef mozilla::EnumSet paramType; typedef U serializedType; - static void Write(Message* msg, const paramType& param) { + static void Write(MessageWriter* writer, const paramType& param) { MOZ_RELEASE_ASSERT(IsLegalValue(param.serialize())); - WriteParam(msg, param.serialize()); + WriteParam(writer, param.serialize()); } - static bool Read(const Message* msg, PickleIterator* iter, - paramType* result) { + static bool Read(MessageReader* reader, paramType* result) { serializedType tmp; - if (ReadParam(msg, iter, &tmp)) { + if (ReadParam(reader, &tmp)) { if (IsLegalValue(tmp)) { result->deserialize(tmp); return true; @@ -781,9 +764,9 @@ struct ParamTraits> { typedef mozilla::Variant paramType; using Tag = typename mozilla::detail::VariantTag::Type; - static void Write(Message* msg, const paramType& param) { - WriteParam(msg, param.tag); - param.match([msg](const auto& t) { WriteParam(msg, t); }); + static void Write(MessageWriter* writer, const paramType& param) { + WriteParam(writer, param.tag); + param.match([writer](const auto& t) { WriteParam(writer, t); }); } // Because VariantReader is a nested struct, we need the dummy template @@ -793,8 +776,7 @@ struct ParamTraits> { struct VariantReader { using Next = VariantReader; - static bool Read(const Message* msg, PickleIterator* iter, Tag tag, - paramType* result) { + static bool Read(MessageReader* reader, Tag tag, paramType* result) { // Since the VariantReader specializations start at N , we need to // subtract one to look at N - 1, the first valid tag. This means our // comparisons are off by 1. If we get to N = 0 then we have failed to @@ -805,9 +787,9 @@ struct ParamTraits> { // Default construct our field within the result outparameter and // directly deserialize into the variant. Note that this means that // every type in Ts needs to be default constructible - return ReadParam(msg, iter, &result->template emplace()); + return ReadParam(reader, &result->template emplace()); } else { - return Next::Read(msg, iter, tag, result); + return Next::Read(reader, tag, result); } } @@ -818,17 +800,15 @@ struct ParamTraits> { // a matching tag. template struct VariantReader<0, dummy> { - static bool Read(const Message* msg, PickleIterator* iter, Tag tag, - paramType* result) { + static bool Read(MessageReader* reader, Tag tag, paramType* result) { return false; } }; - static bool Read(const Message* msg, PickleIterator* iter, - paramType* result) { + static bool Read(MessageReader* reader, paramType* result) { Tag tag; - if (ReadParam(msg, iter, &tag)) { - return VariantReader::Read(msg, iter, tag, result); + if (ReadParam(reader, &tag)) { + return VariantReader::Read(reader, tag, result); } return false; } @@ -838,28 +818,27 @@ template struct ParamTraits> { typedef mozilla::dom::Optional paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { if (aParam.WasPassed()) { - WriteParam(aMsg, true); - WriteParam(aMsg, aParam.Value()); + WriteParam(aWriter, true); + WriteParam(aWriter, aParam.Value()); return; } - WriteParam(aMsg, false); + WriteParam(aWriter, false); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { bool wasPassed = false; - if (!ReadParam(aMsg, aIter, &wasPassed)) { + if (!ReadParam(aReader, &wasPassed)) { return false; } aResult->Reset(); if (wasPassed) { - if (!ReadParam(aMsg, aIter, &aResult->Construct())) { + if (!ReadParam(aReader, &aResult->Construct())) { return false; } } @@ -872,9 +851,8 @@ template <> struct ParamTraits { typedef nsAtom paramType; - static void Write(Message* aMsg, const paramType* aParam); - static bool Read(const Message* aMsg, PickleIterator* aIter, - RefPtr* aResult); + static void Write(MessageWriter* aWriter, const paramType* aParam); + static bool Read(MessageReader* aReader, RefPtr* aResult); }; struct CrossOriginOpenerPolicyValidator { @@ -930,16 +908,15 @@ template struct ParamTraits> { typedef mozilla::BitSet paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { for (Word word : aParam.Storage()) { - WriteParam(aMsg, word); + WriteParam(aWriter, word); } } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { for (Word& word : aResult->Storage()) { - if (!ReadParam(aMsg, aIter, &word)) { + if (!ReadParam(aReader, &word)) { return false; } } @@ -951,19 +928,18 @@ template struct ParamTraits> { typedef mozilla::UniquePtr paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { bool isNull = aParam == nullptr; - WriteParam(aMsg, isNull); + WriteParam(aWriter, isNull); if (!isNull) { - WriteParam(aMsg, *aParam.get()); + WriteParam(aWriter, *aParam.get()); } } - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(IPC::MessageReader* aReader, paramType* aResult) { bool isNull = true; - if (!ReadParam(aMsg, aIter, &isNull)) { + if (!ReadParam(aReader, &isNull)) { return false; } @@ -971,7 +947,7 @@ struct ParamTraits> { aResult->reset(); } else { *aResult = mozilla::MakeUnique(); - if (!ReadParam(aMsg, aIter, aResult->get())) { + if (!ReadParam(aReader, aResult->get())) { return false; } } diff --git a/ipc/glue/IPCStreamUtils.cpp b/ipc/glue/IPCStreamUtils.cpp index 0213c7750b31..dec9e0ff2fcf 100644 --- a/ipc/glue/IPCStreamUtils.cpp +++ b/ipc/glue/IPCStreamUtils.cpp @@ -548,7 +548,7 @@ Maybe& AutoIPCStream::TakeOptionalValue() { return *mOptionalValue; } -void IPDLParamTraits::Write(IPC::Message* aMsg, +void IPDLParamTraits::Write(IPC::MessageWriter* aWriter, IProtocol* aActor, nsIInputStream* aParam) { auto autoStream = MakeRefPtr(/* aDelayedStart */ true); @@ -598,7 +598,7 @@ void IPDLParamTraits::Write(IPC::Message* aMsg, } MOZ_RELEASE_ASSERT(ok, "Failed to serialize nsIInputStream"); - WriteIPDLParam(aMsg, aActor, autoStream->TakeOptionalValue()); + WriteIPDLParam(aWriter, aActor, autoStream->TakeOptionalValue()); // Dispatch the autoStream to an async runnable, so that we guarantee it // outlives this callstack, and doesn't shut down any actors we created @@ -607,12 +607,11 @@ void IPDLParamTraits::Write(IPC::Message* aMsg, NS_GetCurrentThread(), autoStream.forget(), true); } -bool IPDLParamTraits::Read(const IPC::Message* aMsg, - PickleIterator* aIter, +bool IPDLParamTraits::Read(IPC::MessageReader* aReader, IProtocol* aActor, RefPtr* aResult) { mozilla::Maybe ipcStream; - if (!ReadIPDLParam(aMsg, aIter, aActor, &ipcStream)) { + if (!ReadIPDLParam(aReader, aActor, &ipcStream)) { return false; } diff --git a/ipc/glue/IPCStreamUtils.h b/ipc/glue/IPCStreamUtils.h index 27c92debe5e9..22d3fb1730e5 100644 --- a/ipc/glue/IPCStreamUtils.h +++ b/ipc/glue/IPCStreamUtils.h @@ -208,10 +208,10 @@ class HoldIPCStream final : public AutoIPCStream { template <> struct IPDLParamTraits { - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, nsIInputStream* aParam); - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, RefPtr* aResult); + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + RefPtr* aResult); }; } // namespace ipc diff --git a/ipc/glue/IPDLParamTraits.h b/ipc/glue/IPDLParamTraits.h index f258bdcaf688..300894232369 100644 --- a/ipc/glue/IPDLParamTraits.h +++ b/ipc/glue/IPDLParamTraits.h @@ -37,14 +37,14 @@ struct IPDLParamTraits { // ParamTraits. Types which want to use the actor parameter must specialize // IPDLParamTraits. template - static inline void Write(IPC::Message* aMsg, IProtocol*, R&& aParam) { - IPC::ParamTraits

::Write(aMsg, std::forward(aParam)); + static inline void Write(IPC::MessageWriter* aWriter, IProtocol*, + R&& aParam) { + IPC::ParamTraits

::Write(aWriter, std::forward(aParam)); } template - static inline bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol*, R* aResult) { - return IPC::ParamTraits

::Read(aMsg, aIter, aResult); + static inline bool Read(IPC::MessageReader* aReader, IProtocol*, R* aResult) { + return IPC::ParamTraits

::Read(aReader, aResult); } }; @@ -59,49 +59,47 @@ struct IPDLParamTraits { // more information. // template -static MOZ_NEVER_INLINE void WriteIPDLParam(IPC::Message* aMsg, +static MOZ_NEVER_INLINE void WriteIPDLParam(IPC::MessageWriter* aWriter, IProtocol* aActor, P&& aParam) { - IPDLParamTraits>::Write(aMsg, aActor, + IPDLParamTraits>::Write(aWriter, aActor, std::forward

(aParam)); } template -static MOZ_NEVER_INLINE bool ReadIPDLParam(const IPC::Message* aMsg, - PickleIterator* aIter, +static MOZ_NEVER_INLINE bool ReadIPDLParam(IPC::MessageReader* aReader, IProtocol* aActor, P* aResult) { - return IPDLParamTraits

::Read(aMsg, aIter, aActor, aResult); + return IPDLParamTraits

::Read(aReader, aActor, aResult); } template static MOZ_NEVER_INLINE bool ReadIPDLParamInfallible( - const IPC::Message* aMsg, PickleIterator* aIter, IProtocol* aActor, - P* aResult, const char* aCrashMessage) { - bool ok = ReadIPDLParam(aMsg, aIter, aActor, aResult); + IPC::MessageReader* aReader, IProtocol* aActor, P* aResult, + const char* aCrashMessage) { + bool ok = ReadIPDLParam(aReader, aActor, aResult); if (!ok) { MOZ_CRASH_UNSAFE(aCrashMessage); } return ok; } -constexpr void WriteIPDLParamList(IPC::Message*, IProtocol*) {} +constexpr void WriteIPDLParamList(IPC::MessageWriter*, IProtocol*) {} template -static void WriteIPDLParamList(IPC::Message* aMsg, IProtocol* aActor, +static void WriteIPDLParamList(IPC::MessageWriter* aWriter, IProtocol* aActor, P&& aParam, Ps&&... aParams) { - WriteIPDLParam(aMsg, aActor, std::forward

(aParam)); - WriteIPDLParamList(aMsg, aActor, std::forward(aParams)...); + WriteIPDLParam(aWriter, aActor, std::forward

(aParam)); + WriteIPDLParamList(aWriter, aActor, std::forward(aParams)...); } -constexpr bool ReadIPDLParamList(const IPC::Message*, PickleIterator*, - IProtocol*) { +constexpr bool ReadIPDLParamList(IPC::MessageReader*, IProtocol*) { return true; } template -static bool ReadIPDLParamList(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, P* aResult, Ps*... aResults) { - return ReadIPDLParam(aMsg, aIter, aActor, aResult) && - ReadIPDLParamList(aMsg, aIter, aActor, aResults...); +static bool ReadIPDLParamList(IPC::MessageReader* aReader, IProtocol* aActor, + P* aResult, Ps*... aResults) { + return ReadIPDLParam(aReader, aActor, aResult) && + ReadIPDLParamList(aReader, aActor, aResults...); } // When being passed `RefPtr` or `nsCOMPtr`, forward to a specialization @@ -113,28 +111,28 @@ static bool ReadIPDLParamList(const IPC::Message* aMsg, PickleIterator* aIter, // deserializing into `nsCOMPtr`. template struct IPDLParamTraits> { - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, const RefPtr& aParam) { - IPDLParamTraits::Write(aMsg, aActor, aParam.get()); + IPDLParamTraits::Write(aWriter, aActor, aParam.get()); } - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, RefPtr* aResult) { - return IPDLParamTraits::Read(aMsg, aIter, aActor, aResult); + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + RefPtr* aResult) { + return IPDLParamTraits::Read(aReader, aActor, aResult); } }; template struct IPDLParamTraits> { - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, const nsCOMPtr& aParam) { - IPDLParamTraits::Write(aMsg, aActor, aParam.get()); + IPDLParamTraits::Write(aWriter, aActor, aParam.get()); } - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, nsCOMPtr* aResult) { + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + nsCOMPtr* aResult) { RefPtr refptr; - if (!IPDLParamTraits::Read(aMsg, aIter, aActor, &refptr)) { + if (!IPDLParamTraits::Read(aReader, aActor, &refptr)) { return false; } *aResult = refptr.forget(); @@ -151,32 +149,33 @@ struct IPDLParamTraits> { // forwarding reference as occasionally these types appear inside of IPDL // arrays. template - static void Write(IPC::Message* aMsg, IProtocol* aActor, U&& aParam) { + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, + U&& aParam) { uint32_t length = aParam.Length(); - WriteIPDLParam(aMsg, aActor, length); + WriteIPDLParam(aWriter, aActor, length); if (sUseWriteBytes) { auto pickledLength = CheckedInt(length) * sizeof(T); MOZ_RELEASE_ASSERT(pickledLength.isValid()); - aMsg->WriteBytes(aParam.Elements(), pickledLength.value()); + aWriter->WriteBytes(aParam.Elements(), pickledLength.value()); } else { - WriteValues(aMsg, aActor, std::forward(aParam)); + WriteValues(aWriter, aActor, std::forward(aParam)); } } // This method uses infallible allocation so that an OOM failure will // show up as an OOM crash rather than an IPC FatalError. - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, nsTArray* aResult) { + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + nsTArray* aResult) { uint32_t length; - if (!ReadIPDLParam(aMsg, aIter, aActor, &length)) { + if (!ReadIPDLParam(aReader, aActor, &length)) { return false; } if (sUseWriteBytes) { auto pickledLength = CheckedInt(length) * sizeof(T); if (!pickledLength.isValid() || - !aMsg->HasBytesAvailable(aIter, pickledLength.value())) { + !aReader->HasBytesAvailable(pickledLength.value())) { return false; } @@ -185,15 +184,15 @@ struct IPDLParamTraits> { // Perhaps we should consider using an API which doesn't initialize the // elements? T* elements = aResult->AppendElements(length); - return aMsg->ReadBytesInto(aIter, elements, pickledLength.value()); + return aReader->ReadBytesInto(elements, pickledLength.value()); } // Each ReadIPDLParam may read more than 1 byte each; this is an attempt // to minimally validate that the length isn't much larger than what's - // actually available in aMsg. We cannot use |pickledLength|, like in the + // actually available in aReader. We cannot use |pickledLength|, like in the // codepath above, because ReadIPDLParam can read variable amounts of data - // from aMsg. - if (!aMsg->HasBytesAvailable(aIter, length)) { + // from aReader. + if (!aReader->HasBytesAvailable(length)) { return false; } @@ -201,7 +200,7 @@ struct IPDLParamTraits> { for (uint32_t index = 0; index < length; index++) { T* element = aResult->AppendElement(); - if (!ReadIPDLParam(aMsg, aIter, aActor, element)) { + if (!ReadIPDLParam(aReader, aActor, element)) { return false; } } @@ -210,18 +209,18 @@ struct IPDLParamTraits> { private: // Length has already been written. Const overload. - static void WriteValues(IPC::Message* aMsg, IProtocol* aActor, + static void WriteValues(IPC::MessageWriter* aWriter, IProtocol* aActor, const nsTArray& aParam) { for (auto& elt : aParam) { - WriteIPDLParam(aMsg, aActor, elt); + WriteIPDLParam(aWriter, aActor, elt); } } // Length has already been written. Rvalue overload. - static void WriteValues(IPC::Message* aMsg, IProtocol* aActor, + static void WriteValues(IPC::MessageWriter* aWriter, IProtocol* aActor, nsTArray&& aParam) { for (auto& elt : aParam) { - WriteIPDLParam(aMsg, aActor, std::move(elt)); + WriteIPDLParam(aWriter, aActor, std::move(elt)); } // As we just moved all of our values out, let's clean up after ourselves & @@ -247,35 +246,36 @@ template struct IPDLParamTraits> { typedef Maybe paramType; - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, const Maybe& aParam) { bool isSome = aParam.isSome(); - WriteIPDLParam(aMsg, aActor, isSome); + WriteIPDLParam(aWriter, aActor, isSome); if (isSome) { - WriteIPDLParam(aMsg, aActor, aParam.ref()); + WriteIPDLParam(aWriter, aActor, aParam.ref()); } } - static void Write(IPC::Message* aMsg, IProtocol* aActor, Maybe&& aParam) { + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, + Maybe&& aParam) { bool isSome = aParam.isSome(); - WriteIPDLParam(aMsg, aActor, isSome); + WriteIPDLParam(aWriter, aActor, isSome); if (isSome) { - WriteIPDLParam(aMsg, aActor, std::move(aParam.ref())); + WriteIPDLParam(aWriter, aActor, std::move(aParam.ref())); } } - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, Maybe* aResult) { + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + Maybe* aResult) { bool isSome; - if (!ReadIPDLParam(aMsg, aIter, aActor, &isSome)) { + if (!ReadIPDLParam(aReader, aActor, &isSome)) { return false; } if (isSome) { aResult->emplace(); - if (!ReadIPDLParam(aMsg, aIter, aActor, aResult->ptr())) { + if (!ReadIPDLParam(aReader, aActor, aResult->ptr())) { return false; } } else { @@ -290,19 +290,20 @@ struct IPDLParamTraits> { typedef UniquePtr paramType; template - static void Write(IPC::Message* aMsg, IProtocol* aActor, U&& aParam) { + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, + U&& aParam) { bool isNull = aParam == nullptr; - WriteIPDLParam(aMsg, aActor, isNull); + WriteIPDLParam(aWriter, aActor, isNull); if (!isNull) { - WriteValue(aMsg, aActor, std::forward(aParam)); + WriteValue(aWriter, aActor, std::forward(aParam)); } } - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, UniquePtr* aResult) { + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + UniquePtr* aResult) { bool isNull = true; - if (!ReadParam(aMsg, aIter, &isNull)) { + if (!ReadParam(aReader, &isNull)) { return false; } @@ -310,7 +311,7 @@ struct IPDLParamTraits> { aResult->reset(); } else { *aResult = MakeUnique(); - if (!ReadIPDLParam(aMsg, aIter, aActor, aResult->get())) { + if (!ReadIPDLParam(aReader, aActor, aResult->get())) { return false; } } @@ -319,15 +320,15 @@ struct IPDLParamTraits> { private: // If we have an rvalue, clear out our passed-in parameter. - static void WriteValue(IPC::Message* aMsg, IProtocol* aActor, + static void WriteValue(IPC::MessageWriter* aWriter, IProtocol* aActor, UniquePtr&& aParam) { - WriteIPDLParam(aMsg, aActor, std::move(*aParam.get())); + WriteIPDLParam(aWriter, aActor, std::move(*aParam.get())); aParam = nullptr; } - static void WriteValue(IPC::Message* aMsg, IProtocol* aActor, + static void WriteValue(IPC::MessageWriter* aWriter, IProtocol* aActor, const UniquePtr& aParam) { - WriteIPDLParam(aMsg, aActor, *aParam.get()); + WriteIPDLParam(aWriter, aActor, *aParam.get()); } }; @@ -336,36 +337,36 @@ struct IPDLParamTraits> { typedef Tuple paramType; template - static void Write(IPC::Message* aMsg, IProtocol* aActor, U&& aParam) { - WriteInternal(aMsg, aActor, std::forward(aParam), + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, + U&& aParam) { + WriteInternal(aWriter, aActor, std::forward(aParam), std::index_sequence_for{}); } - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, Tuple* aResult) { - return ReadInternal(aMsg, aIter, aActor, *aResult, + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + Tuple* aResult) { + return ReadInternal(aReader, aActor, *aResult, std::index_sequence_for{}); } private: template - static void WriteInternal(IPC::Message* aMsg, IProtocol* aActor, + static void WriteInternal(IPC::MessageWriter* aWriter, IProtocol* aActor, const Tuple& aParam, std::index_sequence) { - WriteIPDLParamList(aMsg, aActor, Get(aParam)...); + WriteIPDLParamList(aWriter, aActor, Get(aParam)...); } template - static void WriteInternal(IPC::Message* aMsg, IProtocol* aActor, + static void WriteInternal(IPC::MessageWriter* aWriter, IProtocol* aActor, Tuple&& aParam, std::index_sequence) { - WriteIPDLParamList(aMsg, aActor, std::move(Get(aParam))...); + WriteIPDLParamList(aWriter, aActor, std::move(Get(aParam))...); } template - static bool ReadInternal(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, Tuple& aResult, - std::index_sequence) { - return ReadIPDLParamList(aMsg, aIter, aActor, &Get(aResult)...); + static bool ReadInternal(IPC::MessageReader* aReader, IProtocol* aActor, + Tuple& aResult, std::index_sequence) { + return ReadIPDLParamList(aReader, aActor, &Get(aResult)...); } }; @@ -374,17 +375,19 @@ struct IPDLParamTraits> { typedef mozilla::Variant paramType; using Tag = typename mozilla::detail::VariantTag::Type; - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, const paramType& aParam) { - WriteIPDLParam(aMsg, aActor, aParam.tag); - aParam.match( - [aMsg, aActor](const auto& t) { WriteIPDLParam(aMsg, aActor, t); }); + WriteIPDLParam(aWriter, aActor, aParam.tag); + aParam.match([aWriter, aActor](const auto& t) { + WriteIPDLParam(aWriter, aActor, t); + }); } - static void Write(IPC::Message* aMsg, IProtocol* aActor, paramType&& aParam) { - WriteIPDLParam(aMsg, aActor, aParam.tag); - aParam.match([aMsg, aActor](auto& t) { - WriteIPDLParam(aMsg, aActor, std::move(t)); + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, + paramType&& aParam) { + WriteIPDLParam(aWriter, aActor, aParam.tag); + aParam.match([aWriter, aActor](auto& t) { + WriteIPDLParam(aWriter, aActor, std::move(t)); }); } @@ -395,8 +398,8 @@ struct IPDLParamTraits> { struct VariantReader { using Next = VariantReader; - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, Tag aTag, paramType* aResult) { + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, Tag aTag, + paramType* aResult) { // Since the VariantReader specializations start at N , we need to // subtract one to look at N - 1, the first valid tag. This means our // comparisons are off by 1. If we get to N = 0 then we have failed to @@ -407,10 +410,10 @@ struct IPDLParamTraits> { // Default construct our field within the result outparameter and // directly deserialize into the variant. Note that this means that // every type in Ts needs to be default constructible. - return ReadIPDLParam(aMsg, aIter, aActor, + return ReadIPDLParam(aReader, aActor, &aResult->template emplace()); } - return Next::Read(aMsg, aIter, aActor, aTag, aResult); + return Next::Read(aReader, aActor, aTag, aResult); } }; // VariantReader @@ -420,21 +423,20 @@ struct IPDLParamTraits> { // a matching tag. template struct VariantReader<0, dummy> { - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, Tag aTag, paramType* aResult) { + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, Tag aTag, + paramType* aResult) { return false; } }; - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, paramType* aResult) { + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + paramType* aResult) { Tag tag; - if (!ReadIPDLParam(aMsg, aIter, aActor, &tag)) { + if (!ReadIPDLParam(aReader, aActor, &tag)) { return false; } - return VariantReader::Read(aMsg, aIter, aActor, tag, - aResult); + return VariantReader::Read(aReader, aActor, tag, aResult); } }; diff --git a/ipc/glue/NodeChannel.cpp b/ipc/glue/NodeChannel.cpp index 21dcf3141d0e..2670492ce87c 100644 --- a/ipc/glue/NodeChannel.cpp +++ b/ipc/glue/NodeChannel.cpp @@ -17,20 +17,19 @@ template <> struct IPC::ParamTraits { using paramType = mozilla::ipc::NodeChannel::Introduction; - static void Write(Message* aMsg, paramType&& aParam) { - WriteParam(aMsg, aParam.mName); - WriteParam(aMsg, std::move(aParam.mHandle)); - WriteParam(aMsg, aParam.mMode); - WriteParam(aMsg, aParam.mMyPid); - WriteParam(aMsg, aParam.mOtherPid); + static void Write(MessageWriter* aWriter, paramType&& aParam) { + WriteParam(aWriter, aParam.mName); + WriteParam(aWriter, std::move(aParam.mHandle)); + WriteParam(aWriter, aParam.mMode); + WriteParam(aWriter, aParam.mMyPid); + WriteParam(aWriter, aParam.mOtherPid); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mName) && - ReadParam(aMsg, aIter, &aResult->mHandle) && - ReadParam(aMsg, aIter, &aResult->mMode) && - ReadParam(aMsg, aIter, &aResult->mMyPid) && - ReadParam(aMsg, aIter, &aResult->mOtherPid); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mName) && + ReadParam(aReader, &aResult->mHandle) && + ReadParam(aReader, &aResult->mMode) && + ReadParam(aReader, &aResult->mMyPid) && + ReadParam(aReader, &aResult->mOtherPid); } }; diff --git a/ipc/glue/ProtocolMessageUtils.h b/ipc/glue/ProtocolMessageUtils.h index 16e7a91e49ab..0481c0b7e72b 100644 --- a/ipc/glue/ProtocolMessageUtils.h +++ b/ipc/glue/ProtocolMessageUtils.h @@ -49,14 +49,13 @@ template <> struct ParamTraits { typedef mozilla::ipc::ActorHandle paramType; - static void Write(Message* aMsg, const paramType& aParam) { - IPC::WriteParam(aMsg, aParam.mId); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + IPC::WriteParam(aWriter, aParam.mId); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { int id; - if (IPC::ReadParam(aMsg, aIter, &id)) { + if (IPC::ReadParam(aReader, &id)) { aResult->mId = id; return true; } @@ -72,17 +71,16 @@ template struct ParamTraits> { typedef mozilla::ipc::Endpoint paramType; - static void Write(Message* aMsg, paramType&& aParam) { - IPC::WriteParam(aMsg, std::move(aParam.mPort)); - IPC::WriteParam(aMsg, aParam.mMyPid); - IPC::WriteParam(aMsg, aParam.mOtherPid); + static void Write(MessageWriter* aWriter, paramType&& aParam) { + IPC::WriteParam(aWriter, std::move(aParam.mPort)); + IPC::WriteParam(aWriter, aParam.mMyPid); + IPC::WriteParam(aWriter, aParam.mOtherPid); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return IPC::ReadParam(aMsg, aIter, &aResult->mPort) && - IPC::ReadParam(aMsg, aIter, &aResult->mMyPid) && - IPC::ReadParam(aMsg, aIter, &aResult->mOtherPid); + static bool Read(MessageReader* aReader, paramType* aResult) { + return IPC::ReadParam(aReader, &aResult->mPort) && + IPC::ReadParam(aReader, &aResult->mMyPid) && + IPC::ReadParam(aReader, &aResult->mOtherPid); } static void Log(const paramType& aParam, std::wstring* aLog) { @@ -98,23 +96,25 @@ template <> struct IPDLParamTraits { using paramType = UntypedManagedEndpoint; - static void Write(IPC::Message* aMsg, IProtocol* aActor, paramType&& aParam); - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, paramType* aResult); + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, + paramType&& aParam); + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + paramType* aResult); }; template struct IPDLParamTraits> { using paramType = ManagedEndpoint; - static void Write(IPC::Message* aMsg, IProtocol* aActor, paramType&& aParam) { - IPDLParamTraits::Write(aMsg, aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, + paramType&& aParam) { + IPDLParamTraits::Write(aWriter, aActor, std::move(aParam)); } - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, paramType* aResult) { - return IPDLParamTraits::Read(aMsg, aIter, aActor, + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + paramType* aResult) { + return IPDLParamTraits::Read(aReader, aActor, aResult); } }; @@ -123,10 +123,10 @@ template <> struct IPDLParamTraits { typedef FileDescriptor paramType; - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, const paramType& aParam); - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, paramType* aResult); + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + paramType* aResult); }; } // namespace mozilla::ipc diff --git a/ipc/glue/ScopedPort.cpp b/ipc/glue/ScopedPort.cpp index 6ec1be3f2a63..e874796fb24b 100644 --- a/ipc/glue/ScopedPort.cpp +++ b/ipc/glue/ScopedPort.cpp @@ -54,25 +54,24 @@ ScopedPort& ScopedPort::operator=(ScopedPort&& aOther) { } // namespace mozilla::ipc -void IPC::ParamTraits::Write(Message* aMsg, +void IPC::ParamTraits::Write(MessageWriter* aWriter, paramType&& aParam) { - aMsg->WriteBool(aParam.IsValid()); + aWriter->WriteBool(aParam.IsValid()); if (!aParam.IsValid()) { return; } - aMsg->WritePort(std::move(aParam)); + aWriter->WritePort(std::move(aParam)); } -bool IPC::ParamTraits::Read(const Message* aMsg, - PickleIterator* aIter, +bool IPC::ParamTraits::Read(MessageReader* aReader, paramType* aResult) { bool isValid = false; - if (!aMsg->ReadBool(aIter, &isValid)) { + if (!aReader->ReadBool(&isValid)) { return false; } if (!isValid) { *aResult = {}; return true; } - return aMsg->ConsumePort(aIter, aResult); + return aReader->ConsumePort(aResult); } diff --git a/ipc/glue/ScopedPort.h b/ipc/glue/ScopedPort.h index 25b159a9042d..e683ba894e57 100644 --- a/ipc/glue/ScopedPort.h +++ b/ipc/glue/ScopedPort.h @@ -70,9 +70,8 @@ template <> struct ParamTraits { using paramType = mozilla::ipc::ScopedPort; - static void Write(Message* aMsg, paramType&& aParam); - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult); + static void Write(MessageWriter* aWriter, paramType&& aParam); + static bool Read(MessageReader* aReader, paramType* aResult); }; } // namespace IPC diff --git a/ipc/glue/SerializedStructuredCloneBuffer.h b/ipc/glue/SerializedStructuredCloneBuffer.h index c81a1525b3d6..222561a5b068 100644 --- a/ipc/glue/SerializedStructuredCloneBuffer.h +++ b/ipc/glue/SerializedStructuredCloneBuffer.h @@ -64,18 +64,17 @@ template <> struct ParamTraits { typedef JSStructuredCloneData paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { MOZ_ASSERT(!(aParam.Size() % sizeof(uint64_t))); - WriteParam(aMsg, aParam.Size()); + WriteParam(aWriter, aParam.Size()); aParam.ForEachDataChunk([&](const char* aData, size_t aSize) { - return aMsg->WriteBytes(aData, aSize, sizeof(uint64_t)); + return aWriter->WriteBytes(aData, aSize, sizeof(uint64_t)); }); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { size_t length = 0; - if (!ReadParam(aMsg, aIter, &length)) { + if (!ReadParam(aReader, &length)) { return false; } MOZ_ASSERT(!(length % sizeof(uint64_t))); @@ -89,7 +88,7 @@ struct ParamTraits { // return a borrowed buffer because the out param outlives the // IPDL callback. if (length && - !aMsg->ExtractBuffers(aIter, length, &buffers, sizeof(uint64_t))) { + !aReader->ExtractBuffers(length, &buffers, sizeof(uint64_t))) { return false; } @@ -111,13 +110,12 @@ template <> struct ParamTraits { typedef mozilla::SerializedStructuredCloneBuffer paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.data); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.data); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->data); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->data); } static void Log(const paramType& aParam, std::wstring* aLog) { diff --git a/ipc/glue/SharedMemory.h b/ipc/glue/SharedMemory.h index 929f266f830c..d9d40806f5a6 100644 --- a/ipc/glue/SharedMemory.h +++ b/ipc/glue/SharedMemory.h @@ -57,9 +57,8 @@ class SharedMemory { virtual SharedMemoryType Type() const = 0; - virtual bool WriteHandle(IPC::Message* aMessage) = 0; - virtual bool ReadHandle(const IPC::Message* aMessage, - PickleIterator* aIter) = 0; + virtual bool WriteHandle(IPC::MessageWriter* aWriter) = 0; + virtual bool ReadHandle(IPC::MessageReader* aReader) = 0; void Protect(char* aAddr, size_t aSize, int aRights) { char* memStart = reinterpret_cast(memory()); @@ -122,19 +121,18 @@ class SharedMemoryCommon : public SharedMemory { virtual bool IsHandleValid(const Handle& aHandle) const = 0; virtual bool SetHandle(Handle aHandle, OpenRights aRights) = 0; - virtual bool WriteHandle(IPC::Message* aMessage) override { + virtual bool WriteHandle(IPC::MessageWriter* aWriter) override { Handle handle = CloneHandle(); if (!handle) { return false; } - IPC::WriteParam(aMessage, std::move(handle)); + IPC::WriteParam(aWriter, std::move(handle)); return true; } - virtual bool ReadHandle(const IPC::Message* aMessage, - PickleIterator* aIter) override { + virtual bool ReadHandle(IPC::MessageReader* aReader) override { Handle handle; - return IPC::ReadParam(aMessage, aIter, &handle) && IsHandleValid(handle) && + return IPC::ReadParam(aReader, &handle) && IsHandleValid(handle) && SetHandle(std::move(handle), RightsReadWrite); } }; diff --git a/ipc/glue/ShmemMessageUtils.h b/ipc/glue/ShmemMessageUtils.h index 1b84b6558e4e..c8740eacb4bf 100644 --- a/ipc/glue/ShmemMessageUtils.h +++ b/ipc/glue/ShmemMessageUtils.h @@ -18,9 +18,10 @@ template <> struct IPDLParamTraits { typedef Shmem paramType; - static void Write(IPC::Message* aMsg, IProtocol* aActor, paramType&& aParam); - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, paramType* aResult); + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, + paramType&& aParam); + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + paramType* aResult); static void Log(const paramType& aParam, std::wstring* aLog) { aLog->append(L"(shmem segment)"); diff --git a/ipc/glue/TaintingIPCUtils.h b/ipc/glue/TaintingIPCUtils.h index 0c93c92f813b..d4f61d95b570 100644 --- a/ipc/glue/TaintingIPCUtils.h +++ b/ipc/glue/TaintingIPCUtils.h @@ -19,19 +19,19 @@ namespace ipc { template struct IPDLParamTraits> { - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, const mozilla::Tainted& aParam) { - WriteIPDLParam(aMsg, aActor, aParam.mValue); + WriteIPDLParam(aWriter, aActor, aParam.mValue); } - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, mozilla::Tainted&& aParam) { - WriteIPDLParam(aMsg, aActor, std::move(aParam.mValue)); + WriteIPDLParam(aWriter, aActor, std::move(aParam.mValue)); } - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, mozilla::Tainted* aResult) { - return ReadIPDLParam(aMsg, aIter, aActor, &(aResult->mValue)); + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + mozilla::Tainted* aResult) { + return ReadIPDLParam(aReader, aActor, &(aResult->mValue)); } }; diff --git a/ipc/glue/TransportSecurityInfoUtils.cpp b/ipc/glue/TransportSecurityInfoUtils.cpp index 0fa88dc5c86e..fbca28594a9f 100644 --- a/ipc/glue/TransportSecurityInfoUtils.cpp +++ b/ipc/glue/TransportSecurityInfoUtils.cpp @@ -10,23 +10,22 @@ namespace IPC { void ParamTraits::Write( - Message* aMsg, nsITransportSecurityInfo* aParam) { + MessageWriter* aWriter, nsITransportSecurityInfo* aParam) { bool nonNull = !!aParam; - WriteParam(aMsg, nonNull); + WriteParam(aWriter, nonNull); if (!nonNull) { return; } - aParam->SerializeToIPC(aMsg); + aParam->SerializeToIPC(aWriter); } bool ParamTraits::Read( - const Message* aMsg, PickleIterator* aIter, - RefPtr* aResult) { + MessageReader* aReader, RefPtr* aResult) { *aResult = nullptr; bool nonNull = false; - if (!ReadParam(aMsg, aIter, &nonNull)) { + if (!ReadParam(aReader, &nonNull)) { return false; } @@ -36,7 +35,7 @@ bool ParamTraits::Read( RefPtr info = new mozilla::psm::TransportSecurityInfo(); - if (!info->DeserializeFromIPC(aMsg, aIter)) { + if (!info->DeserializeFromIPC(aReader)) { return false; } @@ -44,22 +43,23 @@ bool ParamTraits::Read( return true; } -void ParamTraits::Write(Message* aMsg, nsIX509Cert* aParam) { +void ParamTraits::Write(MessageWriter* aWriter, + nsIX509Cert* aParam) { bool nonNull = !!aParam; - WriteParam(aMsg, nonNull); + WriteParam(aWriter, nonNull); if (!nonNull) { return; } - aParam->SerializeToIPC(aMsg); + aParam->SerializeToIPC(aWriter); } -bool ParamTraits::Read(const Message* aMsg, PickleIterator* aIter, +bool ParamTraits::Read(MessageReader* aReader, RefPtr* aResult) { *aResult = nullptr; bool nonNull = false; - if (!ReadParam(aMsg, aIter, &nonNull)) { + if (!ReadParam(aReader, &nonNull)) { return false; } @@ -68,7 +68,7 @@ bool ParamTraits::Read(const Message* aMsg, PickleIterator* aIter, } RefPtr cert = new nsNSSCertificate(); - if (!cert->DeserializeFromIPC(aMsg, aIter)) { + if (!cert->DeserializeFromIPC(aReader)) { return false; } diff --git a/ipc/glue/TransportSecurityInfoUtils.h b/ipc/glue/TransportSecurityInfoUtils.h index a782931d6bde..5788fd59302d 100644 --- a/ipc/glue/TransportSecurityInfoUtils.h +++ b/ipc/glue/TransportSecurityInfoUtils.h @@ -15,16 +15,15 @@ struct ParamTraits; template <> struct ParamTraits { - static void Write(Message* aMsg, nsITransportSecurityInfo* aParam); - static bool Read(const Message* aMsg, PickleIterator* aIter, + static void Write(MessageWriter* aWriter, nsITransportSecurityInfo* aParam); + static bool Read(MessageReader* aReader, RefPtr* aResult); }; template <> struct ParamTraits { - static void Write(Message* aMsg, nsIX509Cert* aCert); - static bool Read(const Message* aMsg, PickleIterator* aIter, - RefPtr* aResult); + static void Write(MessageWriter* aWriter, nsIX509Cert* aCert); + static bool Read(MessageReader* aReader, RefPtr* aResult); }; } // namespace IPC diff --git a/ipc/glue/URIUtils.h b/ipc/glue/URIUtils.h index fa595f357539..7cb8687bbe8c 100644 --- a/ipc/glue/URIUtils.h +++ b/ipc/glue/URIUtils.h @@ -25,16 +25,17 @@ already_AddRefed DeserializeURI(const Maybe& aParams); template <> struct IPDLParamTraits { - static void Write(IPC::Message* aMsg, IProtocol* aActor, nsIURI* aParam) { + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, + nsIURI* aParam) { Maybe params; SerializeURI(aParam, params); - WriteIPDLParam(aMsg, aActor, params); + WriteIPDLParam(aWriter, aActor, params); } - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, RefPtr* aResult) { + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + RefPtr* aResult) { Maybe params; - if (!ReadIPDLParam(aMsg, aIter, aActor, ¶ms)) { + if (!ReadIPDLParam(aReader, aActor, ¶ms)) { return false; } *aResult = DeserializeURI(params); diff --git a/ipc/ipdl/test/cxx/IPDLUnitTestTypes.h b/ipc/ipdl/test/cxx/IPDLUnitTestTypes.h index 7d20c77bf01d..02696f7df771 100644 --- a/ipc/ipdl/test/cxx/IPDLUnitTestTypes.h +++ b/ipc/ipdl/test/cxx/IPDLUnitTestTypes.h @@ -25,17 +25,17 @@ namespace IPC { template <> struct ParamTraits { typedef mozilla::_ipdltest::DirtyRect paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.x); - WriteParam(aMsg, aParam.y); - WriteParam(aMsg, aParam.w); - WriteParam(aMsg, aParam.h); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.x); + WriteParam(aWriter, aParam.y); + WriteParam(aWriter, aParam.w); + WriteParam(aWriter, aParam.h); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) { - return (ReadParam(aMsg, aIter, &aResult->x) && - ReadParam(aMsg, aIter, &aResult->y) && - ReadParam(aMsg, aIter, &aResult->w) && - ReadParam(aMsg, aIter, &aResult->h)); + static bool Read(MessageReader* aReader, void** aIter, paramType* aResult) { + return (ReadParam(aReader, aIter, &aResult->x) && + ReadParam(aReader, aIter, &aResult->y) && + ReadParam(aReader, aIter, &aResult->w) && + ReadParam(aReader, aIter, &aResult->h)); } }; } // namespace IPC diff --git a/ipc/ipdl/test/cxx/IPDLUnitTestUtils.h b/ipc/ipdl/test/cxx/IPDLUnitTestUtils.h index a5d23456545e..e454ae7b614c 100644 --- a/ipc/ipdl/test/cxx/IPDLUnitTestUtils.h +++ b/ipc/ipdl/test/cxx/IPDLUnitTestUtils.h @@ -19,9 +19,8 @@ struct ParamTraits { typedef mozilla::_ipdltest::Bad paramType; // Defined in TestActorPunning.cpp. - static void Write(Message* aMsg, const paramType& aParam); - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult); + static void Write(MessageWriter* aWriter, const paramType& aParam); + static bool Read(MessageReader* aReader, paramType* aResult); }; } // namespace IPC diff --git a/ipc/ipdl/test/cxx/TestActorPunning.cpp b/ipc/ipdl/test/cxx/TestActorPunning.cpp index c969ef60eb97..5ba3b637f244 100644 --- a/ipc/ipdl/test/cxx/TestActorPunning.cpp +++ b/ipc/ipdl/test/cxx/TestActorPunning.cpp @@ -107,18 +107,17 @@ namespace IPC { using namespace mozilla::_ipdltest; using namespace mozilla::ipc; -/*static*/ void ParamTraits::Write(Message* aMsg, +/*static*/ void ParamTraits::Write(MessageWriter* aWriter, const paramType& aParam) { // Skip past the sentinel for the actor as well as the actor. - int32_t* ptr = aMsg->GetInt32PtrForTest(2 * sizeof(int32_t)); + int32_t* ptr = aWriter->GetInt32PtrForTest(2 * sizeof(int32_t)); ActorHandle* ah = reinterpret_cast(ptr); if (ah->mId != -3) fail("guessed wrong offset (value is %d, should be -3)", ah->mId); ah->mId = -2; } -/*static*/ bool ParamTraits::Read(const Message* aMsg, - PickleIterator* aIter, +/*static*/ bool ParamTraits::Read(MessageReader* aReader, paramType* aResult) { return true; } diff --git a/ipc/mscom/COMPtrHolder.h b/ipc/mscom/COMPtrHolder.h index 83c1f85de975..e99698b8e7fd 100644 --- a/ipc/mscom/COMPtrHolder.h +++ b/ipc/mscom/COMPtrHolder.h @@ -124,7 +124,7 @@ template struct ParamTraits> { typedef mozilla::mscom::COMPtrHolder paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { #if defined(MOZ_SANDBOX) static const bool sIsStreamPreservationNeeded = XRE_IsParentProcess() && @@ -144,9 +144,9 @@ struct ParamTraits> { int bufLen; const BYTE* buf = proxyStream.GetBuffer(bufLen); MOZ_ASSERT(buf || !bufLen); - aMsg->WriteInt(bufLen); + aWriter->WriteInt(bufLen); if (bufLen) { - aMsg->WriteBytes(reinterpret_cast(buf), bufLen); + aWriter->WriteBytes(reinterpret_cast(buf), bufLen); } #if defined(MOZ_SANDBOX) @@ -163,17 +163,16 @@ struct ParamTraits> { #endif // defined(MOZ_SANDBOX) } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { int length; - if (!aMsg->ReadLength(aIter, &length)) { + if (!aReader->ReadLength(&length)) { return false; } mozilla::UniquePtr buf; if (length) { buf = mozilla::MakeUnique(length); - if (!aMsg->ReadBytesInto(aIter, buf.get(), length)) { + if (!aReader->ReadBytesInto(buf.get(), length)) { return false; } } diff --git a/layout/generic/LayoutMessageUtils.h b/layout/generic/LayoutMessageUtils.h index c62de8482a63..c8be7b174e45 100644 --- a/layout/generic/LayoutMessageUtils.h +++ b/layout/generic/LayoutMessageUtils.h @@ -17,15 +17,14 @@ template <> struct ParamTraits { using paramType = mozilla::IntrinsicSize; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.width); - WriteParam(aMsg, aParam.height); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.width); + WriteParam(aWriter, aParam.height); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->width) && - ReadParam(aMsg, aIter, &aResult->height); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->width) && + ReadParam(aReader, &aResult->height); } }; @@ -33,13 +32,12 @@ template <> struct ParamTraits { using paramType = mozilla::AspectRatio; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mRatio); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mRatio); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mRatio); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mRatio); } }; diff --git a/netwerk/base/DashboardTypes.h b/netwerk/base/DashboardTypes.h index 34e013400c73..6dd901d02aae 100644 --- a/netwerk/base/DashboardTypes.h +++ b/netwerk/base/DashboardTypes.h @@ -71,23 +71,22 @@ template <> struct ParamTraits { typedef mozilla::net::SocketInfo paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.host); - WriteParam(aMsg, aParam.sent); - WriteParam(aMsg, aParam.received); - WriteParam(aMsg, aParam.port); - WriteParam(aMsg, aParam.active); - WriteParam(aMsg, aParam.type); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.host); + WriteParam(aWriter, aParam.sent); + WriteParam(aWriter, aParam.received); + WriteParam(aWriter, aParam.port); + WriteParam(aWriter, aParam.active); + WriteParam(aWriter, aParam.type); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->host) && - ReadParam(aMsg, aIter, &aResult->sent) && - ReadParam(aMsg, aIter, &aResult->received) && - ReadParam(aMsg, aIter, &aResult->port) && - ReadParam(aMsg, aIter, &aResult->active) && - ReadParam(aMsg, aIter, &aResult->type); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->host) && + ReadParam(aReader, &aResult->sent) && + ReadParam(aReader, &aResult->received) && + ReadParam(aReader, &aResult->port) && + ReadParam(aReader, &aResult->active) && + ReadParam(aReader, &aResult->type); } }; @@ -95,23 +94,22 @@ template <> struct ParamTraits { typedef mozilla::net::DNSCacheEntries paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.hostname); - WriteParam(aMsg, aParam.hostaddr); - WriteParam(aMsg, aParam.family); - WriteParam(aMsg, aParam.expiration); - WriteParam(aMsg, aParam.netInterface); - WriteParam(aMsg, aParam.TRR); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.hostname); + WriteParam(aWriter, aParam.hostaddr); + WriteParam(aWriter, aParam.family); + WriteParam(aWriter, aParam.expiration); + WriteParam(aWriter, aParam.netInterface); + WriteParam(aWriter, aParam.TRR); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->hostname) && - ReadParam(aMsg, aIter, &aResult->hostaddr) && - ReadParam(aMsg, aIter, &aResult->family) && - ReadParam(aMsg, aIter, &aResult->expiration) && - ReadParam(aMsg, aIter, &aResult->netInterface) && - ReadParam(aMsg, aIter, &aResult->TRR); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->hostname) && + ReadParam(aReader, &aResult->hostaddr) && + ReadParam(aReader, &aResult->family) && + ReadParam(aReader, &aResult->expiration) && + ReadParam(aReader, &aResult->netInterface) && + ReadParam(aReader, &aResult->TRR); } }; @@ -119,13 +117,12 @@ template <> struct ParamTraits { typedef mozilla::net::DnsAndConnectSockets paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.speculative); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.speculative); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->speculative); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->speculative); } }; @@ -133,17 +130,16 @@ template <> struct ParamTraits { typedef mozilla::net::HttpConnInfo paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.ttl); - WriteParam(aMsg, aParam.rtt); - WriteParam(aMsg, aParam.protocolVersion); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.ttl); + WriteParam(aWriter, aParam.rtt); + WriteParam(aWriter, aParam.protocolVersion); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->ttl) && - ReadParam(aMsg, aIter, &aResult->rtt) && - ReadParam(aMsg, aIter, &aResult->protocolVersion); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->ttl) && + ReadParam(aReader, &aResult->rtt) && + ReadParam(aReader, &aResult->protocolVersion); } }; @@ -151,27 +147,26 @@ template <> struct ParamTraits { typedef mozilla::net::HttpRetParams paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.host); - WriteParam(aMsg, aParam.active); - WriteParam(aMsg, aParam.idle); - WriteParam(aMsg, aParam.dnsAndSocks); - WriteParam(aMsg, aParam.counter); - WriteParam(aMsg, aParam.port); - WriteParam(aMsg, aParam.httpVersion); - WriteParam(aMsg, aParam.ssl); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.host); + WriteParam(aWriter, aParam.active); + WriteParam(aWriter, aParam.idle); + WriteParam(aWriter, aParam.dnsAndSocks); + WriteParam(aWriter, aParam.counter); + WriteParam(aWriter, aParam.port); + WriteParam(aWriter, aParam.httpVersion); + WriteParam(aWriter, aParam.ssl); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->host) && - ReadParam(aMsg, aIter, &aResult->active) && - ReadParam(aMsg, aIter, &aResult->idle) && - ReadParam(aMsg, aIter, &aResult->dnsAndSocks) && - ReadParam(aMsg, aIter, &aResult->counter) && - ReadParam(aMsg, aIter, &aResult->port) && - ReadParam(aMsg, aIter, &aResult->httpVersion) && - ReadParam(aMsg, aIter, &aResult->ssl); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->host) && + ReadParam(aReader, &aResult->active) && + ReadParam(aReader, &aResult->idle) && + ReadParam(aReader, &aResult->dnsAndSocks) && + ReadParam(aReader, &aResult->counter) && + ReadParam(aReader, &aResult->port) && + ReadParam(aReader, &aResult->httpVersion) && + ReadParam(aReader, &aResult->ssl); } }; diff --git a/netwerk/base/FuzzySecurityInfo.cpp b/netwerk/base/FuzzySecurityInfo.cpp index 499da8617f72..ce9d5ee48136 100644 --- a/netwerk/base/FuzzySecurityInfo.cpp +++ b/netwerk/base/FuzzySecurityInfo.cpp @@ -339,12 +339,11 @@ FuzzySecurityInfo::SetEchConfig(const nsACString& aEchConfig) { NS_IMETHODIMP FuzzySecurityInfo::GetRetryEchConfig(nsACString& aEchConfig) { return NS_OK; } -void FuzzySecurityInfo::SerializeToIPC(IPC::Message* aMsg) { +void FuzzySecurityInfo::SerializeToIPC(IPC::MessageWriter* aWriter) { MOZ_CRASH("Unused"); } -bool FuzzySecurityInfo::DeserializeFromIPC(const IPC::Message* aMsg, - PickleIterator* aIter) { +bool FuzzySecurityInfo::DeserializeFromIPC(IPC::MessageReader* aReader) { MOZ_CRASH("Unused"); return false; } diff --git a/netwerk/dns/DNSByTypeRecord.h b/netwerk/dns/DNSByTypeRecord.h index c987d4ff6aab..d350cf41f0e6 100644 --- a/netwerk/dns/DNSByTypeRecord.h +++ b/netwerk/dns/DNSByTypeRecord.h @@ -42,14 +42,14 @@ namespace ipc { template <> struct IPDLParamTraits { typedef mozilla::net::IPCTypeRecord paramType; - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, const paramType& aParam) { - WriteIPDLParam(aMsg, aActor, aParam.mData); + WriteIPDLParam(aWriter, aActor, aParam.mData); } - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, paramType* aResult) { - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mData)) { + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + paramType* aResult) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mData)) { return false; } return true; @@ -59,16 +59,16 @@ struct IPDLParamTraits { template <> struct IPDLParamTraits { typedef mozilla::Nothing paramType; - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, const paramType& aParam) { bool isSome = false; - WriteIPDLParam(aMsg, aActor, isSome); + WriteIPDLParam(aWriter, aActor, isSome); } - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, paramType* aResult) { + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + paramType* aResult) { bool isSome; - if (!ReadIPDLParam(aMsg, aIter, aActor, &isSome)) { + if (!ReadIPDLParam(aReader, aActor, &isSome)) { return false; } *aResult = Nothing(); @@ -79,38 +79,38 @@ struct IPDLParamTraits { template <> struct IPDLParamTraits { typedef mozilla::net::SVCB paramType; - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, const paramType& aParam) { - WriteIPDLParam(aMsg, aActor, aParam.mSvcFieldPriority); - WriteIPDLParam(aMsg, aActor, aParam.mSvcDomainName); - WriteIPDLParam(aMsg, aActor, aParam.mEchConfig); - WriteIPDLParam(aMsg, aActor, aParam.mODoHConfig); - WriteIPDLParam(aMsg, aActor, aParam.mHasIPHints); - WriteIPDLParam(aMsg, aActor, aParam.mHasEchConfig); - WriteIPDLParam(aMsg, aActor, aParam.mSvcFieldValue); + WriteIPDLParam(aWriter, aActor, aParam.mSvcFieldPriority); + WriteIPDLParam(aWriter, aActor, aParam.mSvcDomainName); + WriteIPDLParam(aWriter, aActor, aParam.mEchConfig); + WriteIPDLParam(aWriter, aActor, aParam.mODoHConfig); + WriteIPDLParam(aWriter, aActor, aParam.mHasIPHints); + WriteIPDLParam(aWriter, aActor, aParam.mHasEchConfig); + WriteIPDLParam(aWriter, aActor, aParam.mSvcFieldValue); } - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, paramType* aResult) { - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mSvcFieldPriority)) { + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + paramType* aResult) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mSvcFieldPriority)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mSvcDomainName)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mSvcDomainName)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mEchConfig)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mEchConfig)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mODoHConfig)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mODoHConfig)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mHasIPHints)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mHasIPHints)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mHasEchConfig)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mHasEchConfig)) { return false; } - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mSvcFieldValue)) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mSvcFieldValue)) { return false; } return true; @@ -120,14 +120,14 @@ struct IPDLParamTraits { template <> struct IPDLParamTraits { typedef mozilla::net::SvcParamAlpn paramType; - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, const paramType& aParam) { - WriteIPDLParam(aMsg, aActor, aParam.mValue); + WriteIPDLParam(aWriter, aActor, aParam.mValue); } - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, paramType* aResult) { - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mValue)) { + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + paramType* aResult) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mValue)) { return false; } return true; @@ -137,11 +137,11 @@ struct IPDLParamTraits { template <> struct IPDLParamTraits { typedef mozilla::net::SvcParamNoDefaultAlpn paramType; - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, const paramType& aParam) {} - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, paramType* aResult) { + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + paramType* aResult) { return true; } }; @@ -149,14 +149,14 @@ struct IPDLParamTraits { template <> struct IPDLParamTraits { typedef mozilla::net::SvcParamPort paramType; - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, const paramType& aParam) { - WriteIPDLParam(aMsg, aActor, aParam.mValue); + WriteIPDLParam(aWriter, aActor, aParam.mValue); } - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, paramType* aResult) { - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mValue)) { + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + paramType* aResult) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mValue)) { return false; } return true; @@ -166,14 +166,14 @@ struct IPDLParamTraits { template <> struct IPDLParamTraits { typedef mozilla::net::SvcParamIpv4Hint paramType; - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, const paramType& aParam) { - WriteIPDLParam(aMsg, aActor, aParam.mValue); + WriteIPDLParam(aWriter, aActor, aParam.mValue); } - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, paramType* aResult) { - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mValue)) { + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + paramType* aResult) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mValue)) { return false; } return true; @@ -183,14 +183,14 @@ struct IPDLParamTraits { template <> struct IPDLParamTraits { typedef mozilla::net::SvcParamEchConfig paramType; - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, const paramType& aParam) { - WriteIPDLParam(aMsg, aActor, aParam.mValue); + WriteIPDLParam(aWriter, aActor, aParam.mValue); } - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, paramType* aResult) { - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mValue)) { + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + paramType* aResult) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mValue)) { return false; } return true; @@ -200,14 +200,14 @@ struct IPDLParamTraits { template <> struct IPDLParamTraits { typedef mozilla::net::SvcParamIpv6Hint paramType; - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, const paramType& aParam) { - WriteIPDLParam(aMsg, aActor, aParam.mValue); + WriteIPDLParam(aWriter, aActor, aParam.mValue); } - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, paramType* aResult) { - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mValue)) { + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + paramType* aResult) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mValue)) { return false; } return true; @@ -217,14 +217,14 @@ struct IPDLParamTraits { template <> struct IPDLParamTraits { typedef mozilla::net::SvcParamODoHConfig paramType; - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, const paramType& aParam) { - WriteIPDLParam(aMsg, aActor, aParam.mValue); + WriteIPDLParam(aWriter, aActor, aParam.mValue); } - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, paramType* aResult) { - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mValue)) { + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + paramType* aResult) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mValue)) { return false; } return true; @@ -234,14 +234,14 @@ struct IPDLParamTraits { template <> struct IPDLParamTraits { typedef mozilla::net::SvcFieldValue paramType; - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, const paramType& aParam) { - WriteIPDLParam(aMsg, aActor, aParam.mValue); + WriteIPDLParam(aWriter, aActor, aParam.mValue); } - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, paramType* aResult) { - if (!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mValue)) { + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + paramType* aResult) { + if (!ReadIPDLParam(aReader, aActor, &aResult->mValue)) { return false; } return true; diff --git a/netwerk/ipc/NeckoMessageUtils.h b/netwerk/ipc/NeckoMessageUtils.h index 09b67460fedd..eb248c247d58 100644 --- a/netwerk/ipc/NeckoMessageUtils.h +++ b/netwerk/ipc/NeckoMessageUtils.h @@ -47,21 +47,20 @@ struct Permission { template <> struct ParamTraits { - static void Write(Message* aMsg, const Permission& aParam) { - WriteParam(aMsg, aParam.origin); - WriteParam(aMsg, aParam.type); - WriteParam(aMsg, aParam.capability); - WriteParam(aMsg, aParam.expireType); - WriteParam(aMsg, aParam.expireTime); + static void Write(MessageWriter* aWriter, const Permission& aParam) { + WriteParam(aWriter, aParam.origin); + WriteParam(aWriter, aParam.type); + WriteParam(aWriter, aParam.capability); + WriteParam(aWriter, aParam.expireType); + WriteParam(aWriter, aParam.expireTime); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - Permission* aResult) { - return ReadParam(aMsg, aIter, &aResult->origin) && - ReadParam(aMsg, aIter, &aResult->type) && - ReadParam(aMsg, aIter, &aResult->capability) && - ReadParam(aMsg, aIter, &aResult->expireType) && - ReadParam(aMsg, aIter, &aResult->expireTime); + static bool Read(MessageReader* aReader, Permission* aResult) { + return ReadParam(aReader, &aResult->origin) && + ReadParam(aReader, &aResult->type) && + ReadParam(aReader, &aResult->capability) && + ReadParam(aReader, &aResult->expireType) && + ReadParam(aReader, &aResult->expireTime); } static void Log(const Permission& p, std::wstring* l) { @@ -79,26 +78,27 @@ struct ParamTraits { template <> struct ParamTraits { - static void Write(Message* aMsg, const mozilla::net::NetAddr& aParam) { - WriteParam(aMsg, aParam.raw.family); + static void Write(MessageWriter* aWriter, + const mozilla::net::NetAddr& aParam) { + WriteParam(aWriter, aParam.raw.family); if (aParam.raw.family == AF_UNSPEC) { - aMsg->WriteBytes(aParam.raw.data, sizeof(aParam.raw.data)); + aWriter->WriteBytes(aParam.raw.data, sizeof(aParam.raw.data)); } else if (aParam.raw.family == AF_INET) { - WriteParam(aMsg, aParam.inet.port); - WriteParam(aMsg, aParam.inet.ip); + WriteParam(aWriter, aParam.inet.port); + WriteParam(aWriter, aParam.inet.ip); } else if (aParam.raw.family == AF_INET6) { - WriteParam(aMsg, aParam.inet6.port); - WriteParam(aMsg, aParam.inet6.flowinfo); - WriteParam(aMsg, aParam.inet6.ip.u64[0]); - WriteParam(aMsg, aParam.inet6.ip.u64[1]); - WriteParam(aMsg, aParam.inet6.scope_id); + WriteParam(aWriter, aParam.inet6.port); + WriteParam(aWriter, aParam.inet6.flowinfo); + WriteParam(aWriter, aParam.inet6.ip.u64[0]); + WriteParam(aWriter, aParam.inet6.ip.u64[1]); + WriteParam(aWriter, aParam.inet6.scope_id); #if defined(XP_UNIX) } else if (aParam.raw.family == AF_LOCAL) { // Train's already off the rails: let's get a stack trace at least... MOZ_CRASH( "Error: please post stack trace to " "https://bugzilla.mozilla.org/show_bug.cgi?id=661158"); - aMsg->WriteBytes(aParam.local.path, sizeof(aParam.local.path)); + aWriter->WriteBytes(aParam.local.path, sizeof(aParam.local.path)); #endif } else { if (XRE_IsParentProcess()) { @@ -111,26 +111,25 @@ struct ParamTraits { } } - static bool Read(const Message* aMsg, PickleIterator* aIter, - mozilla::net::NetAddr* aResult) { - if (!ReadParam(aMsg, aIter, &aResult->raw.family)) return false; + static bool Read(MessageReader* aReader, mozilla::net::NetAddr* aResult) { + if (!ReadParam(aReader, &aResult->raw.family)) return false; if (aResult->raw.family == AF_UNSPEC) { - return aMsg->ReadBytesInto(aIter, &aResult->raw.data, - sizeof(aResult->raw.data)); + return aReader->ReadBytesInto(&aResult->raw.data, + sizeof(aResult->raw.data)); } else if (aResult->raw.family == AF_INET) { - return ReadParam(aMsg, aIter, &aResult->inet.port) && - ReadParam(aMsg, aIter, &aResult->inet.ip); + return ReadParam(aReader, &aResult->inet.port) && + ReadParam(aReader, &aResult->inet.ip); } else if (aResult->raw.family == AF_INET6) { - return ReadParam(aMsg, aIter, &aResult->inet6.port) && - ReadParam(aMsg, aIter, &aResult->inet6.flowinfo) && - ReadParam(aMsg, aIter, &aResult->inet6.ip.u64[0]) && - ReadParam(aMsg, aIter, &aResult->inet6.ip.u64[1]) && - ReadParam(aMsg, aIter, &aResult->inet6.scope_id); + return ReadParam(aReader, &aResult->inet6.port) && + ReadParam(aReader, &aResult->inet6.flowinfo) && + ReadParam(aReader, &aResult->inet6.ip.u64[0]) && + ReadParam(aReader, &aResult->inet6.ip.u64[1]) && + ReadParam(aReader, &aResult->inet6.scope_id); #if defined(XP_UNIX) } else if (aResult->raw.family == AF_LOCAL) { - return aMsg->ReadBytesInto(aIter, &aResult->local.path, - sizeof(aResult->local.path)); + return aReader->ReadBytesInto(&aResult->local.path, + sizeof(aResult->local.path)); #endif } diff --git a/netwerk/protocol/http/PHttpChannelParams.h b/netwerk/protocol/http/PHttpChannelParams.h index a48ece34c2b0..d67870c8880c 100644 --- a/netwerk/protocol/http/PHttpChannelParams.h +++ b/netwerk/protocol/http/PHttpChannelParams.h @@ -44,19 +44,18 @@ template <> struct ParamTraits { typedef mozilla::net::RequestHeaderTuple paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mHeader); - WriteParam(aMsg, aParam.mValue); - WriteParam(aMsg, aParam.mMerge); - WriteParam(aMsg, aParam.mEmpty); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mHeader); + WriteParam(aWriter, aParam.mValue); + WriteParam(aWriter, aParam.mMerge); + WriteParam(aWriter, aParam.mEmpty); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &aResult->mHeader) || - !ReadParam(aMsg, aIter, &aResult->mValue) || - !ReadParam(aMsg, aIter, &aResult->mMerge) || - !ReadParam(aMsg, aIter, &aResult->mEmpty)) + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &aResult->mHeader) || + !ReadParam(aReader, &aResult->mValue) || + !ReadParam(aReader, &aResult->mMerge) || + !ReadParam(aReader, &aResult->mEmpty)) return false; return true; @@ -67,17 +66,16 @@ template <> struct ParamTraits { typedef mozilla::net::nsHttpAtom paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { // aParam.get() cannot be null. MOZ_ASSERT(aParam.get(), "null nsHTTPAtom value"); nsAutoCString value(aParam.get()); - WriteParam(aMsg, value); + WriteParam(aWriter, value); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { nsAutoCString value; - if (!ReadParam(aMsg, aIter, &value)) return false; + if (!ReadParam(aReader, &value)) return false; *aResult = mozilla::net::nsHttp::ResolveAtom(value); MOZ_ASSERT(aResult->get(), "atom table not initialized"); @@ -89,42 +87,40 @@ template <> struct ParamTraits { typedef mozilla::net::nsHttpHeaderArray::nsEntry paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { if (aParam.headerNameOriginal.IsEmpty()) { - WriteParam(aMsg, aParam.header); + WriteParam(aWriter, aParam.header); } else { - WriteParam(aMsg, aParam.headerNameOriginal); + WriteParam(aWriter, aParam.headerNameOriginal); } - WriteParam(aMsg, aParam.value); + WriteParam(aWriter, aParam.value); switch (aParam.variety) { case mozilla::net::nsHttpHeaderArray::eVarietyUnknown: - WriteParam(aMsg, (uint8_t)0); + WriteParam(aWriter, (uint8_t)0); break; case mozilla::net::nsHttpHeaderArray::eVarietyRequestOverride: - WriteParam(aMsg, (uint8_t)1); + WriteParam(aWriter, (uint8_t)1); break; case mozilla::net::nsHttpHeaderArray::eVarietyRequestDefault: - WriteParam(aMsg, (uint8_t)2); + WriteParam(aWriter, (uint8_t)2); break; case mozilla::net::nsHttpHeaderArray:: eVarietyResponseNetOriginalAndResponse: - WriteParam(aMsg, (uint8_t)3); + WriteParam(aWriter, (uint8_t)3); break; case mozilla::net::nsHttpHeaderArray::eVarietyResponseNetOriginal: - WriteParam(aMsg, (uint8_t)4); + WriteParam(aWriter, (uint8_t)4); break; case mozilla::net::nsHttpHeaderArray::eVarietyResponse: - WriteParam(aMsg, (uint8_t)5); + WriteParam(aWriter, (uint8_t)5); } } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { uint8_t variety; nsAutoCString header; - if (!ReadParam(aMsg, aIter, &header) || - !ReadParam(aMsg, aIter, &aResult->value) || - !ReadParam(aMsg, aIter, &variety)) + if (!ReadParam(aReader, &header) || !ReadParam(aReader, &aResult->value) || + !ReadParam(aReader, &variety)) return false; mozilla::net::nsHttpAtom atom = mozilla::net::nsHttp::ResolveAtom(header); @@ -168,15 +164,14 @@ template <> struct ParamTraits { typedef mozilla::net::nsHttpHeaderArray paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { paramType& p = const_cast(aParam); - WriteParam(aMsg, p.mHeaders); + WriteParam(aWriter, p.mHeaders); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &aResult->mHeaders)) return false; + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &aResult->mHeaders)) return false; return true; } @@ -186,32 +181,30 @@ template <> struct ParamTraits { typedef mozilla::net::nsHttpRequestHead paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { aParam.Enter(); - WriteParam(aMsg, aParam.mHeaders); - WriteParam(aMsg, aParam.mMethod); - WriteParam(aMsg, static_cast(aParam.mVersion)); - WriteParam(aMsg, aParam.mRequestURI); - WriteParam(aMsg, aParam.mPath); - WriteParam(aMsg, aParam.mOrigin); - WriteParam(aMsg, static_cast(aParam.mParsedMethod)); - WriteParam(aMsg, aParam.mHTTPS); + WriteParam(aWriter, aParam.mHeaders); + WriteParam(aWriter, aParam.mMethod); + WriteParam(aWriter, static_cast(aParam.mVersion)); + WriteParam(aWriter, aParam.mRequestURI); + WriteParam(aWriter, aParam.mPath); + WriteParam(aWriter, aParam.mOrigin); + WriteParam(aWriter, static_cast(aParam.mParsedMethod)); + WriteParam(aWriter, aParam.mHTTPS); aParam.Exit(); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { uint32_t version; uint8_t method; aResult->Enter(); - if (!ReadParam(aMsg, aIter, &aResult->mHeaders) || - !ReadParam(aMsg, aIter, &aResult->mMethod) || - !ReadParam(aMsg, aIter, &version) || - !ReadParam(aMsg, aIter, &aResult->mRequestURI) || - !ReadParam(aMsg, aIter, &aResult->mPath) || - !ReadParam(aMsg, aIter, &aResult->mOrigin) || - !ReadParam(aMsg, aIter, &method) || - !ReadParam(aMsg, aIter, &aResult->mHTTPS)) { + if (!ReadParam(aReader, &aResult->mHeaders) || + !ReadParam(aReader, &aResult->mMethod) || + !ReadParam(aReader, &version) || + !ReadParam(aReader, &aResult->mRequestURI) || + !ReadParam(aReader, &aResult->mPath) || + !ReadParam(aReader, &aResult->mOrigin) || + !ReadParam(aReader, &method) || !ReadParam(aReader, &aResult->mHTTPS)) { aResult->Exit(); return false; } @@ -230,52 +223,50 @@ template <> struct ParamTraits { typedef mozilla::net::nsHttpResponseHead paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { aParam.Enter(); - WriteParam(aMsg, aParam.mHeaders); - WriteParam(aMsg, static_cast(aParam.mVersion)); - WriteParam(aMsg, aParam.mStatus); - WriteParam(aMsg, aParam.mStatusText); - WriteParam(aMsg, aParam.mContentLength); - WriteParam(aMsg, aParam.mContentType); - WriteParam(aMsg, aParam.mContentCharset); - WriteParam(aMsg, aParam.mHasCacheControl); - WriteParam(aMsg, aParam.mCacheControlPublic); - WriteParam(aMsg, aParam.mCacheControlPrivate); - WriteParam(aMsg, aParam.mCacheControlNoStore); - WriteParam(aMsg, aParam.mCacheControlNoCache); - WriteParam(aMsg, aParam.mCacheControlImmutable); - WriteParam(aMsg, aParam.mCacheControlStaleWhileRevalidateSet); - WriteParam(aMsg, aParam.mCacheControlStaleWhileRevalidate); - WriteParam(aMsg, aParam.mCacheControlMaxAgeSet); - WriteParam(aMsg, aParam.mCacheControlMaxAge); - WriteParam(aMsg, aParam.mPragmaNoCache); + WriteParam(aWriter, aParam.mHeaders); + WriteParam(aWriter, static_cast(aParam.mVersion)); + WriteParam(aWriter, aParam.mStatus); + WriteParam(aWriter, aParam.mStatusText); + WriteParam(aWriter, aParam.mContentLength); + WriteParam(aWriter, aParam.mContentType); + WriteParam(aWriter, aParam.mContentCharset); + WriteParam(aWriter, aParam.mHasCacheControl); + WriteParam(aWriter, aParam.mCacheControlPublic); + WriteParam(aWriter, aParam.mCacheControlPrivate); + WriteParam(aWriter, aParam.mCacheControlNoStore); + WriteParam(aWriter, aParam.mCacheControlNoCache); + WriteParam(aWriter, aParam.mCacheControlImmutable); + WriteParam(aWriter, aParam.mCacheControlStaleWhileRevalidateSet); + WriteParam(aWriter, aParam.mCacheControlStaleWhileRevalidate); + WriteParam(aWriter, aParam.mCacheControlMaxAgeSet); + WriteParam(aWriter, aParam.mCacheControlMaxAge); + WriteParam(aWriter, aParam.mPragmaNoCache); aParam.Exit(); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { uint32_t version; aResult->Enter(); - if (!ReadParam(aMsg, aIter, &aResult->mHeaders) || - !ReadParam(aMsg, aIter, &version) || - !ReadParam(aMsg, aIter, &aResult->mStatus) || - !ReadParam(aMsg, aIter, &aResult->mStatusText) || - !ReadParam(aMsg, aIter, &aResult->mContentLength) || - !ReadParam(aMsg, aIter, &aResult->mContentType) || - !ReadParam(aMsg, aIter, &aResult->mContentCharset) || - !ReadParam(aMsg, aIter, &aResult->mHasCacheControl) || - !ReadParam(aMsg, aIter, &aResult->mCacheControlPublic) || - !ReadParam(aMsg, aIter, &aResult->mCacheControlPrivate) || - !ReadParam(aMsg, aIter, &aResult->mCacheControlNoStore) || - !ReadParam(aMsg, aIter, &aResult->mCacheControlNoCache) || - !ReadParam(aMsg, aIter, &aResult->mCacheControlImmutable) || - !ReadParam(aMsg, aIter, - &aResult->mCacheControlStaleWhileRevalidateSet) || - !ReadParam(aMsg, aIter, &aResult->mCacheControlStaleWhileRevalidate) || - !ReadParam(aMsg, aIter, &aResult->mCacheControlMaxAgeSet) || - !ReadParam(aMsg, aIter, &aResult->mCacheControlMaxAge) || - !ReadParam(aMsg, aIter, &aResult->mPragmaNoCache)) { + if (!ReadParam(aReader, &aResult->mHeaders) || + !ReadParam(aReader, &version) || + !ReadParam(aReader, &aResult->mStatus) || + !ReadParam(aReader, &aResult->mStatusText) || + !ReadParam(aReader, &aResult->mContentLength) || + !ReadParam(aReader, &aResult->mContentType) || + !ReadParam(aReader, &aResult->mContentCharset) || + !ReadParam(aReader, &aResult->mHasCacheControl) || + !ReadParam(aReader, &aResult->mCacheControlPublic) || + !ReadParam(aReader, &aResult->mCacheControlPrivate) || + !ReadParam(aReader, &aResult->mCacheControlNoStore) || + !ReadParam(aReader, &aResult->mCacheControlNoCache) || + !ReadParam(aReader, &aResult->mCacheControlImmutable) || + !ReadParam(aReader, &aResult->mCacheControlStaleWhileRevalidateSet) || + !ReadParam(aReader, &aResult->mCacheControlStaleWhileRevalidate) || + !ReadParam(aReader, &aResult->mCacheControlMaxAgeSet) || + !ReadParam(aReader, &aResult->mCacheControlMaxAge) || + !ReadParam(aReader, &aResult->mPragmaNoCache)) { aResult->Exit(); return false; } diff --git a/netwerk/protocol/websocket/WebSocketFrame.cpp b/netwerk/protocol/websocket/WebSocketFrame.cpp index fbbf8d65eb0b..126f33e5488d 100644 --- a/netwerk/protocol/websocket/WebSocketFrame.cpp +++ b/netwerk/protocol/websocket/WebSocketFrame.cpp @@ -112,31 +112,30 @@ WebSocketFrameData::~WebSocketFrameData() { MOZ_COUNT_DTOR(WebSocketFrameData); } -void WebSocketFrameData::WriteIPCParams(IPC::Message* aMessage) const { - WriteParam(aMessage, mTimeStamp); - WriteParam(aMessage, mFinBit); - WriteParam(aMessage, mRsvBit1); - WriteParam(aMessage, mRsvBit2); - WriteParam(aMessage, mRsvBit3); - WriteParam(aMessage, mMaskBit); - WriteParam(aMessage, mOpCode); - WriteParam(aMessage, mMask); - WriteParam(aMessage, mPayload); +void WebSocketFrameData::WriteIPCParams(IPC::MessageWriter* aWriter) const { + WriteParam(aWriter, mTimeStamp); + WriteParam(aWriter, mFinBit); + WriteParam(aWriter, mRsvBit1); + WriteParam(aWriter, mRsvBit2); + WriteParam(aWriter, mRsvBit3); + WriteParam(aWriter, mMaskBit); + WriteParam(aWriter, mOpCode); + WriteParam(aWriter, mMask); + WriteParam(aWriter, mPayload); } -bool WebSocketFrameData::ReadIPCParams(const IPC::Message* aMessage, - PickleIterator* aIter) { - if (!ReadParam(aMessage, aIter, &mTimeStamp)) { +bool WebSocketFrameData::ReadIPCParams(IPC::MessageReader* aReader) { + if (!ReadParam(aReader, &mTimeStamp)) { return false; } -#define ReadParamHelper(x) \ - { \ - bool bit; \ - if (!ReadParam(aMessage, aIter, &bit)) { \ - return false; \ - } \ - (x) = bit; \ +#define ReadParamHelper(x) \ + { \ + bool bit; \ + if (!ReadParam(aReader, &bit)) { \ + return false; \ + } \ + (x) = bit; \ } ReadParamHelper(mFinBit); @@ -147,9 +146,8 @@ bool WebSocketFrameData::ReadIPCParams(const IPC::Message* aMessage, #undef ReadParamHelper - return ReadParam(aMessage, aIter, &mOpCode) && - ReadParam(aMessage, aIter, &mMask) && - ReadParam(aMessage, aIter, &mPayload); + return ReadParam(aReader, &mOpCode) && ReadParam(aReader, &mMask) && + ReadParam(aReader, &mPayload); } } // namespace net diff --git a/netwerk/protocol/websocket/WebSocketFrame.h b/netwerk/protocol/websocket/WebSocketFrame.h index 747453c6adc9..f8630f55ea2a 100644 --- a/netwerk/protocol/websocket/WebSocketFrame.h +++ b/netwerk/protocol/websocket/WebSocketFrame.h @@ -43,8 +43,8 @@ class WebSocketFrameData final { ~WebSocketFrameData(); // For IPC serialization - void WriteIPCParams(IPC::Message* aMessage) const; - bool ReadIPCParams(const IPC::Message* aMessage, PickleIterator* aIter); + void WriteIPCParams(IPC::MessageWriter* aWriter) const; + bool ReadIPCParams(IPC::MessageReader* aReader); DOMHighResTimeStamp mTimeStamp{0}; @@ -87,13 +87,12 @@ template <> struct ParamTraits { using paramType = mozilla::net::WebSocketFrameData; - static void Write(Message* aMsg, const paramType& aParam) { - aParam.WriteIPCParams(aMsg); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + aParam.WriteIPCParams(aWriter); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return aResult->ReadIPCParams(aMsg, aIter); + static bool Read(MessageReader* aReader, paramType* aResult) { + return aResult->ReadIPCParams(aReader); } }; diff --git a/security/manager/ssl/TransportSecurityInfo.cpp b/security/manager/ssl/TransportSecurityInfo.cpp index 1089de38e188..a8d28836af82 100644 --- a/security/manager/ssl/TransportSecurityInfo.cpp +++ b/security/manager/ssl/TransportSecurityInfo.cpp @@ -755,67 +755,63 @@ TransportSecurityInfo::Read(nsIObjectInputStream* aStream) { #undef CHILD_DIAGNOSTIC_ASSERT -void TransportSecurityInfo::SerializeToIPC(IPC::Message* aMsg) { +void TransportSecurityInfo::SerializeToIPC(IPC::MessageWriter* aWriter) { MutexAutoLock guard(mMutex); int32_t errorCode = static_cast(mErrorCode); - WriteParam(aMsg, static_cast(mSecurityState)); - WriteParam(aMsg, errorCode); - WriteParam(aMsg, mServerCert); - WriteParam(aMsg, mCipherSuite); - WriteParam(aMsg, mProtocolVersion); - WriteParam(aMsg, static_cast(mIsDomainMismatch)); - WriteParam(aMsg, static_cast(mIsNotValidAtThisTime)); - WriteParam(aMsg, static_cast(mIsUntrusted)); - WriteParam(aMsg, static_cast(mIsEV)); - WriteParam(aMsg, static_cast(mHasIsEVStatus)); - WriteParam(aMsg, static_cast(mHaveCipherSuiteAndProtocol)); - WriteParam(aMsg, static_cast(mHaveCertErrorBits)); - WriteParam(aMsg, mCertificateTransparencyStatus); - WriteParam(aMsg, mKeaGroup); - WriteParam(aMsg, mSignatureSchemeName); - WriteParam(aMsg, mSucceededCertChain); - WriteParam(aMsg, mFailedCertChain); - WriteParam(aMsg, mIsDelegatedCredential); - WriteParam(aMsg, mNPNCompleted); - WriteParam(aMsg, mNegotiatedNPN); - WriteParam(aMsg, mResumed); - WriteParam(aMsg, mIsBuiltCertChainRootBuiltInRoot); - WriteParam(aMsg, mIsAcceptedEch); - WriteParam(aMsg, mPeerId); + WriteParam(aWriter, static_cast(mSecurityState)); + WriteParam(aWriter, errorCode); + WriteParam(aWriter, mServerCert); + WriteParam(aWriter, mCipherSuite); + WriteParam(aWriter, mProtocolVersion); + WriteParam(aWriter, static_cast(mIsDomainMismatch)); + WriteParam(aWriter, static_cast(mIsNotValidAtThisTime)); + WriteParam(aWriter, static_cast(mIsUntrusted)); + WriteParam(aWriter, static_cast(mIsEV)); + WriteParam(aWriter, static_cast(mHasIsEVStatus)); + WriteParam(aWriter, static_cast(mHaveCipherSuiteAndProtocol)); + WriteParam(aWriter, static_cast(mHaveCertErrorBits)); + WriteParam(aWriter, mCertificateTransparencyStatus); + WriteParam(aWriter, mKeaGroup); + WriteParam(aWriter, mSignatureSchemeName); + WriteParam(aWriter, mSucceededCertChain); + WriteParam(aWriter, mFailedCertChain); + WriteParam(aWriter, mIsDelegatedCredential); + WriteParam(aWriter, mNPNCompleted); + WriteParam(aWriter, mNegotiatedNPN); + WriteParam(aWriter, mResumed); + WriteParam(aWriter, mIsBuiltCertChainRootBuiltInRoot); + WriteParam(aWriter, mIsAcceptedEch); + WriteParam(aWriter, mPeerId); } -bool TransportSecurityInfo::DeserializeFromIPC(const IPC::Message* aMsg, - PickleIterator* aIter) { +bool TransportSecurityInfo::DeserializeFromIPC(IPC::MessageReader* aReader) { MutexAutoLock guard(mMutex); int32_t errorCode = 0; - if (!ReadParamAtomicHelper(aMsg, aIter, mSecurityState) || - !ReadParam(aMsg, aIter, &errorCode) || - !ReadParam(aMsg, aIter, &mServerCert) || - !ReadParam(aMsg, aIter, &mCipherSuite) || - !ReadParam(aMsg, aIter, &mProtocolVersion) || - !ReadParamAtomicHelper(aMsg, aIter, mIsDomainMismatch) || - !ReadParamAtomicHelper(aMsg, aIter, mIsNotValidAtThisTime) || - !ReadParamAtomicHelper(aMsg, aIter, mIsUntrusted) || - !ReadParamAtomicHelper(aMsg, aIter, mIsEV) || - !ReadParamAtomicHelper(aMsg, aIter, mHasIsEVStatus) || - !ReadParamAtomicHelper(aMsg, aIter, mHaveCipherSuiteAndProtocol) || - !ReadParamAtomicHelper(aMsg, aIter, mHaveCertErrorBits) || - !ReadParam(aMsg, aIter, &mCertificateTransparencyStatus) || - !ReadParam(aMsg, aIter, &mKeaGroup) || - !ReadParam(aMsg, aIter, &mSignatureSchemeName) || - !ReadParam(aMsg, aIter, &mSucceededCertChain) || - !ReadParam(aMsg, aIter, &mFailedCertChain) || - !ReadParam(aMsg, aIter, &mIsDelegatedCredential) || - !ReadParam(aMsg, aIter, &mNPNCompleted) || - !ReadParam(aMsg, aIter, &mNegotiatedNPN) || - !ReadParam(aMsg, aIter, &mResumed) || - !ReadParam(aMsg, aIter, &mIsBuiltCertChainRootBuiltInRoot) || - !ReadParam(aMsg, aIter, &mIsAcceptedEch) || - !ReadParam(aMsg, aIter, &mPeerId)) { + if (!ReadParamAtomicHelper(aReader, mSecurityState) || + !ReadParam(aReader, &errorCode) || !ReadParam(aReader, &mServerCert) || + !ReadParam(aReader, &mCipherSuite) || + !ReadParam(aReader, &mProtocolVersion) || + !ReadParamAtomicHelper(aReader, mIsDomainMismatch) || + !ReadParamAtomicHelper(aReader, mIsNotValidAtThisTime) || + !ReadParamAtomicHelper(aReader, mIsUntrusted) || + !ReadParamAtomicHelper(aReader, mIsEV) || + !ReadParamAtomicHelper(aReader, mHasIsEVStatus) || + !ReadParamAtomicHelper(aReader, mHaveCipherSuiteAndProtocol) || + !ReadParamAtomicHelper(aReader, mHaveCertErrorBits) || + !ReadParam(aReader, &mCertificateTransparencyStatus) || + !ReadParam(aReader, &mKeaGroup) || + !ReadParam(aReader, &mSignatureSchemeName) || + !ReadParam(aReader, &mSucceededCertChain) || + !ReadParam(aReader, &mFailedCertChain) || + !ReadParam(aReader, &mIsDelegatedCredential) || + !ReadParam(aReader, &mNPNCompleted) || + !ReadParam(aReader, &mNegotiatedNPN) || !ReadParam(aReader, &mResumed) || + !ReadParam(aReader, &mIsBuiltCertChainRootBuiltInRoot) || + !ReadParam(aReader, &mIsAcceptedEch) || !ReadParam(aReader, &mPeerId)) { return false; } diff --git a/security/manager/ssl/TransportSecurityInfo.h b/security/manager/ssl/TransportSecurityInfo.h index aaf55071ad68..efc51817b042 100644 --- a/security/manager/ssl/TransportSecurityInfo.h +++ b/security/manager/ssl/TransportSecurityInfo.h @@ -169,10 +169,10 @@ class TransportSecurityInfo : public nsITransportSecurityInfo, } template - static bool ReadParamAtomicHelper(const IPC::Message* aMsg, - PickleIterator* aIter, Atomic

& atomic) { + static bool ReadParamAtomicHelper(IPC::MessageReader* aReader, + Atomic

& atomic) { P tmpStore; - bool result = ReadParam(aMsg, aIter, &tmpStore); + bool result = ReadParam(aReader, &tmpStore); if (result == false) { return result; } diff --git a/security/manager/ssl/nsNSSCertificate.cpp b/security/manager/ssl/nsNSSCertificate.cpp index 5e0f928b5877..77bbffe5c3ce 100644 --- a/security/manager/ssl/nsNSSCertificate.cpp +++ b/security/manager/ssl/nsNSSCertificate.cpp @@ -616,19 +616,18 @@ nsNSSCertificate::Read(nsIObjectInputStream* aStream) { return NS_OK; } -void nsNSSCertificate::SerializeToIPC(IPC::Message* aMsg) { +void nsNSSCertificate::SerializeToIPC(IPC::MessageWriter* aWriter) { bool hasCert = !mDER.IsEmpty(); - WriteParam(aMsg, hasCert); + WriteParam(aWriter, hasCert); if (!hasCert) { return; } - WriteParam(aMsg, mDER); + WriteParam(aWriter, mDER); } -bool nsNSSCertificate::DeserializeFromIPC(const IPC::Message* aMsg, - PickleIterator* aIter) { +bool nsNSSCertificate::DeserializeFromIPC(IPC::MessageReader* aReader) { auto lock = mCert.Lock(); auto& maybeCert = lock.ref(); if (!mDER.IsEmpty() || maybeCert.isSome()) { @@ -636,7 +635,7 @@ bool nsNSSCertificate::DeserializeFromIPC(const IPC::Message* aMsg, } bool hasCert = false; - if (!ReadParam(aMsg, aIter, &hasCert)) { + if (!ReadParam(aReader, &hasCert)) { return false; } @@ -644,7 +643,7 @@ bool nsNSSCertificate::DeserializeFromIPC(const IPC::Message* aMsg, return true; } - if (!ReadParam(aMsg, aIter, &mDER)) { + if (!ReadParam(aReader, &mDER)) { return false; } return true; diff --git a/toolkit/components/alerts/AlertNotificationIPCSerializer.h b/toolkit/components/alerts/AlertNotificationIPCSerializer.h index a880d8fd5dcc..14ea28ee2a71 100644 --- a/toolkit/components/alerts/AlertNotificationIPCSerializer.h +++ b/toolkit/components/alerts/AlertNotificationIPCSerializer.h @@ -20,11 +20,11 @@ namespace ipc { template <> struct IPDLParamTraits { - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, nsIAlertNotification* aParam) { bool isNull = !aParam; if (isNull) { - WriteIPDLParam(aMsg, aActor, isNull); + WriteIPDLParam(aWriter, aActor, isNull); return; } @@ -52,31 +52,31 @@ struct IPDLParamTraits { NS_WARN_IF(NS_FAILED(aParam->GetVibrate(vibrate)))) { // Write a `null` object if any getter returns an error. Otherwise, the // receiver will try to deserialize an incomplete object and crash. - WriteIPDLParam(aMsg, aActor, /* isNull */ true); + WriteIPDLParam(aWriter, aActor, /* isNull */ true); return; } - WriteIPDLParam(aMsg, aActor, isNull); - WriteIPDLParam(aMsg, aActor, name); - WriteIPDLParam(aMsg, aActor, imageURL); - WriteIPDLParam(aMsg, aActor, title); - WriteIPDLParam(aMsg, aActor, text); - WriteIPDLParam(aMsg, aActor, textClickable); - WriteIPDLParam(aMsg, aActor, cookie); - WriteIPDLParam(aMsg, aActor, dir); - WriteIPDLParam(aMsg, aActor, lang); - WriteIPDLParam(aMsg, aActor, data); - WriteIPDLParam(aMsg, aActor, IPC::Principal(principal)); - WriteIPDLParam(aMsg, aActor, inPrivateBrowsing); - WriteIPDLParam(aMsg, aActor, requireInteraction); - WriteIPDLParam(aMsg, aActor, silent); - WriteIPDLParam(aMsg, aActor, vibrate); + WriteIPDLParam(aWriter, aActor, isNull); + WriteIPDLParam(aWriter, aActor, name); + WriteIPDLParam(aWriter, aActor, imageURL); + WriteIPDLParam(aWriter, aActor, title); + WriteIPDLParam(aWriter, aActor, text); + WriteIPDLParam(aWriter, aActor, textClickable); + WriteIPDLParam(aWriter, aActor, cookie); + WriteIPDLParam(aWriter, aActor, dir); + WriteIPDLParam(aWriter, aActor, lang); + WriteIPDLParam(aWriter, aActor, data); + WriteIPDLParam(aWriter, aActor, IPC::Principal(principal)); + WriteIPDLParam(aWriter, aActor, inPrivateBrowsing); + WriteIPDLParam(aWriter, aActor, requireInteraction); + WriteIPDLParam(aWriter, aActor, silent); + WriteIPDLParam(aWriter, aActor, vibrate); } - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, RefPtr* aResult) { + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, + RefPtr* aResult) { bool isNull; - NS_ENSURE_TRUE(ReadIPDLParam(aMsg, aIter, aActor, &isNull), false); + NS_ENSURE_TRUE(ReadIPDLParam(aReader, aActor, &isNull), false); if (isNull) { *aResult = nullptr; return true; @@ -87,20 +87,20 @@ struct IPDLParamTraits { IPC::Principal principal; nsTArray vibrate; - if (!ReadIPDLParam(aMsg, aIter, aActor, &name) || - !ReadIPDLParam(aMsg, aIter, aActor, &imageURL) || - !ReadIPDLParam(aMsg, aIter, aActor, &title) || - !ReadIPDLParam(aMsg, aIter, aActor, &text) || - !ReadIPDLParam(aMsg, aIter, aActor, &textClickable) || - !ReadIPDLParam(aMsg, aIter, aActor, &cookie) || - !ReadIPDLParam(aMsg, aIter, aActor, &dir) || - !ReadIPDLParam(aMsg, aIter, aActor, &lang) || - !ReadIPDLParam(aMsg, aIter, aActor, &data) || - !ReadIPDLParam(aMsg, aIter, aActor, &principal) || - !ReadIPDLParam(aMsg, aIter, aActor, &inPrivateBrowsing) || - !ReadIPDLParam(aMsg, aIter, aActor, &requireInteraction) || - !ReadIPDLParam(aMsg, aIter, aActor, &silent) || - !ReadIPDLParam(aMsg, aIter, aActor, &vibrate)) { + if (!ReadIPDLParam(aReader, aActor, &name) || + !ReadIPDLParam(aReader, aActor, &imageURL) || + !ReadIPDLParam(aReader, aActor, &title) || + !ReadIPDLParam(aReader, aActor, &text) || + !ReadIPDLParam(aReader, aActor, &textClickable) || + !ReadIPDLParam(aReader, aActor, &cookie) || + !ReadIPDLParam(aReader, aActor, &dir) || + !ReadIPDLParam(aReader, aActor, &lang) || + !ReadIPDLParam(aReader, aActor, &data) || + !ReadIPDLParam(aReader, aActor, &principal) || + !ReadIPDLParam(aReader, aActor, &inPrivateBrowsing) || + !ReadIPDLParam(aReader, aActor, &requireInteraction) || + !ReadIPDLParam(aReader, aActor, &silent) || + !ReadIPDLParam(aReader, aActor, &vibrate)) { return false; } diff --git a/toolkit/components/sessionstore/SessionStoreMessageUtils.h b/toolkit/components/sessionstore/SessionStoreMessageUtils.h index d5fd2cd5e9f6..de8161e44901 100644 --- a/toolkit/components/sessionstore/SessionStoreMessageUtils.h +++ b/toolkit/components/sessionstore/SessionStoreMessageUtils.h @@ -16,15 +16,14 @@ template <> struct ParamTraits { typedef mozilla::dom::CollectedNonMultipleSelectValue paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mSelectedIndex); - WriteParam(aMsg, aParam.mValue); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mSelectedIndex); + WriteParam(aWriter, aParam.mValue); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mSelectedIndex) && - ReadParam(aMsg, aIter, &aResult->mValue); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mSelectedIndex) && + ReadParam(aReader, &aResult->mValue); } }; @@ -32,17 +31,16 @@ template <> struct ParamTraits { typedef CollectedInputDataValue paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.id); - WriteParam(aMsg, aParam.type); - WriteParam(aMsg, aParam.value); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.id); + WriteParam(aWriter, aParam.type); + WriteParam(aWriter, aParam.value); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->id) && - ReadParam(aMsg, aIter, &aResult->type) && - ReadParam(aMsg, aIter, &aResult->value); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->id) && + ReadParam(aReader, &aResult->type) && + ReadParam(aReader, &aResult->value); } }; @@ -50,21 +48,20 @@ template <> struct ParamTraits { typedef InputFormData paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.descendants); - WriteParam(aMsg, aParam.innerHTML); - WriteParam(aMsg, aParam.url); - WriteParam(aMsg, aParam.numId); - WriteParam(aMsg, aParam.numXPath); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.descendants); + WriteParam(aWriter, aParam.innerHTML); + WriteParam(aWriter, aParam.url); + WriteParam(aWriter, aParam.numId); + WriteParam(aWriter, aParam.numXPath); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->descendants) && - ReadParam(aMsg, aIter, &aResult->innerHTML) && - ReadParam(aMsg, aIter, &aResult->url) && - ReadParam(aMsg, aIter, &aResult->numId) && - ReadParam(aMsg, aIter, &aResult->numXPath); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->descendants) && + ReadParam(aReader, &aResult->innerHTML) && + ReadParam(aReader, &aResult->url) && + ReadParam(aReader, &aResult->numId) && + ReadParam(aReader, &aResult->numXPath); } }; @@ -79,35 +76,34 @@ struct IPDLParamTraits { // won't be doing anything with the children lists, and it avoids sending form // data for subframes to the content processes of their embedders. - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, mozilla::dom::SessionStoreRestoreData* aParam) { bool isNull = !aParam; - WriteIPDLParam(aMsg, aActor, isNull); + WriteIPDLParam(aWriter, aActor, isNull); if (isNull) { return; } - WriteIPDLParam(aMsg, aActor, aParam->mURI); - WriteIPDLParam(aMsg, aActor, aParam->mInnerHTML); - WriteIPDLParam(aMsg, aActor, aParam->mScroll); - WriteIPDLParam(aMsg, aActor, aParam->mEntries); + WriteIPDLParam(aWriter, aActor, aParam->mURI); + WriteIPDLParam(aWriter, aActor, aParam->mInnerHTML); + WriteIPDLParam(aWriter, aActor, aParam->mScroll); + WriteIPDLParam(aWriter, aActor, aParam->mEntries); } - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, RefPtr* aResult) { *aResult = nullptr; bool isNull; - if (!ReadIPDLParam(aMsg, aIter, aActor, &isNull)) { + if (!ReadIPDLParam(aReader, aActor, &isNull)) { return false; } if (isNull) { return true; } auto data = MakeRefPtr(); - if (!ReadIPDLParam(aMsg, aIter, aActor, &data->mURI) || - !ReadIPDLParam(aMsg, aIter, aActor, &data->mInnerHTML) || - !ReadIPDLParam(aMsg, aIter, aActor, &data->mScroll) || - !ReadIPDLParam(aMsg, aIter, aActor, &data->mEntries)) { + if (!ReadIPDLParam(aReader, aActor, &data->mURI) || + !ReadIPDLParam(aReader, aActor, &data->mInnerHTML) || + !ReadIPDLParam(aReader, aActor, &data->mScroll) || + !ReadIPDLParam(aReader, aActor, &data->mEntries)) { return false; } *aResult = std::move(data); @@ -117,17 +113,16 @@ struct IPDLParamTraits { template <> struct IPDLParamTraits { - static void Write(IPC::Message* aMsg, IProtocol* aActor, + static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor, mozilla::dom::SessionStoreRestoreData::Entry aParam) { - WriteIPDLParam(aMsg, aActor, aParam.mData); - WriteIPDLParam(aMsg, aActor, aParam.mIsXPath); + WriteIPDLParam(aWriter, aActor, aParam.mData); + WriteIPDLParam(aWriter, aActor, aParam.mIsXPath); } - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - IProtocol* aActor, + static bool Read(IPC::MessageReader* aReader, IProtocol* aActor, mozilla::dom::SessionStoreRestoreData::Entry* aResult) { - return ReadIPDLParam(aMsg, aIter, aActor, &aResult->mData) && - ReadIPDLParam(aMsg, aIter, aActor, &aResult->mIsXPath); + return ReadIPDLParam(aReader, aActor, &aResult->mData) && + ReadIPDLParam(aReader, aActor, &aResult->mIsXPath); } }; diff --git a/toolkit/components/telemetry/core/ipc/TelemetryComms.h b/toolkit/components/telemetry/core/ipc/TelemetryComms.h index 8e94b298a322..75f59209b0db 100644 --- a/toolkit/components/telemetry/core/ipc/TelemetryComms.h +++ b/toolkit/components/telemetry/core/ipc/TelemetryComms.h @@ -107,16 +107,14 @@ template <> struct ParamTraits { typedef mozilla::Telemetry::HistogramAccumulation paramType; - static void Write(Message* aMsg, const paramType& aParam) { - aMsg->WriteUInt32(aParam.mId); - WriteParam(aMsg, aParam.mSample); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + aWriter->WriteUInt32(aParam.mId); + WriteParam(aWriter, aParam.mSample); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!aMsg->ReadUInt32(aIter, - reinterpret_cast(&(aResult->mId))) || - !ReadParam(aMsg, aIter, &(aResult->mSample))) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!aReader->ReadUInt32(reinterpret_cast(&(aResult->mId))) || + !ReadParam(aReader, &(aResult->mSample))) { return false; } @@ -128,18 +126,16 @@ template <> struct ParamTraits { typedef mozilla::Telemetry::KeyedHistogramAccumulation paramType; - static void Write(Message* aMsg, const paramType& aParam) { - aMsg->WriteUInt32(aParam.mId); - WriteParam(aMsg, aParam.mSample); - WriteParam(aMsg, aParam.mKey); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + aWriter->WriteUInt32(aParam.mId); + WriteParam(aWriter, aParam.mSample); + WriteParam(aWriter, aParam.mKey); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!aMsg->ReadUInt32(aIter, - reinterpret_cast(&(aResult->mId))) || - !ReadParam(aMsg, aIter, &(aResult->mSample)) || - !ReadParam(aMsg, aIter, &(aResult->mKey))) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!aReader->ReadUInt32(reinterpret_cast(&(aResult->mId))) || + !ReadParam(aReader, &(aResult->mSample)) || + !ReadParam(aReader, &(aResult->mKey))) { return false; } @@ -154,11 +150,11 @@ template <> struct ParamTraits { typedef mozilla::Telemetry::ScalarAction paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { // Write the message type - aMsg->WriteUInt32(aParam.mId); - WriteParam(aMsg, aParam.mDynamic); - WriteParam(aMsg, static_cast(aParam.mActionType)); + aWriter->WriteUInt32(aParam.mId); + WriteParam(aWriter, aParam.mDynamic); + WriteParam(aWriter, static_cast(aParam.mActionType)); if (aParam.mData.isNothing()) { MOZ_CRASH("There is no data in the ScalarAction."); @@ -167,33 +163,32 @@ struct ParamTraits { if (aParam.mData->is()) { // That's a nsITelemetry::SCALAR_TYPE_COUNT. - WriteParam(aMsg, static_cast(nsITelemetry::SCALAR_TYPE_COUNT)); - WriteParam(aMsg, aParam.mData->as()); + WriteParam(aWriter, + static_cast(nsITelemetry::SCALAR_TYPE_COUNT)); + WriteParam(aWriter, aParam.mData->as()); } else if (aParam.mData->is()) { // That's a nsITelemetry::SCALAR_TYPE_STRING. - WriteParam(aMsg, static_cast(nsITelemetry::SCALAR_TYPE_STRING)); - WriteParam(aMsg, aParam.mData->as()); + WriteParam(aWriter, + static_cast(nsITelemetry::SCALAR_TYPE_STRING)); + WriteParam(aWriter, aParam.mData->as()); } else if (aParam.mData->is()) { // That's a nsITelemetry::SCALAR_TYPE_BOOLEAN. - WriteParam(aMsg, + WriteParam(aWriter, static_cast(nsITelemetry::SCALAR_TYPE_BOOLEAN)); - WriteParam(aMsg, aParam.mData->as()); + WriteParam(aWriter, aParam.mData->as()); } else { MOZ_CRASH("Unknown scalar type."); } } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { // Read the scalar ID and the scalar type. uint32_t scalarType = 0; - if (!aMsg->ReadUInt32(aIter, - reinterpret_cast(&(aResult->mId))) || - !ReadParam(aMsg, aIter, - reinterpret_cast(&(aResult->mDynamic))) || - !ReadParam(aMsg, aIter, + if (!aReader->ReadUInt32(reinterpret_cast(&(aResult->mId))) || + !ReadParam(aReader, reinterpret_cast(&(aResult->mDynamic))) || + !ReadParam(aReader, reinterpret_cast(&(aResult->mActionType))) || - !ReadParam(aMsg, aIter, &scalarType)) { + !ReadParam(aReader, &scalarType)) { return false; } @@ -202,7 +197,7 @@ struct ParamTraits { case nsITelemetry::SCALAR_TYPE_COUNT: { uint32_t data = 0; // De-serialize the data. - if (!ReadParam(aMsg, aIter, &data)) { + if (!ReadParam(aReader, &data)) { return false; } aResult->mData = mozilla::Some(mozilla::AsVariant(data)); @@ -211,7 +206,7 @@ struct ParamTraits { case nsITelemetry::SCALAR_TYPE_STRING: { nsString data; // De-serialize the data. - if (!ReadParam(aMsg, aIter, &data)) { + if (!ReadParam(aReader, &data)) { return false; } aResult->mData = mozilla::Some(mozilla::AsVariant(data)); @@ -220,7 +215,7 @@ struct ParamTraits { case nsITelemetry::SCALAR_TYPE_BOOLEAN: { bool data = false; // De-serialize the data. - if (!ReadParam(aMsg, aIter, &data)) { + if (!ReadParam(aReader, &data)) { return false; } aResult->mData = mozilla::Some(mozilla::AsVariant(data)); @@ -242,12 +237,12 @@ template <> struct ParamTraits { typedef mozilla::Telemetry::KeyedScalarAction paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { // Write the message type - aMsg->WriteUInt32(static_cast(aParam.mId)); - WriteParam(aMsg, aParam.mDynamic); - WriteParam(aMsg, static_cast(aParam.mActionType)); - WriteParam(aMsg, aParam.mKey); + aWriter->WriteUInt32(static_cast(aParam.mId)); + WriteParam(aWriter, aParam.mDynamic); + WriteParam(aWriter, static_cast(aParam.mActionType)); + WriteParam(aWriter, aParam.mKey); if (aParam.mData.isNothing()) { MOZ_CRASH("There is no data in the KeyedScalarAction."); @@ -256,8 +251,9 @@ struct ParamTraits { if (aParam.mData->is()) { // That's a nsITelemetry::SCALAR_TYPE_COUNT. - WriteParam(aMsg, static_cast(nsITelemetry::SCALAR_TYPE_COUNT)); - WriteParam(aMsg, aParam.mData->as()); + WriteParam(aWriter, + static_cast(nsITelemetry::SCALAR_TYPE_COUNT)); + WriteParam(aWriter, aParam.mData->as()); } else if (aParam.mData->is()) { // That's a nsITelemetry::SCALAR_TYPE_STRING. // Keyed string scalars are not supported. @@ -266,26 +262,23 @@ struct ParamTraits { "Not supported."); } else if (aParam.mData->is()) { // That's a nsITelemetry::SCALAR_TYPE_BOOLEAN. - WriteParam(aMsg, + WriteParam(aWriter, static_cast(nsITelemetry::SCALAR_TYPE_BOOLEAN)); - WriteParam(aMsg, aParam.mData->as()); + WriteParam(aWriter, aParam.mData->as()); } else { MOZ_CRASH("Unknown keyed scalar type."); } } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { // Read the scalar ID and the scalar type. uint32_t scalarType = 0; - if (!aMsg->ReadUInt32(aIter, - reinterpret_cast(&(aResult->mId))) || - !ReadParam(aMsg, aIter, - reinterpret_cast(&(aResult->mDynamic))) || - !ReadParam(aMsg, aIter, + if (!aReader->ReadUInt32(reinterpret_cast(&(aResult->mId))) || + !ReadParam(aReader, reinterpret_cast(&(aResult->mDynamic))) || + !ReadParam(aReader, reinterpret_cast(&(aResult->mActionType))) || - !ReadParam(aMsg, aIter, &(aResult->mKey)) || - !ReadParam(aMsg, aIter, &scalarType)) { + !ReadParam(aReader, &(aResult->mKey)) || + !ReadParam(aReader, &scalarType)) { return false; } @@ -294,7 +287,7 @@ struct ParamTraits { case nsITelemetry::SCALAR_TYPE_COUNT: { uint32_t data = 0; // De-serialize the data. - if (!ReadParam(aMsg, aIter, &data)) { + if (!ReadParam(aReader, &data)) { return false; } aResult->mData = mozilla::Some(mozilla::AsVariant(data)); @@ -310,7 +303,7 @@ struct ParamTraits { case nsITelemetry::SCALAR_TYPE_BOOLEAN: { bool data = false; // De-serialize the data. - if (!ReadParam(aMsg, aIter, &data)) { + if (!ReadParam(aReader, &data)) { return false; } aResult->mData = mozilla::Some(mozilla::AsVariant(data)); @@ -329,26 +322,23 @@ template <> struct ParamTraits { typedef mozilla::Telemetry::DynamicScalarDefinition paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { nsCString name; - WriteParam(aMsg, aParam.type); - WriteParam(aMsg, aParam.dataset); - WriteParam(aMsg, aParam.expired); - WriteParam(aMsg, aParam.keyed); - WriteParam(aMsg, aParam.builtin); - WriteParam(aMsg, aParam.name); + WriteParam(aWriter, aParam.type); + WriteParam(aWriter, aParam.dataset); + WriteParam(aWriter, aParam.expired); + WriteParam(aWriter, aParam.keyed); + WriteParam(aWriter, aParam.builtin); + WriteParam(aWriter, aParam.name); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, - reinterpret_cast(&(aResult->type))) || - !ReadParam(aMsg, aIter, - reinterpret_cast(&(aResult->dataset))) || - !ReadParam(aMsg, aIter, reinterpret_cast(&(aResult->expired))) || - !ReadParam(aMsg, aIter, reinterpret_cast(&(aResult->keyed))) || - !ReadParam(aMsg, aIter, reinterpret_cast(&(aResult->builtin))) || - !ReadParam(aMsg, aIter, &(aResult->name))) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, reinterpret_cast(&(aResult->type))) || + !ReadParam(aReader, reinterpret_cast(&(aResult->dataset))) || + !ReadParam(aReader, reinterpret_cast(&(aResult->expired))) || + !ReadParam(aReader, reinterpret_cast(&(aResult->keyed))) || + !ReadParam(aReader, reinterpret_cast(&(aResult->builtin))) || + !ReadParam(aReader, &(aResult->name))) { return false; } return true; @@ -359,23 +349,22 @@ template <> struct ParamTraits { typedef mozilla::Telemetry::ChildEventData paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.timestamp); - WriteParam(aMsg, aParam.category); - WriteParam(aMsg, aParam.method); - WriteParam(aMsg, aParam.object); - WriteParam(aMsg, aParam.value); - WriteParam(aMsg, aParam.extra); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.timestamp); + WriteParam(aWriter, aParam.category); + WriteParam(aWriter, aParam.method); + WriteParam(aWriter, aParam.object); + WriteParam(aWriter, aParam.value); + WriteParam(aWriter, aParam.extra); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &(aResult->timestamp)) || - !ReadParam(aMsg, aIter, &(aResult->category)) || - !ReadParam(aMsg, aIter, &(aResult->method)) || - !ReadParam(aMsg, aIter, &(aResult->object)) || - !ReadParam(aMsg, aIter, &(aResult->value)) || - !ReadParam(aMsg, aIter, &(aResult->extra))) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &(aResult->timestamp)) || + !ReadParam(aReader, &(aResult->category)) || + !ReadParam(aReader, &(aResult->method)) || + !ReadParam(aReader, &(aResult->object)) || + !ReadParam(aReader, &(aResult->value)) || + !ReadParam(aReader, &(aResult->extra))) { return false; } @@ -387,15 +376,14 @@ template <> struct ParamTraits { typedef mozilla::Telemetry::EventExtraEntry paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.key); - WriteParam(aMsg, aParam.value); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.key); + WriteParam(aWriter, aParam.value); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &(aResult->key)) || - !ReadParam(aMsg, aIter, &(aResult->value))) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &(aResult->key)) || + !ReadParam(aReader, &(aResult->value))) { return false; } diff --git a/toolkit/components/telemetry/other/CombinedStacks.h b/toolkit/components/telemetry/other/CombinedStacks.h index d99de243df05..00de61b9baa1 100644 --- a/toolkit/components/telemetry/other/CombinedStacks.h +++ b/toolkit/components/telemetry/other/CombinedStacks.h @@ -74,28 +74,27 @@ template <> struct ParamTraits { typedef mozilla::Telemetry::CombinedStacks paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mModules); - WriteParam(aMsg, aParam.mStacks); - WriteParam(aMsg, aParam.mNextIndex); - WriteParam(aMsg, aParam.mMaxStacksCount); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mModules); + WriteParam(aWriter, aParam.mStacks); + WriteParam(aWriter, aParam.mNextIndex); + WriteParam(aWriter, aParam.mMaxStacksCount); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &aResult->mModules)) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &aResult->mModules)) { return false; } - if (!ReadParam(aMsg, aIter, &aResult->mStacks)) { + if (!ReadParam(aReader, &aResult->mStacks)) { return false; } - if (!ReadParam(aMsg, aIter, &aResult->mNextIndex)) { + if (!ReadParam(aReader, &aResult->mNextIndex)) { return false; } - if (!ReadParam(aMsg, aIter, &aResult->mMaxStacksCount)) { + if (!ReadParam(aReader, &aResult->mMaxStacksCount)) { return false; } diff --git a/toolkit/components/telemetry/other/ProcessedStack.h b/toolkit/components/telemetry/other/ProcessedStack.h index 74a77062eaac..e91f8d91d4ac 100644 --- a/toolkit/components/telemetry/other/ProcessedStack.h +++ b/toolkit/components/telemetry/other/ProcessedStack.h @@ -93,18 +93,17 @@ template <> struct ParamTraits { typedef mozilla::Telemetry::ProcessedStack::Module paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mName); - WriteParam(aMsg, aParam.mBreakpadId); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mName); + WriteParam(aWriter, aParam.mBreakpadId); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &aResult->mName)) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &aResult->mName)) { return false; } - if (!ReadParam(aMsg, aIter, &aResult->mBreakpadId)) { + if (!ReadParam(aReader, &aResult->mBreakpadId)) { return false; } @@ -116,18 +115,17 @@ template <> struct ParamTraits { typedef mozilla::Telemetry::ProcessedStack::Frame paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mOffset); - WriteParam(aMsg, aParam.mModIndex); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mOffset); + WriteParam(aWriter, aParam.mModIndex); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &aResult->mOffset)) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &aResult->mOffset)) { return false; } - if (!ReadParam(aMsg, aIter, &aResult->mModIndex)) { + if (!ReadParam(aReader, &aResult->mModIndex)) { return false; } diff --git a/toolkit/xre/dllservices/UntrustedModulesData.h b/toolkit/xre/dllservices/UntrustedModulesData.h index 2f3530ad955a..1bd6b91a3642 100644 --- a/toolkit/xre/dllservices/UntrustedModulesData.h +++ b/toolkit/xre/dllservices/UntrustedModulesData.h @@ -260,14 +260,13 @@ template <> struct ParamTraits { typedef mozilla::ModuleVersion paramType; - static void Write(Message* aMsg, const paramType& aParam) { - aMsg->WriteUInt64(aParam.AsInteger()); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + aWriter->WriteUInt64(aParam.AsInteger()); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { uint64_t ver; - if (!aMsg->ReadUInt64(aIter, &ver)) { + if (!aReader->ReadUInt64(&ver)) { return false; } @@ -280,21 +279,20 @@ template <> struct ParamTraits { typedef mozilla::VendorInfo paramType; - static void Write(Message* aMsg, const paramType& aParam) { - aMsg->WriteUInt32(static_cast(aParam.mSource)); - WriteParam(aMsg, aParam.mVendor); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + aWriter->WriteUInt32(static_cast(aParam.mSource)); + WriteParam(aWriter, aParam.mVendor); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { uint32_t source; - if (!aMsg->ReadUInt32(aIter, &source)) { + if (!aReader->ReadUInt32(&source)) { return false; } aResult->mSource = static_cast(source); - if (!ReadParam(aMsg, aIter, &aResult->mVendor)) { + if (!ReadParam(aReader, &aResult->mVendor)) { return false; } @@ -306,8 +304,8 @@ template <> struct ParamTraits { typedef mozilla::ModuleRecord paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mResolvedNtName); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mResolvedNtName); nsAutoString resolvedDosName; if (aParam.mResolvedDosName) { @@ -316,21 +314,20 @@ struct ParamTraits { MOZ_ASSERT(NS_SUCCEEDED(rv)); } - WriteParam(aMsg, resolvedDosName); - WriteParam(aMsg, aParam.mSanitizedDllName); - WriteParam(aMsg, aParam.mVersion); - WriteParam(aMsg, aParam.mVendorInfo); - aMsg->WriteUInt32(static_cast(aParam.mTrustFlags)); + WriteParam(aWriter, resolvedDosName); + WriteParam(aWriter, aParam.mSanitizedDllName); + WriteParam(aWriter, aParam.mVersion); + WriteParam(aWriter, aParam.mVendorInfo); + aWriter->WriteUInt32(static_cast(aParam.mTrustFlags)); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &aResult->mResolvedNtName)) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &aResult->mResolvedNtName)) { return false; } nsAutoString resolvedDosName; - if (!ReadParam(aMsg, aIter, &resolvedDosName)) { + if (!ReadParam(aReader, &resolvedDosName)) { return false; } @@ -342,20 +339,20 @@ struct ParamTraits { return false; } - if (!ReadParam(aMsg, aIter, &aResult->mSanitizedDllName)) { + if (!ReadParam(aReader, &aResult->mSanitizedDllName)) { return false; } - if (!ReadParam(aMsg, aIter, &aResult->mVersion)) { + if (!ReadParam(aReader, &aResult->mVersion)) { return false; } - if (!ReadParam(aMsg, aIter, &aResult->mVendorInfo)) { + if (!ReadParam(aReader, &aResult->mVendorInfo)) { return false; } uint32_t trustFlags; - if (!aMsg->ReadUInt32(aIter, &trustFlags)) { + if (!aReader->ReadUInt32(&trustFlags)) { return false; } @@ -368,31 +365,30 @@ template <> struct ParamTraits { typedef mozilla::ModulesMap paramType; - static void Write(Message* aMsg, const paramType& aParam) { - aMsg->WriteUInt32(aParam.Count()); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + aWriter->WriteUInt32(aParam.Count()); for (const auto& entry : aParam) { MOZ_RELEASE_ASSERT(entry.GetData()); - WriteParam(aMsg, entry.GetKey()); - WriteParam(aMsg, *(entry.GetData())); + WriteParam(aWriter, entry.GetKey()); + WriteParam(aWriter, *(entry.GetData())); } } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { uint32_t count; - if (!ReadParam(aMsg, aIter, &count)) { + if (!ReadParam(aReader, &count)) { return false; } for (uint32_t current = 0; current < count; ++current) { nsAutoString key; - if (!ReadParam(aMsg, aIter, &key) || key.IsEmpty()) { + if (!ReadParam(aReader, &key) || key.IsEmpty()) { return false; } RefPtr rec(new mozilla::ModuleRecord()); - if (!ReadParam(aMsg, aIter, rec.get())) { + if (!ReadParam(aReader, rec.get())) { return false; } @@ -407,16 +403,17 @@ template <> struct ParamTraits { typedef mozilla::ModulePaths paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { aParam.mModuleNtPaths.match( - [aMsg](const paramType::SetType& aSet) { WriteSet(aMsg, aSet); }, - [aMsg](const paramType::VecType& aVec) { WriteVector(aMsg, aVec); }); + [aWriter](const paramType::SetType& aSet) { WriteSet(aWriter, aSet); }, + [aWriter](const paramType::VecType& aVec) { + WriteVector(aWriter, aVec); + }); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { uint32_t len; - if (!aMsg->ReadUInt32(aIter, &len)) { + if (!aReader->ReadUInt32(&len)) { return false; } @@ -429,7 +426,7 @@ struct ParamTraits { for (uint32_t idx = 0; idx < len; ++idx) { nsString str; - if (!ReadParam(aMsg, aIter, &str)) { + if (!ReadParam(aReader, &str)) { return false; } @@ -443,18 +440,19 @@ struct ParamTraits { private: // NB: This function must write out the set in the same format as WriteVector - static void WriteSet(Message* aMsg, const paramType::SetType& aSet) { - aMsg->WriteUInt32(aSet.Count()); + static void WriteSet(MessageWriter* aWriter, const paramType::SetType& aSet) { + aWriter->WriteUInt32(aSet.Count()); for (const auto& key : aSet.Keys()) { - WriteParam(aMsg, key); + WriteParam(aWriter, key); } } // NB: This function must write out the vector in the same format as WriteSet - static void WriteVector(Message* aMsg, const paramType::VecType& aVec) { - aMsg->WriteUInt32(aVec.length()); + static void WriteVector(MessageWriter* aWriter, + const paramType::VecType& aVec) { + aWriter->WriteUInt32(aVec.length()); for (auto const& item : aVec) { - WriteParam(aMsg, item); + WriteParam(aWriter, item); } } }; @@ -463,46 +461,45 @@ template <> struct ParamTraits { typedef mozilla::UntrustedModulesData paramType; - static void Write(Message* aMsg, const paramType& aParam) { - aMsg->WriteUInt32(aParam.mProcessType); - aMsg->WriteULong(aParam.mPid); - WriteParam(aMsg, aParam.mElapsed); - WriteParam(aMsg, aParam.mModules); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + aWriter->WriteUInt32(aParam.mProcessType); + aWriter->WriteULong(aParam.mPid); + WriteParam(aWriter, aParam.mElapsed); + WriteParam(aWriter, aParam.mModules); - aMsg->WriteUInt32(aParam.mNumEvents); + aWriter->WriteUInt32(aParam.mNumEvents); for (auto event : aParam.mEvents) { - WriteEvent(aMsg, event->mEvent); + WriteEvent(aWriter, event->mEvent); } - WriteParam(aMsg, aParam.mStacks); - WriteParam(aMsg, aParam.mXULLoadDurationMS); - aMsg->WriteUInt32(aParam.mSanitizationFailures); - aMsg->WriteUInt32(aParam.mTrustTestFailures); + WriteParam(aWriter, aParam.mStacks); + WriteParam(aWriter, aParam.mXULLoadDurationMS); + aWriter->WriteUInt32(aParam.mSanitizationFailures); + aWriter->WriteUInt32(aParam.mTrustTestFailures); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { uint32_t processType; - if (!aMsg->ReadUInt32(aIter, &processType)) { + if (!aReader->ReadUInt32(&processType)) { return false; } aResult->mProcessType = static_cast(processType); - if (!aMsg->ReadULong(aIter, &aResult->mPid)) { + if (!aReader->ReadULong(&aResult->mPid)) { return false; } - if (!ReadParam(aMsg, aIter, &aResult->mElapsed)) { + if (!ReadParam(aReader, &aResult->mElapsed)) { return false; } - if (!ReadParam(aMsg, aIter, &aResult->mModules)) { + if (!ReadParam(aReader, &aResult->mModules)) { return false; } // We read mEvents manually so that we can use ReadEvent defined below. - if (!ReadParam(aMsg, aIter, &aResult->mNumEvents)) { + if (!ReadParam(aReader, &aResult->mNumEvents)) { return false; } @@ -510,25 +507,25 @@ struct ParamTraits { ++curEventIdx) { auto newEvent = mozilla::MakeUnique(); - if (!ReadEvent(aMsg, aIter, &newEvent->mEvent, aResult->mModules)) { + if (!ReadEvent(aReader, &newEvent->mEvent, aResult->mModules)) { return false; } aResult->mEvents.insertBack(newEvent.release()); } - if (!ReadParam(aMsg, aIter, &aResult->mStacks)) { + if (!ReadParam(aReader, &aResult->mStacks)) { return false; } - if (!ReadParam(aMsg, aIter, &aResult->mXULLoadDurationMS)) { + if (!ReadParam(aReader, &aResult->mXULLoadDurationMS)) { return false; } - if (!aMsg->ReadUInt32(aIter, &aResult->mSanitizationFailures)) { + if (!aReader->ReadUInt32(&aResult->mSanitizationFailures)) { return false; } - if (!aMsg->ReadUInt32(aIter, &aResult->mTrustTestFailures)) { + if (!aReader->ReadUInt32(&aResult->mTrustTestFailures)) { return false; } @@ -539,46 +536,46 @@ struct ParamTraits { // Because ProcessedModuleLoadEvent depends on a hash table from // UntrustedModulesData, we do its serialization as part of this // specialization. - static void WriteEvent(Message* aMsg, + static void WriteEvent(MessageWriter* aWriter, const mozilla::ProcessedModuleLoadEvent& aParam) { - aMsg->WriteUInt64(aParam.mProcessUptimeMS); - WriteParam(aMsg, aParam.mLoadDurationMS); - aMsg->WriteULong(aParam.mThreadId); - WriteParam(aMsg, aParam.mThreadName); - WriteParam(aMsg, aParam.mRequestedDllName); - WriteParam(aMsg, aParam.mBaseAddress); - WriteParam(aMsg, aParam.mIsDependent); - WriteParam(aMsg, aParam.mLoadStatus); + aWriter->WriteUInt64(aParam.mProcessUptimeMS); + WriteParam(aWriter, aParam.mLoadDurationMS); + aWriter->WriteULong(aParam.mThreadId); + WriteParam(aWriter, aParam.mThreadName); + WriteParam(aWriter, aParam.mRequestedDllName); + WriteParam(aWriter, aParam.mBaseAddress); + WriteParam(aWriter, aParam.mIsDependent); + WriteParam(aWriter, aParam.mLoadStatus); // We don't write the ModuleRecord directly; we write its key into the // UntrustedModulesData::mModules hash table. MOZ_ASSERT(aParam.mModule && !aParam.mModule->mResolvedNtName.IsEmpty()); - WriteParam(aMsg, aParam.mModule->mResolvedNtName); + WriteParam(aWriter, aParam.mModule->mResolvedNtName); } // Because ProcessedModuleLoadEvent depends on a hash table from // UntrustedModulesData, we do its deserialization as part of this // specialization. - static bool ReadEvent(const Message* aMsg, PickleIterator* aIter, + static bool ReadEvent(MessageReader* aReader, mozilla::ProcessedModuleLoadEvent* aResult, const mozilla::ModulesMap& aModulesMap) { - if (!aMsg->ReadUInt64(aIter, &aResult->mProcessUptimeMS)) { + if (!aReader->ReadUInt64(&aResult->mProcessUptimeMS)) { return false; } - if (!ReadParam(aMsg, aIter, &aResult->mLoadDurationMS)) { + if (!ReadParam(aReader, &aResult->mLoadDurationMS)) { return false; } - if (!aMsg->ReadULong(aIter, &aResult->mThreadId)) { + if (!aReader->ReadULong(&aResult->mThreadId)) { return false; } - if (!ReadParam(aMsg, aIter, &aResult->mThreadName)) { + if (!ReadParam(aReader, &aResult->mThreadName)) { return false; } - if (!ReadParam(aMsg, aIter, &aResult->mRequestedDllName)) { + if (!ReadParam(aReader, &aResult->mRequestedDllName)) { return false; } @@ -586,20 +583,20 @@ struct ParamTraits { // mRequestedDllName unsanitized, so now is a good time to sanitize it. aResult->SanitizeRequestedDllName(); - if (!ReadParam(aMsg, aIter, &aResult->mBaseAddress)) { + if (!ReadParam(aReader, &aResult->mBaseAddress)) { return false; } - if (!ReadParam(aMsg, aIter, &aResult->mIsDependent)) { + if (!ReadParam(aReader, &aResult->mIsDependent)) { return false; } - if (!ReadParam(aMsg, aIter, &aResult->mLoadStatus)) { + if (!ReadParam(aReader, &aResult->mLoadStatus)) { return false; } nsAutoString resolvedNtName; - if (!ReadParam(aMsg, aIter, &resolvedNtName)) { + if (!ReadParam(aReader, &resolvedNtName)) { return false; } @@ -617,18 +614,17 @@ template <> struct ParamTraits { typedef mozilla::ModulesMapResult paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mModules); - aMsg->WriteUInt32(aParam.mTrustTestFailures); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mModules); + aWriter->WriteUInt32(aParam.mTrustTestFailures); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - if (!ReadParam(aMsg, aIter, &aResult->mModules)) { + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &aResult->mModules)) { return false; } - if (!aMsg->ReadUInt32(aIter, &aResult->mTrustTestFailures)) { + if (!aReader->ReadUInt32(&aResult->mTrustTestFailures)) { return false; } diff --git a/widget/nsGUIEventIPC.h b/widget/nsGUIEventIPC.h index 66543130b97d..586db2737a61 100644 --- a/widget/nsGUIEventIPC.h +++ b/widget/nsGUIEventIPC.h @@ -32,13 +32,12 @@ template <> struct ParamTraits { typedef mozilla::BaseEventFlags paramType; - static void Write(Message* aMsg, const paramType& aParam) { - aMsg->WriteBytes(&aParam, sizeof(aParam)); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + aWriter->WriteBytes(&aParam, sizeof(aParam)); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return aMsg->ReadBytesInto(aIter, aResult, sizeof(*aResult)); + static bool Read(MessageReader* aReader, paramType* aResult) { + return aReader->ReadBytesInto(aResult, sizeof(*aResult)); } }; @@ -46,31 +45,30 @@ template <> struct ParamTraits { typedef mozilla::WidgetEvent paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { // Mark the event as posted to another process. const_cast(aParam).MarkAsPostedToRemoteProcess(); - WriteParam(aMsg, static_cast(aParam.mClass)); - WriteParam(aMsg, aParam.mMessage); - WriteParam(aMsg, aParam.mRefPoint); - WriteParam(aMsg, aParam.mFocusSequenceNumber); - WriteParam(aMsg, aParam.mTime); - WriteParam(aMsg, aParam.mTimeStamp); - WriteParam(aMsg, aParam.mFlags); - WriteParam(aMsg, aParam.mLayersId); + WriteParam(aWriter, static_cast(aParam.mClass)); + WriteParam(aWriter, aParam.mMessage); + WriteParam(aWriter, aParam.mRefPoint); + WriteParam(aWriter, aParam.mFocusSequenceNumber); + WriteParam(aWriter, aParam.mTime); + WriteParam(aWriter, aParam.mTimeStamp); + WriteParam(aWriter, aParam.mFlags); + WriteParam(aWriter, aParam.mLayersId); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { mozilla::EventClassIDType eventClassID = 0; - bool ret = ReadParam(aMsg, aIter, &eventClassID) && - ReadParam(aMsg, aIter, &aResult->mMessage) && - ReadParam(aMsg, aIter, &aResult->mRefPoint) && - ReadParam(aMsg, aIter, &aResult->mFocusSequenceNumber) && - ReadParam(aMsg, aIter, &aResult->mTime) && - ReadParam(aMsg, aIter, &aResult->mTimeStamp) && - ReadParam(aMsg, aIter, &aResult->mFlags) && - ReadParam(aMsg, aIter, &aResult->mLayersId); + bool ret = ReadParam(aReader, &eventClassID) && + ReadParam(aReader, &aResult->mMessage) && + ReadParam(aReader, &aResult->mRefPoint) && + ReadParam(aReader, &aResult->mFocusSequenceNumber) && + ReadParam(aReader, &aResult->mTime) && + ReadParam(aReader, &aResult->mTimeStamp) && + ReadParam(aReader, &aResult->mFlags) && + ReadParam(aReader, &aResult->mLayersId); aResult->mClass = static_cast(eventClassID); if (ret) { // Reset cross process dispatching state here because the event has not @@ -87,13 +85,12 @@ template <> struct ParamTraits { typedef mozilla::WidgetGUIEvent paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, static_cast(aParam)); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, static_cast(aParam)); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, static_cast(aResult)); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, static_cast(aResult)); } }; @@ -101,16 +98,14 @@ template <> struct ParamTraits { typedef mozilla::WidgetInputEvent paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, static_cast(aParam)); - WriteParam(aMsg, aParam.mModifiers); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, static_cast(aParam)); + WriteParam(aWriter, aParam.mModifiers); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, - static_cast(aResult)) && - ReadParam(aMsg, aIter, &aResult->mModifiers); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, static_cast(aResult)) && + ReadParam(aReader, &aResult->mModifiers); } }; @@ -118,22 +113,21 @@ template <> struct ParamTraits { typedef mozilla::WidgetMouseEventBase paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, static_cast(aParam)); - WriteParam(aMsg, aParam.mButton); - WriteParam(aMsg, aParam.mButtons); - WriteParam(aMsg, aParam.mPressure); - WriteParam(aMsg, aParam.mInputSource); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, static_cast(aParam)); + WriteParam(aWriter, aParam.mButton); + WriteParam(aWriter, aParam.mButtons); + WriteParam(aWriter, aParam.mPressure); + WriteParam(aWriter, aParam.mInputSource); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, static_cast(aResult)) && - ReadParam(aMsg, aIter, &aResult->mButton) && - ReadParam(aMsg, aIter, &aResult->mButtons) && - ReadParam(aMsg, aIter, &aResult->mPressure) && - ReadParam(aMsg, aIter, &aResult->mInputSource); + ReadParam(aReader, &aResult->mButton) && + ReadParam(aReader, &aResult->mButtons) && + ReadParam(aReader, &aResult->mPressure) && + ReadParam(aReader, &aResult->mInputSource); } }; @@ -141,55 +135,54 @@ template <> struct ParamTraits { typedef mozilla::WidgetWheelEvent paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, static_cast(aParam)); - WriteParam(aMsg, aParam.mDeltaX); - WriteParam(aMsg, aParam.mDeltaY); - WriteParam(aMsg, aParam.mDeltaZ); - WriteParam(aMsg, aParam.mDeltaMode); - WriteParam(aMsg, aParam.mWheelTicksX); - WriteParam(aMsg, aParam.mWheelTicksY); - WriteParam(aMsg, aParam.mCustomizedByUserPrefs); - WriteParam(aMsg, aParam.mMayHaveMomentum); - WriteParam(aMsg, aParam.mIsMomentum); - WriteParam(aMsg, aParam.mIsNoLineOrPageDelta); - WriteParam(aMsg, aParam.mLineOrPageDeltaX); - WriteParam(aMsg, aParam.mLineOrPageDeltaY); - WriteParam(aMsg, static_cast(aParam.mScrollType)); - WriteParam(aMsg, aParam.mOverflowDeltaX); - WriteParam(aMsg, aParam.mOverflowDeltaY); - WriteParam(aMsg, aParam.mViewPortIsOverscrolled); - WriteParam(aMsg, aParam.mCanTriggerSwipe); - WriteParam(aMsg, aParam.mAllowToOverrideSystemScrollSpeed); - WriteParam(aMsg, aParam.mDeltaValuesHorizontalizedForDefaultHandler); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, + static_cast(aParam)); + WriteParam(aWriter, aParam.mDeltaX); + WriteParam(aWriter, aParam.mDeltaY); + WriteParam(aWriter, aParam.mDeltaZ); + WriteParam(aWriter, aParam.mDeltaMode); + WriteParam(aWriter, aParam.mWheelTicksX); + WriteParam(aWriter, aParam.mWheelTicksY); + WriteParam(aWriter, aParam.mCustomizedByUserPrefs); + WriteParam(aWriter, aParam.mMayHaveMomentum); + WriteParam(aWriter, aParam.mIsMomentum); + WriteParam(aWriter, aParam.mIsNoLineOrPageDelta); + WriteParam(aWriter, aParam.mLineOrPageDeltaX); + WriteParam(aWriter, aParam.mLineOrPageDeltaY); + WriteParam(aWriter, static_cast(aParam.mScrollType)); + WriteParam(aWriter, aParam.mOverflowDeltaX); + WriteParam(aWriter, aParam.mOverflowDeltaY); + WriteParam(aWriter, aParam.mViewPortIsOverscrolled); + WriteParam(aWriter, aParam.mCanTriggerSwipe); + WriteParam(aWriter, aParam.mAllowToOverrideSystemScrollSpeed); + WriteParam(aWriter, aParam.mDeltaValuesHorizontalizedForDefaultHandler); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { uint8_t scrollType = 0; - bool rv = - ReadParam(aMsg, aIter, - static_cast(aResult)) && - ReadParam(aMsg, aIter, &aResult->mDeltaX) && - ReadParam(aMsg, aIter, &aResult->mDeltaY) && - ReadParam(aMsg, aIter, &aResult->mDeltaZ) && - ReadParam(aMsg, aIter, &aResult->mDeltaMode) && - ReadParam(aMsg, aIter, &aResult->mWheelTicksX) && - ReadParam(aMsg, aIter, &aResult->mWheelTicksY) && - ReadParam(aMsg, aIter, &aResult->mCustomizedByUserPrefs) && - ReadParam(aMsg, aIter, &aResult->mMayHaveMomentum) && - ReadParam(aMsg, aIter, &aResult->mIsMomentum) && - ReadParam(aMsg, aIter, &aResult->mIsNoLineOrPageDelta) && - ReadParam(aMsg, aIter, &aResult->mLineOrPageDeltaX) && - ReadParam(aMsg, aIter, &aResult->mLineOrPageDeltaY) && - ReadParam(aMsg, aIter, &scrollType) && - ReadParam(aMsg, aIter, &aResult->mOverflowDeltaX) && - ReadParam(aMsg, aIter, &aResult->mOverflowDeltaY) && - ReadParam(aMsg, aIter, &aResult->mViewPortIsOverscrolled) && - ReadParam(aMsg, aIter, &aResult->mCanTriggerSwipe) && - ReadParam(aMsg, aIter, &aResult->mAllowToOverrideSystemScrollSpeed) && - ReadParam(aMsg, aIter, - &aResult->mDeltaValuesHorizontalizedForDefaultHandler); + bool rv = ReadParam(aReader, + static_cast(aResult)) && + ReadParam(aReader, &aResult->mDeltaX) && + ReadParam(aReader, &aResult->mDeltaY) && + ReadParam(aReader, &aResult->mDeltaZ) && + ReadParam(aReader, &aResult->mDeltaMode) && + ReadParam(aReader, &aResult->mWheelTicksX) && + ReadParam(aReader, &aResult->mWheelTicksY) && + ReadParam(aReader, &aResult->mCustomizedByUserPrefs) && + ReadParam(aReader, &aResult->mMayHaveMomentum) && + ReadParam(aReader, &aResult->mIsMomentum) && + ReadParam(aReader, &aResult->mIsNoLineOrPageDelta) && + ReadParam(aReader, &aResult->mLineOrPageDeltaX) && + ReadParam(aReader, &aResult->mLineOrPageDeltaY) && + ReadParam(aReader, &scrollType) && + ReadParam(aReader, &aResult->mOverflowDeltaX) && + ReadParam(aReader, &aResult->mOverflowDeltaY) && + ReadParam(aReader, &aResult->mViewPortIsOverscrolled) && + ReadParam(aReader, &aResult->mCanTriggerSwipe) && + ReadParam(aReader, &aResult->mAllowToOverrideSystemScrollSpeed) && + ReadParam(aReader, + &aResult->mDeltaValuesHorizontalizedForDefaultHandler); aResult->mScrollType = static_cast(scrollType); return rv; @@ -200,24 +193,23 @@ template <> struct ParamTraits { typedef mozilla::WidgetPointerHelper paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.pointerId); - WriteParam(aMsg, aParam.tiltX); - WriteParam(aMsg, aParam.tiltY); - WriteParam(aMsg, aParam.twist); - WriteParam(aMsg, aParam.tangentialPressure); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.pointerId); + WriteParam(aWriter, aParam.tiltX); + WriteParam(aWriter, aParam.tiltY); + WriteParam(aWriter, aParam.twist); + WriteParam(aWriter, aParam.tangentialPressure); // We don't serialize convertToPointer since it's temporarily variable and // should be reset to default. } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { bool rv; - rv = ReadParam(aMsg, aIter, &aResult->pointerId) && - ReadParam(aMsg, aIter, &aResult->tiltX) && - ReadParam(aMsg, aIter, &aResult->tiltY) && - ReadParam(aMsg, aIter, &aResult->twist) && - ReadParam(aMsg, aIter, &aResult->tangentialPressure); + rv = ReadParam(aReader, &aResult->pointerId) && + ReadParam(aReader, &aResult->tiltX) && + ReadParam(aReader, &aResult->tiltY) && + ReadParam(aReader, &aResult->twist) && + ReadParam(aReader, &aResult->tangentialPressure); return rv; } }; @@ -226,46 +218,46 @@ template <> struct ParamTraits { typedef mozilla::WidgetMouseEvent paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, static_cast(aParam)); - WriteParam(aMsg, static_cast(aParam)); - WriteParam(aMsg, aParam.mIgnoreRootScrollFrame); - WriteParam(aMsg, aParam.mClickEventPrevented); - WriteParam(aMsg, static_cast(aParam.mReason)); - WriteParam(aMsg, static_cast( - aParam.mContextMenuTrigger)); - WriteParam(aMsg, aParam.mExitFrom.isSome()); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, + static_cast(aParam)); + WriteParam(aWriter, + static_cast(aParam)); + WriteParam(aWriter, aParam.mIgnoreRootScrollFrame); + WriteParam(aWriter, aParam.mClickEventPrevented); + WriteParam(aWriter, static_cast(aParam.mReason)); + WriteParam(aWriter, static_cast( + aParam.mContextMenuTrigger)); + WriteParam(aWriter, aParam.mExitFrom.isSome()); if (aParam.mExitFrom.isSome()) { - WriteParam( - aMsg, static_cast(aParam.mExitFrom.value())); + WriteParam(aWriter, static_cast( + aParam.mExitFrom.value())); } - WriteParam(aMsg, aParam.mClickCount); + WriteParam(aWriter, aParam.mClickCount); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { bool rv; paramType::ReasonType reason = 0; paramType::ContextMenuTriggerType contextMenuTrigger = 0; bool hasExitFrom = false; - rv = ReadParam(aMsg, aIter, + rv = ReadParam(aReader, static_cast(aResult)) && - ReadParam(aMsg, aIter, + ReadParam(aReader, static_cast(aResult)) && - ReadParam(aMsg, aIter, &aResult->mIgnoreRootScrollFrame) && - ReadParam(aMsg, aIter, &aResult->mClickEventPrevented) && - ReadParam(aMsg, aIter, &reason) && - ReadParam(aMsg, aIter, &contextMenuTrigger); + ReadParam(aReader, &aResult->mIgnoreRootScrollFrame) && + ReadParam(aReader, &aResult->mClickEventPrevented) && + ReadParam(aReader, &reason) && ReadParam(aReader, &contextMenuTrigger); aResult->mReason = static_cast(reason); aResult->mContextMenuTrigger = static_cast(contextMenuTrigger); - rv = rv && ReadParam(aMsg, aIter, &hasExitFrom); + rv = rv && ReadParam(aReader, &hasExitFrom); if (hasExitFrom) { paramType::ExitFromType exitFrom = 0; - rv = rv && ReadParam(aMsg, aIter, &exitFrom); + rv = rv && ReadParam(aReader, &exitFrom); aResult->mExitFrom = Some(static_cast(exitFrom)); } - rv = rv && ReadParam(aMsg, aIter, &aResult->mClickCount); + rv = rv && ReadParam(aReader, &aResult->mClickCount); return rv; } }; @@ -274,18 +266,17 @@ template <> struct ParamTraits { typedef mozilla::WidgetDragEvent paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, static_cast(aParam)); - WriteParam(aMsg, aParam.mUserCancelled); - WriteParam(aMsg, aParam.mDefaultPreventedOnContent); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, static_cast(aParam)); + WriteParam(aWriter, aParam.mUserCancelled); + WriteParam(aWriter, aParam.mDefaultPreventedOnContent); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - bool rv = ReadParam(aMsg, aIter, - static_cast(aResult)) && - ReadParam(aMsg, aIter, &aResult->mUserCancelled) && - ReadParam(aMsg, aIter, &aResult->mDefaultPreventedOnContent); + static bool Read(MessageReader* aReader, paramType* aResult) { + bool rv = + ReadParam(aReader, static_cast(aResult)) && + ReadParam(aReader, &aResult->mUserCancelled) && + ReadParam(aReader, &aResult->mDefaultPreventedOnContent); return rv; } }; @@ -294,20 +285,19 @@ template <> struct ParamTraits { typedef mozilla::WidgetPointerEvent paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, static_cast(aParam)); - WriteParam(aMsg, aParam.mWidth); - WriteParam(aMsg, aParam.mHeight); - WriteParam(aMsg, aParam.mIsPrimary); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, static_cast(aParam)); + WriteParam(aWriter, aParam.mWidth); + WriteParam(aWriter, aParam.mHeight); + WriteParam(aWriter, aParam.mIsPrimary); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - bool rv = ReadParam(aMsg, aIter, - static_cast(aResult)) && - ReadParam(aMsg, aIter, &aResult->mWidth) && - ReadParam(aMsg, aIter, &aResult->mHeight) && - ReadParam(aMsg, aIter, &aResult->mIsPrimary); + static bool Read(MessageReader* aReader, paramType* aResult) { + bool rv = + ReadParam(aReader, static_cast(aResult)) && + ReadParam(aReader, &aResult->mWidth) && + ReadParam(aReader, &aResult->mHeight) && + ReadParam(aReader, &aResult->mIsPrimary); return rv; } }; @@ -316,37 +306,35 @@ template <> struct ParamTraits { using paramType = mozilla::WidgetTouchEvent; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, static_cast(aParam)); - WriteParam(aMsg, aParam.mInputSource); - WriteParam(aMsg, aParam.mButton); - WriteParam(aMsg, aParam.mButtons); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, static_cast(aParam)); + WriteParam(aWriter, aParam.mInputSource); + WriteParam(aWriter, aParam.mButton); + WriteParam(aWriter, aParam.mButtons); // Sigh, Touch bites us again! We want to be able to do - // WriteParam(aMsg, aParam.mTouches); + // WriteParam(aWriter, aParam.mTouches); const paramType::TouchArray& touches = aParam.mTouches; - WriteParam(aMsg, touches.Length()); + WriteParam(aWriter, touches.Length()); for (uint32_t i = 0; i < touches.Length(); ++i) { mozilla::dom::Touch* touch = touches[i]; - WriteParam(aMsg, touch->mIdentifier); - WriteParam(aMsg, touch->mRefPoint); - WriteParam(aMsg, touch->mRadius); - WriteParam(aMsg, touch->mRotationAngle); - WriteParam(aMsg, touch->mForce); - WriteParam(aMsg, touch->tiltX); - WriteParam(aMsg, touch->tiltY); - WriteParam(aMsg, touch->twist); + WriteParam(aWriter, touch->mIdentifier); + WriteParam(aWriter, touch->mRefPoint); + WriteParam(aWriter, touch->mRadius); + WriteParam(aWriter, touch->mRotationAngle); + WriteParam(aWriter, touch->mForce); + WriteParam(aWriter, touch->tiltX); + WriteParam(aWriter, touch->tiltY); + WriteParam(aWriter, touch->twist); } } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { paramType::TouchArray::size_type numTouches; - if (!ReadParam(aMsg, aIter, - static_cast(aResult)) || - !ReadParam(aMsg, aIter, &aResult->mInputSource) || - !ReadParam(aMsg, aIter, &aResult->mButton) || - !ReadParam(aMsg, aIter, &aResult->mButtons) || - !ReadParam(aMsg, aIter, &numTouches)) { + if (!ReadParam(aReader, static_cast(aResult)) || + !ReadParam(aReader, &aResult->mInputSource) || + !ReadParam(aReader, &aResult->mButton) || + !ReadParam(aReader, &aResult->mButtons) || + !ReadParam(aReader, &numTouches)) { return false; } for (uint32_t i = 0; i < numTouches; ++i) { @@ -358,12 +346,10 @@ struct ParamTraits { uint32_t tiltX; uint32_t tiltY; uint32_t twist; - if (!ReadParam(aMsg, aIter, &identifier) || - !ReadParam(aMsg, aIter, &refPoint) || - !ReadParam(aMsg, aIter, &radius) || - !ReadParam(aMsg, aIter, &rotationAngle) || - !ReadParam(aMsg, aIter, &force) || !ReadParam(aMsg, aIter, &tiltX) || - !ReadParam(aMsg, aIter, &tiltY) || !ReadParam(aMsg, aIter, &twist)) { + if (!ReadParam(aReader, &identifier) || !ReadParam(aReader, &refPoint) || + !ReadParam(aReader, &radius) || !ReadParam(aReader, &rotationAngle) || + !ReadParam(aReader, &force) || !ReadParam(aReader, &tiltX) || + !ReadParam(aReader, &tiltY) || !ReadParam(aReader, &twist)) { return false; } auto* touch = new mozilla::dom::Touch(identifier, refPoint, radius, @@ -381,15 +367,14 @@ template <> struct ParamTraits { typedef mozilla::AlternativeCharCode paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mUnshiftedCharCode); - WriteParam(aMsg, aParam.mShiftedCharCode); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mUnshiftedCharCode); + WriteParam(aWriter, aParam.mShiftedCharCode); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mUnshiftedCharCode) && - ReadParam(aMsg, aIter, &aResult->mShiftedCharCode); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mUnshiftedCharCode) && + ReadParam(aReader, &aResult->mShiftedCharCode); } }; @@ -397,15 +382,14 @@ template <> struct ParamTraits { typedef mozilla::ShortcutKeyCandidate paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mCharCode); - WriteParam(aMsg, aParam.mIgnoreShift); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mCharCode); + WriteParam(aWriter, aParam.mIgnoreShift); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mCharCode) && - ReadParam(aMsg, aIter, &aResult->mIgnoreShift); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mCharCode) && + ReadParam(aReader, &aResult->mIgnoreShift); } }; @@ -413,62 +397,60 @@ template <> struct ParamTraits { typedef mozilla::WidgetKeyboardEvent paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, static_cast(aParam)); - WriteParam(aMsg, + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, static_cast(aParam)); + WriteParam(aWriter, static_cast(aParam.mKeyNameIndex)); - WriteParam(aMsg, + WriteParam(aWriter, static_cast(aParam.mCodeNameIndex)); - WriteParam(aMsg, aParam.mKeyValue); - WriteParam(aMsg, aParam.mCodeValue); - WriteParam(aMsg, aParam.mKeyCode); - WriteParam(aMsg, aParam.mCharCode); - WriteParam(aMsg, aParam.mPseudoCharCode); - WriteParam(aMsg, aParam.mAlternativeCharCodes); - WriteParam(aMsg, aParam.mIsRepeat); - WriteParam(aMsg, aParam.mLocation); - WriteParam(aMsg, aParam.mUniqueId); - WriteParam(aMsg, aParam.mIsSynthesizedByTIP); - WriteParam(aMsg, aParam.mMaybeSkippableInRemoteProcess); + WriteParam(aWriter, aParam.mKeyValue); + WriteParam(aWriter, aParam.mCodeValue); + WriteParam(aWriter, aParam.mKeyCode); + WriteParam(aWriter, aParam.mCharCode); + WriteParam(aWriter, aParam.mPseudoCharCode); + WriteParam(aWriter, aParam.mAlternativeCharCodes); + WriteParam(aWriter, aParam.mIsRepeat); + WriteParam(aWriter, aParam.mLocation); + WriteParam(aWriter, aParam.mUniqueId); + WriteParam(aWriter, aParam.mIsSynthesizedByTIP); + WriteParam(aWriter, aParam.mMaybeSkippableInRemoteProcess); // An OS-specific native event might be attached in |mNativeKeyEvent|, but // that cannot be copied across process boundaries. - WriteParam(aMsg, aParam.mEditCommandsForSingleLineEditor); - WriteParam(aMsg, aParam.mEditCommandsForMultiLineEditor); - WriteParam(aMsg, aParam.mEditCommandsForRichTextEditor); - WriteParam(aMsg, aParam.mEditCommandsForSingleLineEditorInitialized); - WriteParam(aMsg, aParam.mEditCommandsForMultiLineEditorInitialized); - WriteParam(aMsg, aParam.mEditCommandsForRichTextEditorInitialized); + WriteParam(aWriter, aParam.mEditCommandsForSingleLineEditor); + WriteParam(aWriter, aParam.mEditCommandsForMultiLineEditor); + WriteParam(aWriter, aParam.mEditCommandsForRichTextEditor); + WriteParam(aWriter, aParam.mEditCommandsForSingleLineEditorInitialized); + WriteParam(aWriter, aParam.mEditCommandsForMultiLineEditorInitialized); + WriteParam(aWriter, aParam.mEditCommandsForRichTextEditorInitialized); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { mozilla::KeyNameIndexType keyNameIndex = 0; mozilla::CodeNameIndexType codeNameIndex = 0; - if (ReadParam(aMsg, aIter, - static_cast(aResult)) && - ReadParam(aMsg, aIter, &keyNameIndex) && - ReadParam(aMsg, aIter, &codeNameIndex) && - ReadParam(aMsg, aIter, &aResult->mKeyValue) && - ReadParam(aMsg, aIter, &aResult->mCodeValue) && - ReadParam(aMsg, aIter, &aResult->mKeyCode) && - ReadParam(aMsg, aIter, &aResult->mCharCode) && - ReadParam(aMsg, aIter, &aResult->mPseudoCharCode) && - ReadParam(aMsg, aIter, &aResult->mAlternativeCharCodes) && - ReadParam(aMsg, aIter, &aResult->mIsRepeat) && - ReadParam(aMsg, aIter, &aResult->mLocation) && - ReadParam(aMsg, aIter, &aResult->mUniqueId) && - ReadParam(aMsg, aIter, &aResult->mIsSynthesizedByTIP) && - ReadParam(aMsg, aIter, &aResult->mMaybeSkippableInRemoteProcess) && - ReadParam(aMsg, aIter, &aResult->mEditCommandsForSingleLineEditor) && - ReadParam(aMsg, aIter, &aResult->mEditCommandsForMultiLineEditor) && - ReadParam(aMsg, aIter, &aResult->mEditCommandsForRichTextEditor) && - ReadParam(aMsg, aIter, + if (ReadParam(aReader, static_cast(aResult)) && + ReadParam(aReader, &keyNameIndex) && + ReadParam(aReader, &codeNameIndex) && + ReadParam(aReader, &aResult->mKeyValue) && + ReadParam(aReader, &aResult->mCodeValue) && + ReadParam(aReader, &aResult->mKeyCode) && + ReadParam(aReader, &aResult->mCharCode) && + ReadParam(aReader, &aResult->mPseudoCharCode) && + ReadParam(aReader, &aResult->mAlternativeCharCodes) && + ReadParam(aReader, &aResult->mIsRepeat) && + ReadParam(aReader, &aResult->mLocation) && + ReadParam(aReader, &aResult->mUniqueId) && + ReadParam(aReader, &aResult->mIsSynthesizedByTIP) && + ReadParam(aReader, &aResult->mMaybeSkippableInRemoteProcess) && + ReadParam(aReader, &aResult->mEditCommandsForSingleLineEditor) && + ReadParam(aReader, &aResult->mEditCommandsForMultiLineEditor) && + ReadParam(aReader, &aResult->mEditCommandsForRichTextEditor) && + ReadParam(aReader, &aResult->mEditCommandsForSingleLineEditorInitialized) && - ReadParam(aMsg, aIter, + ReadParam(aReader, &aResult->mEditCommandsForMultiLineEditorInitialized) && - ReadParam(aMsg, aIter, + ReadParam(aReader, &aResult->mEditCommandsForRichTextEditorInitialized)) { aResult->mKeyNameIndex = static_cast(keyNameIndex); aResult->mCodeNameIndex = @@ -484,25 +466,24 @@ template <> struct ParamTraits { typedef mozilla::TextRangeStyle paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mDefinedStyles); - WriteParam(aMsg, static_cast( - aParam.mLineStyle)); - WriteParam(aMsg, aParam.mIsBoldLine); - WriteParam(aMsg, aParam.mForegroundColor); - WriteParam(aMsg, aParam.mBackgroundColor); - WriteParam(aMsg, aParam.mUnderlineColor); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mDefinedStyles); + WriteParam(aWriter, static_cast( + aParam.mLineStyle)); + WriteParam(aWriter, aParam.mIsBoldLine); + WriteParam(aWriter, aParam.mForegroundColor); + WriteParam(aWriter, aParam.mBackgroundColor); + WriteParam(aWriter, aParam.mUnderlineColor); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { mozilla::TextRangeStyle::LineStyleType lineStyle; - if (!ReadParam(aMsg, aIter, &aResult->mDefinedStyles) || - !ReadParam(aMsg, aIter, &lineStyle) || - !ReadParam(aMsg, aIter, &aResult->mIsBoldLine) || - !ReadParam(aMsg, aIter, &aResult->mForegroundColor) || - !ReadParam(aMsg, aIter, &aResult->mBackgroundColor) || - !ReadParam(aMsg, aIter, &aResult->mUnderlineColor)) { + if (!ReadParam(aReader, &aResult->mDefinedStyles) || + !ReadParam(aReader, &lineStyle) || + !ReadParam(aReader, &aResult->mIsBoldLine) || + !ReadParam(aReader, &aResult->mForegroundColor) || + !ReadParam(aReader, &aResult->mBackgroundColor) || + !ReadParam(aReader, &aResult->mUnderlineColor)) { return false; } aResult->mLineStyle = mozilla::TextRangeStyle::ToLineStyle(lineStyle); @@ -514,20 +495,19 @@ template <> struct ParamTraits { typedef mozilla::TextRange paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mStartOffset); - WriteParam(aMsg, aParam.mEndOffset); - WriteParam(aMsg, mozilla::ToRawTextRangeType(aParam.mRangeType)); - WriteParam(aMsg, aParam.mRangeStyle); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mStartOffset); + WriteParam(aWriter, aParam.mEndOffset); + WriteParam(aWriter, mozilla::ToRawTextRangeType(aParam.mRangeType)); + WriteParam(aWriter, aParam.mRangeStyle); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { mozilla::RawTextRangeType rawTextRangeType; - if (ReadParam(aMsg, aIter, &aResult->mStartOffset) && - ReadParam(aMsg, aIter, &aResult->mEndOffset) && - ReadParam(aMsg, aIter, &rawTextRangeType) && - ReadParam(aMsg, aIter, &aResult->mRangeStyle)) { + if (ReadParam(aReader, &aResult->mStartOffset) && + ReadParam(aReader, &aResult->mEndOffset) && + ReadParam(aReader, &rawTextRangeType) && + ReadParam(aReader, &aResult->mRangeStyle)) { aResult->mRangeType = mozilla::ToTextRangeType(rawTextRangeType); return true; } @@ -539,22 +519,21 @@ template <> struct ParamTraits { typedef mozilla::TextRangeArray paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.Length()); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.Length()); for (uint32_t index = 0; index < aParam.Length(); index++) { - WriteParam(aMsg, aParam[index]); + WriteParam(aWriter, aParam[index]); } } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { paramType::size_type length; - if (!ReadParam(aMsg, aIter, &length)) { + if (!ReadParam(aReader, &length)) { return false; } for (uint32_t index = 0; index < length; index++) { mozilla::TextRange textRange; - if (!ReadParam(aMsg, aIter, &textRange)) { + if (!ReadParam(aReader, &textRange)) { aResult->Clear(); return false; } @@ -568,25 +547,23 @@ template <> struct ParamTraits { typedef mozilla::WidgetCompositionEvent paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, static_cast(aParam)); - WriteParam(aMsg, aParam.mData); - WriteParam(aMsg, aParam.mNativeIMEContext); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, static_cast(aParam)); + WriteParam(aWriter, aParam.mData); + WriteParam(aWriter, aParam.mNativeIMEContext); bool hasRanges = !!aParam.mRanges; - WriteParam(aMsg, hasRanges); + WriteParam(aWriter, hasRanges); if (hasRanges) { - WriteParam(aMsg, *aParam.mRanges.get()); + WriteParam(aWriter, *aParam.mRanges.get()); } } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { bool hasRanges; - if (!ReadParam(aMsg, aIter, - static_cast(aResult)) || - !ReadParam(aMsg, aIter, &aResult->mData) || - !ReadParam(aMsg, aIter, &aResult->mNativeIMEContext) || - !ReadParam(aMsg, aIter, &hasRanges)) { + if (!ReadParam(aReader, static_cast(aResult)) || + !ReadParam(aReader, &aResult->mData) || + !ReadParam(aReader, &aResult->mNativeIMEContext) || + !ReadParam(aReader, &hasRanges)) { return false; } @@ -594,7 +571,7 @@ struct ParamTraits { aResult->mRanges = nullptr; } else { aResult->mRanges = new mozilla::TextRangeArray(); - if (!ReadParam(aMsg, aIter, aResult->mRanges.get())) { + if (!ReadParam(aReader, aResult->mRanges.get())) { return false; } } @@ -606,17 +583,16 @@ template <> struct ParamTraits { typedef mozilla::FontRange paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mStartOffset); - WriteParam(aMsg, aParam.mFontName); - WriteParam(aMsg, aParam.mFontSize); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mStartOffset); + WriteParam(aWriter, aParam.mFontName); + WriteParam(aWriter, aParam.mFontSize); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mStartOffset) && - ReadParam(aMsg, aIter, &aResult->mFontName) && - ReadParam(aMsg, aIter, &aResult->mFontSize); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mStartOffset) && + ReadParam(aReader, &aResult->mFontName) && + ReadParam(aReader, &aResult->mFontSize); } }; @@ -624,26 +600,24 @@ template <> struct ParamTraits { typedef mozilla::WidgetSelectionEvent paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, static_cast(aParam)); - WriteParam(aMsg, aParam.mOffset); - WriteParam(aMsg, aParam.mLength); - WriteParam(aMsg, aParam.mReversed); - WriteParam(aMsg, aParam.mExpandToClusterBoundary); - WriteParam(aMsg, aParam.mSucceeded); - WriteParam(aMsg, aParam.mUseNativeLineBreak); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, static_cast(aParam)); + WriteParam(aWriter, aParam.mOffset); + WriteParam(aWriter, aParam.mLength); + WriteParam(aWriter, aParam.mReversed); + WriteParam(aWriter, aParam.mExpandToClusterBoundary); + WriteParam(aWriter, aParam.mSucceeded); + WriteParam(aWriter, aParam.mUseNativeLineBreak); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, - static_cast(aResult)) && - ReadParam(aMsg, aIter, &aResult->mOffset) && - ReadParam(aMsg, aIter, &aResult->mLength) && - ReadParam(aMsg, aIter, &aResult->mReversed) && - ReadParam(aMsg, aIter, &aResult->mExpandToClusterBoundary) && - ReadParam(aMsg, aIter, &aResult->mSucceeded) && - ReadParam(aMsg, aIter, &aResult->mUseNativeLineBreak); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, static_cast(aResult)) && + ReadParam(aReader, &aResult->mOffset) && + ReadParam(aReader, &aResult->mLength) && + ReadParam(aReader, &aResult->mReversed) && + ReadParam(aReader, &aResult->mExpandToClusterBoundary) && + ReadParam(aReader, &aResult->mSucceeded) && + ReadParam(aReader, &aResult->mUseNativeLineBreak); } }; @@ -651,13 +625,12 @@ template <> struct ParamTraits { typedef mozilla::widget::IMENotificationRequests paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mWantUpdates); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mWantUpdates); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mWantUpdates); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mWantUpdates); } }; @@ -665,15 +638,14 @@ template <> struct ParamTraits { typedef mozilla::widget::NativeIMEContext paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mRawNativeIMEContext); - WriteParam(aMsg, aParam.mOriginProcessID); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mRawNativeIMEContext); + WriteParam(aWriter, aParam.mOriginProcessID); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mRawNativeIMEContext) && - ReadParam(aMsg, aIter, &aResult->mOriginProcessID); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mRawNativeIMEContext) && + ReadParam(aReader, &aResult->mOriginProcessID); } }; @@ -681,31 +653,30 @@ template <> struct ParamTraits { typedef mozilla::widget::IMENotification::SelectionChangeDataBase paramType; - static void Write(Message* aMsg, const paramType& aParam) { + static void Write(MessageWriter* aWriter, const paramType& aParam) { MOZ_RELEASE_ASSERT(aParam.mString); - WriteParam(aMsg, aParam.mOffset); - WriteParam(aMsg, *aParam.mString); - WriteParam(aMsg, aParam.mWritingModeBits); - WriteParam(aMsg, aParam.mIsInitialized); - WriteParam(aMsg, aParam.mHasRange); - WriteParam(aMsg, aParam.mReversed); - WriteParam(aMsg, aParam.mCausedByComposition); - WriteParam(aMsg, aParam.mCausedBySelectionEvent); - WriteParam(aMsg, aParam.mOccurredDuringComposition); + WriteParam(aWriter, aParam.mOffset); + WriteParam(aWriter, *aParam.mString); + WriteParam(aWriter, aParam.mWritingModeBits); + WriteParam(aWriter, aParam.mIsInitialized); + WriteParam(aWriter, aParam.mHasRange); + WriteParam(aWriter, aParam.mReversed); + WriteParam(aWriter, aParam.mCausedByComposition); + WriteParam(aWriter, aParam.mCausedBySelectionEvent); + WriteParam(aWriter, aParam.mOccurredDuringComposition); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { aResult->mString = new nsString(); - return ReadParam(aMsg, aIter, &aResult->mOffset) && - ReadParam(aMsg, aIter, aResult->mString) && - ReadParam(aMsg, aIter, &aResult->mWritingModeBits) && - ReadParam(aMsg, aIter, &aResult->mIsInitialized) && - ReadParam(aMsg, aIter, &aResult->mHasRange) && - ReadParam(aMsg, aIter, &aResult->mReversed) && - ReadParam(aMsg, aIter, &aResult->mCausedByComposition) && - ReadParam(aMsg, aIter, &aResult->mCausedBySelectionEvent) && - ReadParam(aMsg, aIter, &aResult->mOccurredDuringComposition); + return ReadParam(aReader, &aResult->mOffset) && + ReadParam(aReader, aResult->mString) && + ReadParam(aReader, &aResult->mWritingModeBits) && + ReadParam(aReader, &aResult->mIsInitialized) && + ReadParam(aReader, &aResult->mHasRange) && + ReadParam(aReader, &aResult->mReversed) && + ReadParam(aReader, &aResult->mCausedByComposition) && + ReadParam(aReader, &aResult->mCausedBySelectionEvent) && + ReadParam(aReader, &aResult->mOccurredDuringComposition); } }; @@ -713,25 +684,22 @@ template <> struct ParamTraits { typedef mozilla::widget::IMENotification::TextChangeDataBase paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mStartOffset); - WriteParam(aMsg, aParam.mRemovedEndOffset); - WriteParam(aMsg, aParam.mAddedEndOffset); - WriteParam(aMsg, aParam.mCausedOnlyByComposition); - WriteParam(aMsg, aParam.mIncludingChangesDuringComposition); - WriteParam(aMsg, aParam.mIncludingChangesWithoutComposition); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mStartOffset); + WriteParam(aWriter, aParam.mRemovedEndOffset); + WriteParam(aWriter, aParam.mAddedEndOffset); + WriteParam(aWriter, aParam.mCausedOnlyByComposition); + WriteParam(aWriter, aParam.mIncludingChangesDuringComposition); + WriteParam(aWriter, aParam.mIncludingChangesWithoutComposition); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mStartOffset) && - ReadParam(aMsg, aIter, &aResult->mRemovedEndOffset) && - ReadParam(aMsg, aIter, &aResult->mAddedEndOffset) && - ReadParam(aMsg, aIter, &aResult->mCausedOnlyByComposition) && - ReadParam(aMsg, aIter, - &aResult->mIncludingChangesDuringComposition) && - ReadParam(aMsg, aIter, - &aResult->mIncludingChangesWithoutComposition); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mStartOffset) && + ReadParam(aReader, &aResult->mRemovedEndOffset) && + ReadParam(aReader, &aResult->mAddedEndOffset) && + ReadParam(aReader, &aResult->mCausedOnlyByComposition) && + ReadParam(aReader, &aResult->mIncludingChangesDuringComposition) && + ReadParam(aReader, &aResult->mIncludingChangesWithoutComposition); } }; @@ -739,25 +707,24 @@ template <> struct ParamTraits { typedef mozilla::widget::IMENotification::MouseButtonEventData paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mEventMessage); - WriteParam(aMsg, aParam.mOffset); - WriteParam(aMsg, aParam.mCursorPos); - WriteParam(aMsg, aParam.mCharRect); - WriteParam(aMsg, aParam.mButton); - WriteParam(aMsg, aParam.mButtons); - WriteParam(aMsg, aParam.mModifiers); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mEventMessage); + WriteParam(aWriter, aParam.mOffset); + WriteParam(aWriter, aParam.mCursorPos); + WriteParam(aWriter, aParam.mCharRect); + WriteParam(aWriter, aParam.mButton); + WriteParam(aWriter, aParam.mButtons); + WriteParam(aWriter, aParam.mModifiers); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mEventMessage) && - ReadParam(aMsg, aIter, &aResult->mOffset) && - ReadParam(aMsg, aIter, &aResult->mCursorPos) && - ReadParam(aMsg, aIter, &aResult->mCharRect) && - ReadParam(aMsg, aIter, &aResult->mButton) && - ReadParam(aMsg, aIter, &aResult->mButtons) && - ReadParam(aMsg, aIter, &aResult->mModifiers); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mEventMessage) && + ReadParam(aReader, &aResult->mOffset) && + ReadParam(aReader, &aResult->mCursorPos) && + ReadParam(aReader, &aResult->mCharRect) && + ReadParam(aReader, &aResult->mButton) && + ReadParam(aReader, &aResult->mButtons) && + ReadParam(aReader, &aResult->mModifiers); } }; @@ -765,38 +732,37 @@ template <> struct ParamTraits { typedef mozilla::widget::IMENotification paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, static_cast(aParam.mMessage)); switch (aParam.mMessage) { case mozilla::widget::NOTIFY_IME_OF_SELECTION_CHANGE: - WriteParam(aMsg, aParam.mSelectionChangeData); + WriteParam(aWriter, aParam.mSelectionChangeData); return; case mozilla::widget::NOTIFY_IME_OF_TEXT_CHANGE: - WriteParam(aMsg, aParam.mTextChangeData); + WriteParam(aWriter, aParam.mTextChangeData); return; case mozilla::widget::NOTIFY_IME_OF_MOUSE_BUTTON_EVENT: - WriteParam(aMsg, aParam.mMouseButtonEventData); + WriteParam(aWriter, aParam.mMouseButtonEventData); return; default: return; } } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { + static bool Read(MessageReader* aReader, paramType* aResult) { mozilla::widget::IMEMessageType IMEMessage = 0; - if (!ReadParam(aMsg, aIter, &IMEMessage)) { + if (!ReadParam(aReader, &IMEMessage)) { return false; } aResult->mMessage = static_cast(IMEMessage); switch (aResult->mMessage) { case mozilla::widget::NOTIFY_IME_OF_SELECTION_CHANGE: - return ReadParam(aMsg, aIter, &aResult->mSelectionChangeData); + return ReadParam(aReader, &aResult->mSelectionChangeData); case mozilla::widget::NOTIFY_IME_OF_TEXT_CHANGE: - return ReadParam(aMsg, aIter, &aResult->mTextChangeData); + return ReadParam(aReader, &aResult->mTextChangeData); case mozilla::widget::NOTIFY_IME_OF_MOUSE_BUTTON_EVENT: - return ReadParam(aMsg, aIter, &aResult->mMouseButtonEventData); + return ReadParam(aReader, &aResult->mMouseButtonEventData); default: return true; } @@ -820,15 +786,14 @@ template <> struct ParamTraits { typedef mozilla::widget::IMEState paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mEnabled); - WriteParam(aMsg, aParam.mOpen); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mEnabled); + WriteParam(aWriter, aParam.mOpen); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mEnabled) && - ReadParam(aMsg, aIter, &aResult->mOpen); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mEnabled) && + ReadParam(aReader, &aResult->mOpen); } }; @@ -843,29 +808,28 @@ template <> struct ParamTraits { typedef mozilla::widget::InputContext paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mIMEState); - WriteParam(aMsg, aParam.mHTMLInputType); - WriteParam(aMsg, aParam.mHTMLInputInputmode); - WriteParam(aMsg, aParam.mActionHint); - WriteParam(aMsg, aParam.mAutocapitalize); - WriteParam(aMsg, aParam.mOrigin); - WriteParam(aMsg, aParam.mMayBeIMEUnaware); - WriteParam(aMsg, aParam.mHasHandledUserInput); - WriteParam(aMsg, aParam.mInPrivateBrowsing); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mIMEState); + WriteParam(aWriter, aParam.mHTMLInputType); + WriteParam(aWriter, aParam.mHTMLInputInputmode); + WriteParam(aWriter, aParam.mActionHint); + WriteParam(aWriter, aParam.mAutocapitalize); + WriteParam(aWriter, aParam.mOrigin); + WriteParam(aWriter, aParam.mMayBeIMEUnaware); + WriteParam(aWriter, aParam.mHasHandledUserInput); + WriteParam(aWriter, aParam.mInPrivateBrowsing); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mIMEState) && - ReadParam(aMsg, aIter, &aResult->mHTMLInputType) && - ReadParam(aMsg, aIter, &aResult->mHTMLInputInputmode) && - ReadParam(aMsg, aIter, &aResult->mActionHint) && - ReadParam(aMsg, aIter, &aResult->mAutocapitalize) && - ReadParam(aMsg, aIter, &aResult->mOrigin) && - ReadParam(aMsg, aIter, &aResult->mMayBeIMEUnaware) && - ReadParam(aMsg, aIter, &aResult->mHasHandledUserInput) && - ReadParam(aMsg, aIter, &aResult->mInPrivateBrowsing); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mIMEState) && + ReadParam(aReader, &aResult->mHTMLInputType) && + ReadParam(aReader, &aResult->mHTMLInputInputmode) && + ReadParam(aReader, &aResult->mActionHint) && + ReadParam(aReader, &aResult->mAutocapitalize) && + ReadParam(aReader, &aResult->mOrigin) && + ReadParam(aReader, &aResult->mMayBeIMEUnaware) && + ReadParam(aReader, &aResult->mHasHandledUserInput) && + ReadParam(aReader, &aResult->mInPrivateBrowsing); } }; @@ -888,15 +852,14 @@ template <> struct ParamTraits { typedef mozilla::widget::InputContextAction paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mCause); - WriteParam(aMsg, aParam.mFocusChange); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mCause); + WriteParam(aWriter, aParam.mFocusChange); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mCause) && - ReadParam(aMsg, aIter, &aResult->mFocusChange); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mCause) && + ReadParam(aReader, &aResult->mFocusChange); } }; @@ -904,13 +867,12 @@ template <> struct ParamTraits { typedef mozilla::WritingMode paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mWritingMode.bits); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mWritingMode.bits); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mWritingMode.bits); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mWritingMode.bits); } }; @@ -918,29 +880,28 @@ template <> struct ParamTraits { typedef mozilla::ContentCache::Selection paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mAnchor); - WriteParam(aMsg, aParam.mFocus); - WriteParam(aMsg, aParam.mWritingMode); - WriteParam(aMsg, aParam.mHasRange); - WriteParam(aMsg, aParam.mAnchorCharRects[0]); - WriteParam(aMsg, aParam.mAnchorCharRects[1]); - WriteParam(aMsg, aParam.mFocusCharRects[0]); - WriteParam(aMsg, aParam.mFocusCharRects[1]); - WriteParam(aMsg, aParam.mRect); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mAnchor); + WriteParam(aWriter, aParam.mFocus); + WriteParam(aWriter, aParam.mWritingMode); + WriteParam(aWriter, aParam.mHasRange); + WriteParam(aWriter, aParam.mAnchorCharRects[0]); + WriteParam(aWriter, aParam.mAnchorCharRects[1]); + WriteParam(aWriter, aParam.mFocusCharRects[0]); + WriteParam(aWriter, aParam.mFocusCharRects[1]); + WriteParam(aWriter, aParam.mRect); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mAnchor) && - ReadParam(aMsg, aIter, &aResult->mFocus) && - ReadParam(aMsg, aIter, &aResult->mWritingMode) && - ReadParam(aMsg, aIter, &aResult->mHasRange) && - ReadParam(aMsg, aIter, &aResult->mAnchorCharRects[0]) && - ReadParam(aMsg, aIter, &aResult->mAnchorCharRects[1]) && - ReadParam(aMsg, aIter, &aResult->mFocusCharRects[0]) && - ReadParam(aMsg, aIter, &aResult->mFocusCharRects[1]) && - ReadParam(aMsg, aIter, &aResult->mRect); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mAnchor) && + ReadParam(aReader, &aResult->mFocus) && + ReadParam(aReader, &aResult->mWritingMode) && + ReadParam(aReader, &aResult->mHasRange) && + ReadParam(aReader, &aResult->mAnchorCharRects[0]) && + ReadParam(aReader, &aResult->mAnchorCharRects[1]) && + ReadParam(aReader, &aResult->mFocusCharRects[0]) && + ReadParam(aReader, &aResult->mFocusCharRects[1]) && + ReadParam(aReader, &aResult->mRect); } }; @@ -948,15 +909,14 @@ template <> struct ParamTraits { typedef mozilla::ContentCache::Caret paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mOffset); - WriteParam(aMsg, aParam.mRect); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mOffset); + WriteParam(aWriter, aParam.mRect); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mOffset) && - ReadParam(aMsg, aIter, &aResult->mRect); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mOffset) && + ReadParam(aReader, &aResult->mRect); } }; @@ -964,15 +924,14 @@ template <> struct ParamTraits { typedef mozilla::ContentCache::TextRectArray paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mStart); - WriteParam(aMsg, aParam.mRects); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mStart); + WriteParam(aWriter, aParam.mRects); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mStart) && - ReadParam(aMsg, aIter, &aResult->mRects); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mStart) && + ReadParam(aReader, &aResult->mRects); } }; @@ -980,27 +939,26 @@ template <> struct ParamTraits { typedef mozilla::ContentCache paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mCompositionStart); - WriteParam(aMsg, aParam.mText); - WriteParam(aMsg, aParam.mSelection); - WriteParam(aMsg, aParam.mFirstCharRect); - WriteParam(aMsg, aParam.mCaret); - WriteParam(aMsg, aParam.mTextRectArray); - WriteParam(aMsg, aParam.mLastCommitStringTextRectArray); - WriteParam(aMsg, aParam.mEditorRect); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mCompositionStart); + WriteParam(aWriter, aParam.mText); + WriteParam(aWriter, aParam.mSelection); + WriteParam(aWriter, aParam.mFirstCharRect); + WriteParam(aWriter, aParam.mCaret); + WriteParam(aWriter, aParam.mTextRectArray); + WriteParam(aWriter, aParam.mLastCommitStringTextRectArray); + WriteParam(aWriter, aParam.mEditorRect); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mCompositionStart) && - ReadParam(aMsg, aIter, &aResult->mText) && - ReadParam(aMsg, aIter, &aResult->mSelection) && - ReadParam(aMsg, aIter, &aResult->mFirstCharRect) && - ReadParam(aMsg, aIter, &aResult->mCaret) && - ReadParam(aMsg, aIter, &aResult->mTextRectArray) && - ReadParam(aMsg, aIter, &aResult->mLastCommitStringTextRectArray) && - ReadParam(aMsg, aIter, &aResult->mEditorRect); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mCompositionStart) && + ReadParam(aReader, &aResult->mText) && + ReadParam(aReader, &aResult->mSelection) && + ReadParam(aReader, &aResult->mFirstCharRect) && + ReadParam(aReader, &aResult->mCaret) && + ReadParam(aReader, &aResult->mTextRectArray) && + ReadParam(aReader, &aResult->mLastCommitStringTextRectArray) && + ReadParam(aReader, &aResult->mEditorRect); } }; @@ -1008,17 +966,16 @@ template <> struct ParamTraits { typedef mozilla::widget::CandidateWindowPosition paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mPoint); - WriteParam(aMsg, aParam.mRect); - WriteParam(aMsg, aParam.mExcludeRect); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mPoint); + WriteParam(aWriter, aParam.mRect); + WriteParam(aWriter, aParam.mExcludeRect); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mPoint) && - ReadParam(aMsg, aIter, &aResult->mRect) && - ReadParam(aMsg, aIter, &aResult->mExcludeRect); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mPoint) && + ReadParam(aReader, &aResult->mRect) && + ReadParam(aReader, &aResult->mExcludeRect); } }; @@ -1034,23 +991,22 @@ template <> struct ParamTraits { typedef mozilla::InputData paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mInputType); - WriteParam(aMsg, aParam.mTime); - WriteParam(aMsg, aParam.mTimeStamp); - WriteParam(aMsg, aParam.modifiers); - WriteParam(aMsg, aParam.mFocusSequenceNumber); - WriteParam(aMsg, aParam.mLayersId); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mInputType); + WriteParam(aWriter, aParam.mTime); + WriteParam(aWriter, aParam.mTimeStamp); + WriteParam(aWriter, aParam.modifiers); + WriteParam(aWriter, aParam.mFocusSequenceNumber); + WriteParam(aWriter, aParam.mLayersId); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mInputType) && - ReadParam(aMsg, aIter, &aResult->mTime) && - ReadParam(aMsg, aIter, &aResult->mTimeStamp) && - ReadParam(aMsg, aIter, &aResult->modifiers) && - ReadParam(aMsg, aIter, &aResult->mFocusSequenceNumber) && - ReadParam(aMsg, aIter, &aResult->mLayersId); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->mInputType) && + ReadParam(aReader, &aResult->mTime) && + ReadParam(aReader, &aResult->mTimeStamp) && + ReadParam(aReader, &aResult->modifiers) && + ReadParam(aReader, &aResult->mFocusSequenceNumber) && + ReadParam(aReader, &aResult->mLayersId); } }; @@ -1058,23 +1014,22 @@ template <> struct ParamTraits { typedef mozilla::SingleTouchData::HistoricalTouchData paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mTimeStamp); - WriteParam(aMsg, aParam.mScreenPoint); - WriteParam(aMsg, aParam.mLocalScreenPoint); - WriteParam(aMsg, aParam.mRadius); - WriteParam(aMsg, aParam.mRotationAngle); - WriteParam(aMsg, aParam.mForce); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mTimeStamp); + WriteParam(aWriter, aParam.mScreenPoint); + WriteParam(aWriter, aParam.mLocalScreenPoint); + WriteParam(aWriter, aParam.mRadius); + WriteParam(aWriter, aParam.mRotationAngle); + WriteParam(aWriter, aParam.mForce); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return (ReadParam(aMsg, aIter, &aResult->mTimeStamp) && - ReadParam(aMsg, aIter, &aResult->mScreenPoint) && - ReadParam(aMsg, aIter, &aResult->mLocalScreenPoint) && - ReadParam(aMsg, aIter, &aResult->mRadius) && - ReadParam(aMsg, aIter, &aResult->mRotationAngle) && - ReadParam(aMsg, aIter, &aResult->mForce)); + static bool Read(MessageReader* aReader, paramType* aResult) { + return (ReadParam(aReader, &aResult->mTimeStamp) && + ReadParam(aReader, &aResult->mScreenPoint) && + ReadParam(aReader, &aResult->mLocalScreenPoint) && + ReadParam(aReader, &aResult->mRadius) && + ReadParam(aReader, &aResult->mRotationAngle) && + ReadParam(aReader, &aResult->mForce)); } }; @@ -1082,31 +1037,30 @@ template <> struct ParamTraits { using paramType = mozilla::SingleTouchData; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mHistoricalData); - WriteParam(aMsg, aParam.mIdentifier); - WriteParam(aMsg, aParam.mScreenPoint); - WriteParam(aMsg, aParam.mLocalScreenPoint); - WriteParam(aMsg, aParam.mRadius); - WriteParam(aMsg, aParam.mRotationAngle); - WriteParam(aMsg, aParam.mForce); - WriteParam(aMsg, aParam.mTiltX); - WriteParam(aMsg, aParam.mTiltY); - WriteParam(aMsg, aParam.mTwist); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mHistoricalData); + WriteParam(aWriter, aParam.mIdentifier); + WriteParam(aWriter, aParam.mScreenPoint); + WriteParam(aWriter, aParam.mLocalScreenPoint); + WriteParam(aWriter, aParam.mRadius); + WriteParam(aWriter, aParam.mRotationAngle); + WriteParam(aWriter, aParam.mForce); + WriteParam(aWriter, aParam.mTiltX); + WriteParam(aWriter, aParam.mTiltY); + WriteParam(aWriter, aParam.mTwist); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return (ReadParam(aMsg, aIter, &aResult->mHistoricalData) && - ReadParam(aMsg, aIter, &aResult->mIdentifier) && - ReadParam(aMsg, aIter, &aResult->mScreenPoint) && - ReadParam(aMsg, aIter, &aResult->mLocalScreenPoint) && - ReadParam(aMsg, aIter, &aResult->mRadius) && - ReadParam(aMsg, aIter, &aResult->mRotationAngle) && - ReadParam(aMsg, aIter, &aResult->mForce) && - ReadParam(aMsg, aIter, &aResult->mTiltX) && - ReadParam(aMsg, aIter, &aResult->mTiltY) && - ReadParam(aMsg, aIter, &aResult->mTwist)); + static bool Read(MessageReader* aReader, paramType* aResult) { + return (ReadParam(aReader, &aResult->mHistoricalData) && + ReadParam(aReader, &aResult->mIdentifier) && + ReadParam(aReader, &aResult->mScreenPoint) && + ReadParam(aReader, &aResult->mLocalScreenPoint) && + ReadParam(aReader, &aResult->mRadius) && + ReadParam(aReader, &aResult->mRotationAngle) && + ReadParam(aReader, &aResult->mForce) && + ReadParam(aReader, &aResult->mTiltX) && + ReadParam(aReader, &aResult->mTiltY) && + ReadParam(aReader, &aResult->mTwist)); } }; @@ -1121,25 +1075,24 @@ template <> struct ParamTraits { using paramType = mozilla::MultiTouchInput; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, static_cast(aParam)); - WriteParam(aMsg, aParam.mType); - WriteParam(aMsg, aParam.mTouches); - WriteParam(aMsg, aParam.mHandledByAPZ); - WriteParam(aMsg, aParam.mScreenOffset); - WriteParam(aMsg, aParam.mButton); - WriteParam(aMsg, aParam.mButtons); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, static_cast(aParam)); + WriteParam(aWriter, aParam.mType); + WriteParam(aWriter, aParam.mTouches); + WriteParam(aWriter, aParam.mHandledByAPZ); + WriteParam(aWriter, aParam.mScreenOffset); + WriteParam(aWriter, aParam.mButton); + WriteParam(aWriter, aParam.mButtons); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, static_cast(aResult)) && - ReadParam(aMsg, aIter, &aResult->mType) && - ReadParam(aMsg, aIter, &aResult->mTouches) && - ReadParam(aMsg, aIter, &aResult->mHandledByAPZ) && - ReadParam(aMsg, aIter, &aResult->mScreenOffset) && - ReadParam(aMsg, aIter, &aResult->mButton) && - ReadParam(aMsg, aIter, &aResult->mButtons); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, static_cast(aResult)) && + ReadParam(aReader, &aResult->mType) && + ReadParam(aReader, &aResult->mTouches) && + ReadParam(aReader, &aResult->mHandledByAPZ) && + ReadParam(aReader, &aResult->mScreenOffset) && + ReadParam(aReader, &aResult->mButton) && + ReadParam(aReader, &aResult->mButtons); } }; @@ -1161,29 +1114,28 @@ template <> struct ParamTraits { typedef mozilla::MouseInput paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, static_cast(aParam)); - WriteParam(aMsg, aParam.mButtonType); - WriteParam(aMsg, aParam.mType); - WriteParam(aMsg, aParam.mInputSource); - WriteParam(aMsg, aParam.mButtons); - WriteParam(aMsg, aParam.mOrigin); - WriteParam(aMsg, aParam.mLocalOrigin); - WriteParam(aMsg, aParam.mHandledByAPZ); - WriteParam(aMsg, aParam.mPreventClickEvent); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, static_cast(aParam)); + WriteParam(aWriter, aParam.mButtonType); + WriteParam(aWriter, aParam.mType); + WriteParam(aWriter, aParam.mInputSource); + WriteParam(aWriter, aParam.mButtons); + WriteParam(aWriter, aParam.mOrigin); + WriteParam(aWriter, aParam.mLocalOrigin); + WriteParam(aWriter, aParam.mHandledByAPZ); + WriteParam(aWriter, aParam.mPreventClickEvent); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, static_cast(aResult)) && - ReadParam(aMsg, aIter, &aResult->mButtonType) && - ReadParam(aMsg, aIter, &aResult->mType) && - ReadParam(aMsg, aIter, &aResult->mInputSource) && - ReadParam(aMsg, aIter, &aResult->mButtons) && - ReadParam(aMsg, aIter, &aResult->mOrigin) && - ReadParam(aMsg, aIter, &aResult->mLocalOrigin) && - ReadParam(aMsg, aIter, &aResult->mHandledByAPZ) && - ReadParam(aMsg, aIter, &aResult->mPreventClickEvent); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, static_cast(aResult)) && + ReadParam(aReader, &aResult->mButtonType) && + ReadParam(aReader, &aResult->mType) && + ReadParam(aReader, &aResult->mInputSource) && + ReadParam(aReader, &aResult->mButtons) && + ReadParam(aReader, &aResult->mOrigin) && + ReadParam(aReader, &aResult->mLocalOrigin) && + ReadParam(aReader, &aResult->mHandledByAPZ) && + ReadParam(aReader, &aResult->mPreventClickEvent); } }; @@ -1206,52 +1158,50 @@ struct ParamTraits : BitfieldHelper { typedef mozilla::PanGestureInput paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, static_cast(aParam)); - WriteParam(aMsg, aParam.mType); - WriteParam(aMsg, aParam.mPanStartPoint); - WriteParam(aMsg, aParam.mPanDisplacement); - WriteParam(aMsg, aParam.mLocalPanStartPoint); - WriteParam(aMsg, aParam.mLocalPanDisplacement); - WriteParam(aMsg, aParam.mLineOrPageDeltaX); - WriteParam(aMsg, aParam.mLineOrPageDeltaY); - WriteParam(aMsg, aParam.mUserDeltaMultiplierX); - WriteParam(aMsg, aParam.mUserDeltaMultiplierY); - WriteParam(aMsg, aParam.mDeltaType); - WriteParam(aMsg, aParam.mHandledByAPZ); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, static_cast(aParam)); + WriteParam(aWriter, aParam.mType); + WriteParam(aWriter, aParam.mPanStartPoint); + WriteParam(aWriter, aParam.mPanDisplacement); + WriteParam(aWriter, aParam.mLocalPanStartPoint); + WriteParam(aWriter, aParam.mLocalPanDisplacement); + WriteParam(aWriter, aParam.mLineOrPageDeltaX); + WriteParam(aWriter, aParam.mLineOrPageDeltaY); + WriteParam(aWriter, aParam.mUserDeltaMultiplierX); + WriteParam(aWriter, aParam.mUserDeltaMultiplierY); + WriteParam(aWriter, aParam.mDeltaType); + WriteParam(aWriter, aParam.mHandledByAPZ); WriteParam( - aMsg, + aWriter, aParam .mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection); - WriteParam(aMsg, aParam.mOverscrollBehaviorAllowsSwipe); - WriteParam(aMsg, aParam.mSimulateMomentum); - WriteParam(aMsg, aParam.mIsNoLineOrPageDelta); + WriteParam(aWriter, aParam.mOverscrollBehaviorAllowsSwipe); + WriteParam(aWriter, aParam.mSimulateMomentum); + WriteParam(aWriter, aParam.mIsNoLineOrPageDelta); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, static_cast(aResult)) && - ReadParam(aMsg, aIter, &aResult->mType) && - ReadParam(aMsg, aIter, &aResult->mPanStartPoint) && - ReadParam(aMsg, aIter, &aResult->mPanDisplacement) && - ReadParam(aMsg, aIter, &aResult->mLocalPanStartPoint) && - ReadParam(aMsg, aIter, &aResult->mLocalPanDisplacement) && - ReadParam(aMsg, aIter, &aResult->mLineOrPageDeltaX) && - ReadParam(aMsg, aIter, &aResult->mLineOrPageDeltaY) && - ReadParam(aMsg, aIter, &aResult->mUserDeltaMultiplierX) && - ReadParam(aMsg, aIter, &aResult->mUserDeltaMultiplierY) && - ReadParam(aMsg, aIter, &aResult->mDeltaType) && - ReadBoolForBitfield(aMsg, aIter, aResult, - ¶mType::SetHandledByAPZ) && + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, static_cast(aResult)) && + ReadParam(aReader, &aResult->mType) && + ReadParam(aReader, &aResult->mPanStartPoint) && + ReadParam(aReader, &aResult->mPanDisplacement) && + ReadParam(aReader, &aResult->mLocalPanStartPoint) && + ReadParam(aReader, &aResult->mLocalPanDisplacement) && + ReadParam(aReader, &aResult->mLineOrPageDeltaX) && + ReadParam(aReader, &aResult->mLineOrPageDeltaY) && + ReadParam(aReader, &aResult->mUserDeltaMultiplierX) && + ReadParam(aReader, &aResult->mUserDeltaMultiplierY) && + ReadParam(aReader, &aResult->mDeltaType) && + ReadBoolForBitfield(aReader, aResult, ¶mType::SetHandledByAPZ) && ReadBoolForBitfield( - aMsg, aIter, aResult, + aReader, aResult, ¶mType:: SetRequiresContentResponseIfCannotScrollHorizontallyInStartDirection) && - ReadBoolForBitfield(aMsg, aIter, aResult, + ReadBoolForBitfield(aReader, aResult, ¶mType::SetOverscrollBehaviorAllowsSwipe) && - ReadBoolForBitfield(aMsg, aIter, aResult, + ReadBoolForBitfield(aReader, aResult, ¶mType::SetSimulateMomentum) && - ReadBoolForBitfield(aMsg, aIter, aResult, + ReadBoolForBitfield(aReader, aResult, ¶mType::SetIsNoLineOrPageDelta); } }; @@ -1275,31 +1225,30 @@ template <> struct ParamTraits { typedef mozilla::PinchGestureInput paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, static_cast(aParam)); - WriteParam(aMsg, aParam.mType); - WriteParam(aMsg, aParam.mSource); - WriteParam(aMsg, aParam.mScreenOffset); - WriteParam(aMsg, aParam.mFocusPoint); - WriteParam(aMsg, aParam.mLocalFocusPoint); - WriteParam(aMsg, aParam.mCurrentSpan); - WriteParam(aMsg, aParam.mPreviousSpan); - WriteParam(aMsg, aParam.mLineOrPageDeltaY); - WriteParam(aMsg, aParam.mHandledByAPZ); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, static_cast(aParam)); + WriteParam(aWriter, aParam.mType); + WriteParam(aWriter, aParam.mSource); + WriteParam(aWriter, aParam.mScreenOffset); + WriteParam(aWriter, aParam.mFocusPoint); + WriteParam(aWriter, aParam.mLocalFocusPoint); + WriteParam(aWriter, aParam.mCurrentSpan); + WriteParam(aWriter, aParam.mPreviousSpan); + WriteParam(aWriter, aParam.mLineOrPageDeltaY); + WriteParam(aWriter, aParam.mHandledByAPZ); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, static_cast(aResult)) && - ReadParam(aMsg, aIter, &aResult->mType) && - ReadParam(aMsg, aIter, &aResult->mSource) && - ReadParam(aMsg, aIter, &aResult->mScreenOffset) && - ReadParam(aMsg, aIter, &aResult->mFocusPoint) && - ReadParam(aMsg, aIter, &aResult->mLocalFocusPoint) && - ReadParam(aMsg, aIter, &aResult->mCurrentSpan) && - ReadParam(aMsg, aIter, &aResult->mPreviousSpan) && - ReadParam(aMsg, aIter, &aResult->mLineOrPageDeltaY) && - ReadParam(aMsg, aIter, &aResult->mHandledByAPZ); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, static_cast(aResult)) && + ReadParam(aReader, &aResult->mType) && + ReadParam(aReader, &aResult->mSource) && + ReadParam(aReader, &aResult->mScreenOffset) && + ReadParam(aReader, &aResult->mFocusPoint) && + ReadParam(aReader, &aResult->mLocalFocusPoint) && + ReadParam(aReader, &aResult->mCurrentSpan) && + ReadParam(aReader, &aResult->mPreviousSpan) && + ReadParam(aReader, &aResult->mLineOrPageDeltaY) && + ReadParam(aReader, &aResult->mHandledByAPZ); } }; @@ -1314,19 +1263,18 @@ template <> struct ParamTraits { typedef mozilla::TapGestureInput paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, static_cast(aParam)); - WriteParam(aMsg, aParam.mType); - WriteParam(aMsg, aParam.mPoint); - WriteParam(aMsg, aParam.mLocalPoint); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, static_cast(aParam)); + WriteParam(aWriter, aParam.mType); + WriteParam(aWriter, aParam.mPoint); + WriteParam(aWriter, aParam.mLocalPoint); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, static_cast(aResult)) && - ReadParam(aMsg, aIter, &aResult->mType) && - ReadParam(aMsg, aIter, &aResult->mPoint) && - ReadParam(aMsg, aIter, &aResult->mLocalPoint); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, static_cast(aResult)) && + ReadParam(aReader, &aResult->mType) && + ReadParam(aReader, &aResult->mPoint) && + ReadParam(aReader, &aResult->mLocalPoint); } }; @@ -1362,52 +1310,50 @@ template <> struct ParamTraits { typedef mozilla::ScrollWheelInput paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, static_cast(aParam)); - WriteParam(aMsg, aParam.mDeltaType); - WriteParam(aMsg, aParam.mScrollMode); - WriteParam(aMsg, aParam.mOrigin); - WriteParam(aMsg, aParam.mHandledByAPZ); - WriteParam(aMsg, aParam.mDeltaX); - WriteParam(aMsg, aParam.mDeltaY); - WriteParam(aMsg, aParam.mWheelTicksX); - WriteParam(aMsg, aParam.mWheelTicksY); - WriteParam(aMsg, aParam.mLocalOrigin); - WriteParam(aMsg, aParam.mLineOrPageDeltaX); - WriteParam(aMsg, aParam.mLineOrPageDeltaY); - WriteParam(aMsg, aParam.mScrollSeriesNumber); - WriteParam(aMsg, aParam.mUserDeltaMultiplierX); - WriteParam(aMsg, aParam.mUserDeltaMultiplierY); - WriteParam(aMsg, aParam.mMayHaveMomentum); - WriteParam(aMsg, aParam.mIsMomentum); - WriteParam(aMsg, aParam.mAllowToOverrideSystemScrollSpeed); - WriteParam(aMsg, aParam.mWheelDeltaAdjustmentStrategy); - WriteParam(aMsg, aParam.mAPZAction); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, static_cast(aParam)); + WriteParam(aWriter, aParam.mDeltaType); + WriteParam(aWriter, aParam.mScrollMode); + WriteParam(aWriter, aParam.mOrigin); + WriteParam(aWriter, aParam.mHandledByAPZ); + WriteParam(aWriter, aParam.mDeltaX); + WriteParam(aWriter, aParam.mDeltaY); + WriteParam(aWriter, aParam.mWheelTicksX); + WriteParam(aWriter, aParam.mWheelTicksY); + WriteParam(aWriter, aParam.mLocalOrigin); + WriteParam(aWriter, aParam.mLineOrPageDeltaX); + WriteParam(aWriter, aParam.mLineOrPageDeltaY); + WriteParam(aWriter, aParam.mScrollSeriesNumber); + WriteParam(aWriter, aParam.mUserDeltaMultiplierX); + WriteParam(aWriter, aParam.mUserDeltaMultiplierY); + WriteParam(aWriter, aParam.mMayHaveMomentum); + WriteParam(aWriter, aParam.mIsMomentum); + WriteParam(aWriter, aParam.mAllowToOverrideSystemScrollSpeed); + WriteParam(aWriter, aParam.mWheelDeltaAdjustmentStrategy); + WriteParam(aWriter, aParam.mAPZAction); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, static_cast(aResult)) && - ReadParam(aMsg, aIter, &aResult->mDeltaType) && - ReadParam(aMsg, aIter, &aResult->mScrollMode) && - ReadParam(aMsg, aIter, &aResult->mOrigin) && - ReadParam(aMsg, aIter, &aResult->mHandledByAPZ) && - ReadParam(aMsg, aIter, &aResult->mDeltaX) && - ReadParam(aMsg, aIter, &aResult->mDeltaY) && - ReadParam(aMsg, aIter, &aResult->mWheelTicksX) && - ReadParam(aMsg, aIter, &aResult->mWheelTicksY) && - ReadParam(aMsg, aIter, &aResult->mLocalOrigin) && - ReadParam(aMsg, aIter, &aResult->mLineOrPageDeltaX) && - ReadParam(aMsg, aIter, &aResult->mLineOrPageDeltaY) && - ReadParam(aMsg, aIter, &aResult->mScrollSeriesNumber) && - ReadParam(aMsg, aIter, &aResult->mUserDeltaMultiplierX) && - ReadParam(aMsg, aIter, &aResult->mUserDeltaMultiplierY) && - ReadParam(aMsg, aIter, &aResult->mMayHaveMomentum) && - ReadParam(aMsg, aIter, &aResult->mIsMomentum) && - ReadParam(aMsg, aIter, - &aResult->mAllowToOverrideSystemScrollSpeed) && - ReadParam(aMsg, aIter, &aResult->mWheelDeltaAdjustmentStrategy) && - ReadParam(aMsg, aIter, &aResult->mAPZAction); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, static_cast(aResult)) && + ReadParam(aReader, &aResult->mDeltaType) && + ReadParam(aReader, &aResult->mScrollMode) && + ReadParam(aReader, &aResult->mOrigin) && + ReadParam(aReader, &aResult->mHandledByAPZ) && + ReadParam(aReader, &aResult->mDeltaX) && + ReadParam(aReader, &aResult->mDeltaY) && + ReadParam(aReader, &aResult->mWheelTicksX) && + ReadParam(aReader, &aResult->mWheelTicksY) && + ReadParam(aReader, &aResult->mLocalOrigin) && + ReadParam(aReader, &aResult->mLineOrPageDeltaX) && + ReadParam(aReader, &aResult->mLineOrPageDeltaY) && + ReadParam(aReader, &aResult->mScrollSeriesNumber) && + ReadParam(aReader, &aResult->mUserDeltaMultiplierX) && + ReadParam(aReader, &aResult->mUserDeltaMultiplierY) && + ReadParam(aReader, &aResult->mMayHaveMomentum) && + ReadParam(aReader, &aResult->mIsMomentum) && + ReadParam(aReader, &aResult->mAllowToOverrideSystemScrollSpeed) && + ReadParam(aReader, &aResult->mWheelDeltaAdjustmentStrategy) && + ReadParam(aReader, &aResult->mAPZAction); } }; @@ -1422,23 +1368,22 @@ template <> struct ParamTraits { typedef mozilla::KeyboardInput paramType; - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, static_cast(aParam)); - WriteParam(aMsg, aParam.mType); - WriteParam(aMsg, aParam.mKeyCode); - WriteParam(aMsg, aParam.mCharCode); - WriteParam(aMsg, aParam.mShortcutCandidates); - WriteParam(aMsg, aParam.mHandledByAPZ); + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, static_cast(aParam)); + WriteParam(aWriter, aParam.mType); + WriteParam(aWriter, aParam.mKeyCode); + WriteParam(aWriter, aParam.mCharCode); + WriteParam(aWriter, aParam.mShortcutCandidates); + WriteParam(aWriter, aParam.mHandledByAPZ); } - static bool Read(const Message* aMsg, PickleIterator* aIter, - paramType* aResult) { - return ReadParam(aMsg, aIter, static_cast(aResult)) && - ReadParam(aMsg, aIter, &aResult->mType) && - ReadParam(aMsg, aIter, &aResult->mKeyCode) && - ReadParam(aMsg, aIter, &aResult->mCharCode) && - ReadParam(aMsg, aIter, &aResult->mShortcutCandidates) && - ReadParam(aMsg, aIter, &aResult->mHandledByAPZ); + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, static_cast(aResult)) && + ReadParam(aReader, &aResult->mType) && + ReadParam(aReader, &aResult->mKeyCode) && + ReadParam(aReader, &aResult->mCharCode) && + ReadParam(aReader, &aResult->mShortcutCandidates) && + ReadParam(aReader, &aResult->mHandledByAPZ); } };