Skip to content

Commit

Permalink
Bug 1754037 - Part 3c: Automatically update all ParamTraits implement…
Browse files Browse the repository at this point in the history
…ations, r=ipc-reviewers,media-playback-reviewers,bryce,mccr8

Automatically generated rewrites of all ParamTraits and IPDLParamTraits
implementations in-tree to use IPC::Message{Reader,Writer}.

Differential Revision: https://phabricator.services.mozilla.com/D140004
  • Loading branch information
mystor committed Mar 4, 2022
1 parent 1d44e43 commit 05dc5e0
Show file tree
Hide file tree
Showing 128 changed files with 4,261 additions and 4,607 deletions.
55 changes: 25 additions & 30 deletions accessible/ipc/IPCTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,40 +49,37 @@ template <>
struct ParamTraits<mozilla::a11y::FontSize> {
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));
}
};

template <>
struct ParamTraits<mozilla::a11y::DeleteEntry> {
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));
}
};

template <>
struct ParamTraits<mozilla::a11y::AccGroupInfo> {
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;
}
Expand All @@ -92,41 +89,39 @@ template <>
struct ParamTraits<mozilla::a11y::Color> {
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));
}
};

template <>
struct ParamTraits<mozilla::a11y::AccAttributes*> {
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<nsAtom> 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<paramType>* aResult) {
static bool Read(MessageReader* aReader, RefPtr<paramType>* aResult) {
bool isNull = false;
if (!ReadParam(aMsg, aIter, &isNull)) {
if (!ReadParam(aReader, &isNull)) {
return false;
}

Expand All @@ -137,16 +132,16 @@ struct ParamTraits<mozilla::a11y::AccAttributes*> {

*aResult = mozilla::MakeRefPtr<mozilla::a11y::AccAttributes>();
uint32_t count;
if (!ReadParam(aMsg, aIter, &count)) {
if (!ReadParam(aReader, &count)) {
return false;
}
for (uint32_t i = 0; i < count; ++i) {
RefPtr<nsAtom> 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));
Expand Down
62 changes: 27 additions & 35 deletions chrome/RegistryMessageUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,13 @@ template <>
struct ParamTraits<SerializedURI> {
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;
}
Expand All @@ -78,25 +77,22 @@ template <>
struct ParamTraits<ChromePackage> {
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;
Expand All @@ -119,22 +115,20 @@ template <>
struct ParamTraits<SubstitutionMapping> {
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;
Expand All @@ -155,18 +149,16 @@ template <>
struct ParamTraits<OverrideMapping> {
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;
Expand Down
64 changes: 30 additions & 34 deletions docshell/base/BrowsingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3711,19 +3711,19 @@ void BrowsingContext::ResetLocationChangeRateLimit() {
namespace ipc {

void IPDLParamTraits<dom::MaybeDiscarded<dom::BrowsingContext>>::Write(
IPC::Message* aMsg, IProtocol* aActor,
IPC::MessageWriter* aWriter, IProtocol* aActor,
const dom::MaybeDiscarded<dom::BrowsingContext>& aParam) {
MOZ_DIAGNOSTIC_ASSERT(!aParam.GetMaybeDiscarded() ||
aParam.GetMaybeDiscarded()->EverAttached());
uint64_t id = aParam.ContextId();
WriteIPDLParam(aMsg, aActor, id);
WriteIPDLParam(aWriter, aActor, id);
}

bool IPDLParamTraits<dom::MaybeDiscarded<dom::BrowsingContext>>::Read(
const IPC::Message* aMsg, PickleIterator* aIter, IProtocol* aActor,
IPC::MessageReader* aReader, IProtocol* aActor,
dom::MaybeDiscarded<dom::BrowsingContext>* aResult) {
uint64_t id = 0;
if (!ReadIPDLParam(aMsg, aIter, aActor, &id)) {
if (!ReadIPDLParam(aReader, aActor, &id)) {
return false;
}

Expand All @@ -3738,43 +3738,39 @@ bool IPDLParamTraits<dom::MaybeDiscarded<dom::BrowsingContext>>::Read(
}

void IPDLParamTraits<dom::BrowsingContext::IPCInitializer>::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<dom::BrowsingContext::IPCInitializer>::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;
Expand Down
10 changes: 4 additions & 6 deletions docshell/base/BrowsingContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -1345,20 +1345,18 @@ extern template class syncedcontext::Transaction<BrowsingContext>;
namespace ipc {
template <>
struct IPDLParamTraits<dom::MaybeDiscarded<dom::BrowsingContext>> {
static void Write(IPC::Message* aMsg, IProtocol* aActor,
static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor,
const dom::MaybeDiscarded<dom::BrowsingContext>& aParam);
static bool Read(const IPC::Message* aMsg, PickleIterator* aIter,
IProtocol* aActor,
static bool Read(IPC::MessageReader* aReader, IProtocol* aActor,
dom::MaybeDiscarded<dom::BrowsingContext>* aResult);
};

template <>
struct IPDLParamTraits<dom::BrowsingContext::IPCInitializer> {
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
Expand Down
33 changes: 16 additions & 17 deletions docshell/base/SerializedLoadContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,29 +63,28 @@ template <>
struct ParamTraits<SerializedLoadContext> {
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);
Expand Down
Loading

0 comments on commit 05dc5e0

Please sign in to comment.