Skip to content

Commit

Permalink
Bug 1814683 - Part 1: Combine parent/child fields in IPDL structs/uni…
Browse files Browse the repository at this point in the history
…ons, r=ipc-reviewers,necko-reviewers,mccr8

This combines the multiple fields or variants which were previously used to
track sided types like protocol types into a single field wrapped with a
SideVariant.

This will be used in the next part to avoid the need for default constructors
for actor types allowing the proper types to be used.

Differential Revision: https://phabricator.services.mozilla.com/D168879
  • Loading branch information
mystor committed Mar 14, 2023
1 parent 53bc7ab commit 843507c
Show file tree
Hide file tree
Showing 30 changed files with 247 additions and 255 deletions.
25 changes: 13 additions & 12 deletions accessible/android/DocAccessibleWrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ void DocAccessibleWrap::CacheViewportCallback(nsITimer* aTimer,
accessible->Description(description);

cacheData.AppendElement(BatchData(
accessible->Document()->IPCDoc(), UNIQUE_ID(accessible),
accessible->State(), accessible->Bounds(), accessible->ActionCount(),
name, textValue, nodeID, description, UnspecifiedNaN<double>(),
OriginDocument(accessible->Document()->IPCDoc()),
UNIQUE_ID(accessible), accessible->State(), accessible->Bounds(),
accessible->ActionCount(), name, textValue, nodeID, description,
UnspecifiedNaN<double>(), UnspecifiedNaN<double>(),
UnspecifiedNaN<double>(), nullptr));
UnspecifiedNaN<double>(), UnspecifiedNaN<double>(), nullptr));
}

ipcDoc->SendBatch(eBatch_Viewport, cacheData);
Expand Down Expand Up @@ -257,10 +257,10 @@ void DocAccessibleWrap::CacheFocusPath(AccessibleWrap* aAccessible) {
acc->Description(description);
RefPtr<AccAttributes> attributes = acc->Attributes();
cacheData.AppendElement(
BatchData(acc->Document()->IPCDoc(), UNIQUE_ID(acc), acc->State(),
acc->Bounds(), acc->ActionCount(), name, textValue, nodeID,
description, acc->CurValue(), acc->MinValue(),
acc->MaxValue(), acc->Step(), attributes));
BatchData(OriginDocument(acc->Document()->IPCDoc()), UNIQUE_ID(acc),
acc->State(), acc->Bounds(), acc->ActionCount(), name,
textValue, nodeID, description, acc->CurValue(),
acc->MinValue(), acc->MaxValue(), acc->Step(), attributes));
mFocusPath.InsertOrUpdate(acc->UniqueID(), RefPtr{acc});
}

Expand Down Expand Up @@ -298,10 +298,11 @@ void DocAccessibleWrap::UpdateFocusPathBounds() {
}

boundsData.AppendElement(BatchData(
accessible->Document()->IPCDoc(), UNIQUE_ID(accessible), 0,
accessible->Bounds(), 0, nsString(), nsString(), nsString(),
nsString(), UnspecifiedNaN<double>(), UnspecifiedNaN<double>(),
UnspecifiedNaN<double>(), UnspecifiedNaN<double>(), nullptr));
OriginDocument(accessible->Document()->IPCDoc()),
UNIQUE_ID(accessible), 0, accessible->Bounds(), 0, nsString(),
nsString(), nsString(), nsString(), UnspecifiedNaN<double>(),
UnspecifiedNaN<double>(), UnspecifiedNaN<double>(),
UnspecifiedNaN<double>(), nullptr));
}

ipcDoc->SendBatch(eBatch_BoundsUpdate, boundsData);
Expand Down
2 changes: 1 addition & 1 deletion accessible/ipc/DocAccessibleParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,7 @@ mozilla::ipc::IPCResult DocAccessibleParent::RecvBatch(
nsTArray<RemoteAccessible*> proxies(aData.Length());
for (size_t i = 0; i < aData.Length(); i++) {
DocAccessibleParent* doc = static_cast<DocAccessibleParent*>(
aData.ElementAt(i).Document().get_PDocAccessibleParent());
aData.ElementAt(i).Document().get_PDocAccessible().AsParent());
MOZ_ASSERT(doc);

if (doc->IsShutdown()) {
Expand Down
2 changes: 1 addition & 1 deletion docshell/base/CanonicalBrowsingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ RefPtr<PrintPromise> CanonicalBrowsingContext::Print(

layout::RemotePrintJobParent* remotePrintJob =
new layout::RemotePrintJobParent(printSettings);
printData.remotePrintJobParent() =
printData.remotePrintJob() =
browserParent->Manager()->SendPRemotePrintJobConstructor(remotePrintJob);

if (listener) {
Expand Down
13 changes: 6 additions & 7 deletions dom/cache/AutoUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,12 @@ AutoParentOpResult::~AutoParentOpResult() {
switch (mOpResult.type()) {
case CacheOpResult::TStorageOpenResult: {
StorageOpenResult& result = mOpResult.get_StorageOpenResult();
if (action == Forget || result.actorParent() == nullptr) {
if (action == Forget || !result.actor()) {
break;
}

QM_WARNONLY_TRY(OkIf(PCacheParent::Send__delete__(result.actorParent())));
QM_WARNONLY_TRY(
OkIf(PCacheParent::Send__delete__(result.actor().AsParent())));
break;
}
default:
Expand All @@ -350,11 +351,9 @@ AutoParentOpResult::~AutoParentOpResult() {
void AutoParentOpResult::Add(CacheId aOpenedCacheId,
SafeRefPtr<Manager> aManager) {
MOZ_DIAGNOSTIC_ASSERT(mOpResult.type() == CacheOpResult::TStorageOpenResult);
MOZ_DIAGNOSTIC_ASSERT(mOpResult.get_StorageOpenResult().actorParent() ==
nullptr);
mOpResult.get_StorageOpenResult().actorParent() =
mManager->SendPCacheConstructor(
new CacheParent(std::move(aManager), aOpenedCacheId));
MOZ_DIAGNOSTIC_ASSERT(!mOpResult.get_StorageOpenResult().actor());
mOpResult.get_StorageOpenResult().actor() = mManager->SendPCacheConstructor(
new CacheParent(std::move(aManager), aOpenedCacheId));
}

void AutoParentOpResult::Add(const SavedResponse& aSavedResponse,
Expand Down
4 changes: 2 additions & 2 deletions dom/cache/CacheOpChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void AddWorkerRefToStreamChild(const CacheReadStream& aReadStream,
const SafeRefPtr<CacheWorkerRef>& aWorkerRef) {
MOZ_ASSERT_IF(!NS_IsMainThread(), aWorkerRef);
CacheStreamControlChild* cacheControl =
static_cast<CacheStreamControlChild*>(aReadStream.controlChild());
static_cast<CacheStreamControlChild*>(aReadStream.control().AsChild());
if (cacheControl) {
cacheControl->SetWorkerRef(aWorkerRef.clonePtr());
}
Expand Down Expand Up @@ -139,7 +139,7 @@ mozilla::ipc::IPCResult CacheOpChild::Recv__delete__(
}
case CacheOpResult::TStorageOpenResult: {
auto result = aResult.get_StorageOpenResult();
auto actor = static_cast<CacheChild*>(result.actorChild());
auto actor = static_cast<CacheChild*>(result.actor().AsChild());

// If we have a success status then we should have an actor. Gracefully
// reject instead of crashing, though, if we get a nullptr here.
Expand Down
3 changes: 1 addition & 2 deletions dom/cache/CacheStreamControlChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ void CacheStreamControlChild::SerializeControl(
CacheReadStream* aReadStreamOut) {
NS_ASSERT_OWNINGTHREAD(CacheStreamControlChild);
MOZ_DIAGNOSTIC_ASSERT(aReadStreamOut);
aReadStreamOut->controlParent() = nullptr;
aReadStreamOut->controlChild() = this;
aReadStreamOut->control() = this;
}

void CacheStreamControlChild::SerializeStream(CacheReadStream* aReadStreamOut,
Expand Down
3 changes: 1 addition & 2 deletions dom/cache/CacheStreamControlParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ void CacheStreamControlParent::SerializeControl(
CacheReadStream* aReadStreamOut) {
NS_ASSERT_OWNINGTHREAD(CacheStreamControlParent);
MOZ_DIAGNOSTIC_ASSERT(aReadStreamOut);
aReadStreamOut->controlChild() = nullptr;
aReadStreamOut->controlParent() = this;
aReadStreamOut->control() = this;
}

void CacheStreamControlParent::SerializeStream(CacheReadStream* aReadStreamOut,
Expand Down
6 changes: 3 additions & 3 deletions dom/cache/Manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1379,9 +1379,9 @@ class Manager::StorageOpenAction final : public Manager::BaseAction {

virtual void Complete(Listener* aListener, ErrorResult&& aRv) override {
MOZ_DIAGNOSTIC_ASSERT(aRv.Failed() || mCacheId != INVALID_CACHE_ID);
aListener->OnOpComplete(std::move(aRv),
StorageOpenResult(nullptr, nullptr, mNamespace),
mCacheId);
aListener->OnOpComplete(
std::move(aRv), StorageOpenResult((PCacheParent*)nullptr, mNamespace),
mCacheId);
}

private:
Expand Down
10 changes: 5 additions & 5 deletions dom/cache/ReadStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ already_AddRefed<ReadStream> ReadStream::Create(
// The parameter may or may not be for a Cache created stream. The way we
// tell is by looking at the stream control actor. If the actor exists,
// then we know the Cache created it.
if (!aReadStream.controlChild() && !aReadStream.controlParent()) {
if (!aReadStream.control()) {
return nullptr;
}

Expand All @@ -518,13 +518,13 @@ already_AddRefed<ReadStream> ReadStream::Create(
// Control is guaranteed to survive this method as ActorDestroy() cannot
// run on this thread until we complete.
StreamControl* control;
if (aReadStream.controlChild()) {
if (aReadStream.control().IsChild()) {
auto actor =
static_cast<CacheStreamControlChild*>(aReadStream.controlChild());
static_cast<CacheStreamControlChild*>(aReadStream.control().AsChild());
control = actor;
} else {
auto actor =
static_cast<CacheStreamControlParent*>(aReadStream.controlParent());
auto actor = static_cast<CacheStreamControlParent*>(
aReadStream.control().AsParent());
control = actor;
}
MOZ_DIAGNOSTIC_ASSERT(control);
Expand Down
3 changes: 1 addition & 2 deletions dom/cache/TypeUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,7 @@ void TypeUtils::SerializeCacheStream(nsIInputStream* aStream,
aStreamOut->emplace(CacheReadStream());
CacheReadStream& cacheStream = aStreamOut->ref();

cacheStream.controlChild() = nullptr;
cacheStream.controlParent() = nullptr;
cacheStream.control() = nullptr;

MOZ_ALWAYS_TRUE(mozilla::ipc::SerializeIPCStream(do_AddRef(aStream),
cacheStream.stream(),
Expand Down
2 changes: 1 addition & 1 deletion dom/clients/manager/ClientManagerService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ RefPtr<ClientOpPromise> ClientManagerService::Navigate(
// itself. Instead it sends a Teardown message to the parent which then
// calls delete. That means we can be sure that we are not racing with
// source destruction here.
args.targetParent() = source;
args.target() = source;

RefPtr<ClientOpPromise::Private> promise =
new ClientOpPromise::Private(__func__);
Expand Down
2 changes: 1 addition & 1 deletion dom/clients/manager/ClientNavigateOpChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ RefPtr<ClientOpPromise> ClientNavigateOpChild::DoNavigate(
// access the ClientSource again.
{
ClientSourceChild* targetActor =
static_cast<ClientSourceChild*>(aArgs.targetChild());
static_cast<ClientSourceChild*>(aArgs.target().AsChild());
MOZ_DIAGNOSTIC_ASSERT(targetActor);

ClientSource* target = targetActor->GetSource();
Expand Down
2 changes: 1 addition & 1 deletion dom/fs/child/FileSystemRequestHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ void ResolveCallback(FileSystemGetWritableFileStreamResponse&& aResponse,
auto& properties = aResponse.get_FileSystemWritableFileStreamProperties();

auto* const actor = static_cast<FileSystemWritableFileStreamChild*>(
properties.writableFileStreamChild());
properties.writableFileStream().AsChild());

mozilla::ipc::RandomAccessStreamParams params =
std::move(properties.streamParams());
Expand Down
4 changes: 2 additions & 2 deletions dom/fs/parent/FileSystemManagerParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ mozilla::ipc::IPCResult FileSystemManagerParent::RecvGetWritable(
return IPC_OK();
}

aResolver(FileSystemWritableFileStreamProperties(
std::move(streamParams), writableFileStreamParent, nullptr));
aResolver(FileSystemWritableFileStreamProperties(std::move(streamParams),
writableFileStreamParent));

return IPC_OK();
}
Expand Down
3 changes: 2 additions & 1 deletion dom/indexedDB/ActorsChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ void BackgroundFactoryRequestChild::HandleResponse(
mRequest->Reset();

auto* databaseActor =
static_cast<BackgroundDatabaseChild*>(aResponse.databaseChild());
static_cast<BackgroundDatabaseChild*>(aResponse.database().AsChild());
MOZ_ASSERT(databaseActor);

IDBDatabase* const database = [this, databaseActor]() -> IDBDatabase* {
Expand Down Expand Up @@ -1326,6 +1326,7 @@ BackgroundDatabaseChild::RecvCloseAfterInvalidationComplete() {
}

/*******************************************************************************
structs/unions, r=#ipc-reviewers!)
* BackgroundTransactionBase
******************************************************************************/

Expand Down
7 changes: 3 additions & 4 deletions dom/indexedDB/ActorsParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10268,7 +10268,7 @@ bool TransactionBase::VerifyRequestParams(
}

for (const FileAddInfo& fileAddInfo : aParams.fileAddInfos()) {
const PBackgroundIDBDatabaseFileParent* file = fileAddInfo.fileParent();
const PBackgroundIDBDatabaseFileParent* file = fileAddInfo.file().AsParent();

switch (fileAddInfo.type()) {
case StructuredCloneFileBase::eBlob:
Expand Down Expand Up @@ -15848,8 +15848,7 @@ void OpenDatabaseOp::SendResults() {

// XXX OpenDatabaseRequestResponse stores a raw pointer, can this be
// avoided?
response =
OpenDatabaseRequestResponse{mDatabase.unsafeGetRawPtr(), nullptr};
response = OpenDatabaseRequestResponse{mDatabase.unsafeGetRawPtr()};
} else {
response = ClampResultCode(rv);
#ifdef DEBUG
Expand Down Expand Up @@ -18441,7 +18440,7 @@ bool ObjectStoreAddOrPutRequestOp::Init(TransactionBase& aTransaction) {
switch (fileAddInfo.type()) {
case StructuredCloneFileBase::eBlob: {
PBackgroundIDBDatabaseFileParent* file =
fileAddInfo.fileParent();
fileAddInfo.file().AsParent();
MOZ_ASSERT(file);

auto* const fileActor = static_cast<DatabaseFile*>(file);
Expand Down
10 changes: 2 additions & 8 deletions dom/indexedDB/IDBObjectStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,10 +767,7 @@ RefPtr<IDBRequest> IDBObjectStore::AddOrPut(JSContext* aCx,
return Err(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
}

FileAddInfo info{};
info.fileChild() = fileActor;
info.type() = StructuredCloneFileBase::eBlob;
return info;
return FileAddInfo{fileActor, StructuredCloneFileBase::eBlob};
}

case StructuredCloneFileBase::eWasmBytecode:
Expand All @@ -784,10 +781,7 @@ RefPtr<IDBRequest> IDBObjectStore::AddOrPut(JSContext* aCx,
return Err(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
}

FileAddInfo info{};
info.fileChild() = fileActor;
info.type() = file.Type();
return info;
return FileAddInfo{fileActor, file.Type()};
}

default:
Expand Down
7 changes: 4 additions & 3 deletions dom/ipc/BrowserChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,8 @@ nsresult BrowserChild::UpdateRemotePrintSettings(
// everything.
([&]() MOZ_CAN_RUN_SCRIPT_BOUNDARY {
RefPtr<RemotePrintJobChild> printJob =
static_cast<RemotePrintJobChild*>(aPrintData.remotePrintJobChild());
static_cast<RemotePrintJobChild*>(
aPrintData.remotePrintJob().AsChild());
cv->SetPrintSettingsForSubdocument(printSettings, printJob);
}());
} else if (RefPtr<BrowserBridgeChild> remoteChild =
Expand Down Expand Up @@ -2411,8 +2412,8 @@ mozilla::ipc::IPCResult BrowserChild::RecvPrint(
printSettingsSvc->DeserializeToPrintSettings(aPrintData, printSettings);
{
IgnoredErrorResult rv;
RefPtr printJob =
static_cast<RemotePrintJobChild*>(aPrintData.remotePrintJobChild());
RefPtr printJob = static_cast<RemotePrintJobChild*>(
aPrintData.remotePrintJob().AsChild());
outerWindow->Print(printSettings, printJob,
/* aListener = */ nullptr,
/* aWindowToCloneInto = */ nullptr,
Expand Down
2 changes: 1 addition & 1 deletion dom/ipc/ContentChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ nsresult ContentChild::ProvideWindowCommon(

// Tell the parent process to set up its PBrowserParent.
PopupIPCTabContext ipcContext;
ipcContext.openerChild() = aTabOpener;
ipcContext.opener() = aTabOpener;
if (NS_WARN_IF(!SendConstructPopupBrowser(
std::move(parentEp), std::move(windowParentEp), tabId, ipcContext,
windowInit, aChromeFlags))) {
Expand Down
4 changes: 2 additions & 2 deletions dom/ipc/ContentParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4219,7 +4219,7 @@ bool ContentParent::CanOpenBrowser(const IPCTabContext& aContext) {
if (aContext.type() == IPCTabContext::TPopupIPCTabContext) {
const PopupIPCTabContext& popupContext = aContext.get_PopupIPCTabContext();

auto opener = BrowserParent::GetFrom(popupContext.openerParent());
auto opener = BrowserParent::GetFrom(popupContext.opener().AsParent());
if (!opener) {
MOZ_CRASH_UNLESS_FUZZING(
"Got null opener from child; aborting AllocPBrowserParent.");
Expand Down Expand Up @@ -4372,7 +4372,7 @@ mozilla::ipc::IPCResult ContentParent::RecvConstructPopupBrowser(
// type PopupIPCTabContext, and that the opener BrowserParent is
// reachable.
const PopupIPCTabContext& popupContext = aContext.get_PopupIPCTabContext();
auto opener = BrowserParent::GetFrom(popupContext.openerParent());
auto opener = BrowserParent::GetFrom(popupContext.opener().AsParent());
openerTabId = opener->GetTabId();
openerCpId = opener->Manager()->ChildID();

Expand Down
12 changes: 7 additions & 5 deletions gfx/layers/ipc/CompositableTransactionParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ bool CompositableParentManager::ReceiveCompositableUpdate(
case CompositableOperationDetail::TOpRemoveTexture: {
const OpRemoveTexture& op = aDetail.get_OpRemoveTexture();

RefPtr<TextureHost> tex = TextureHost::AsTextureHost(op.textureParent());
RefPtr<TextureHost> tex =
TextureHost::AsTextureHost(op.texture().AsParent());

MOZ_ASSERT(tex.get());
aCompositable->RemoveTextureHost(tex);
Expand All @@ -55,7 +56,8 @@ bool CompositableParentManager::ReceiveCompositableUpdate(
AutoTArray<CompositableHost::TimedTexture, 4> textures;
for (auto& timedTexture : op.textures()) {
CompositableHost::TimedTexture* t = textures.AppendElement();
t->mTexture = TextureHost::AsTextureHost(timedTexture.textureParent());
t->mTexture =
TextureHost::AsTextureHost(timedTexture.texture().AsParent());
MOZ_ASSERT(t->mTexture);
t->mTimeStamp = timedTexture.timeStamp();
t->mPictureRect = timedTexture.picture();
Expand All @@ -70,7 +72,7 @@ bool CompositableParentManager::ReceiveCompositableUpdate(

for (auto& timedTexture : op.textures()) {
RefPtr<TextureHost> texture =
TextureHost::AsTextureHost(timedTexture.textureParent());
TextureHost::AsTextureHost(timedTexture.texture().AsParent());
if (texture) {
texture->SetLastFwdTransactionId(mFwdTransactionId);
// Make sure that each texture was handled by the compositable
Expand Down Expand Up @@ -108,8 +110,8 @@ bool CompositableParentManager::ReceiveCompositableUpdate(

void CompositableParentManager::DestroyActor(const OpDestroy& aOp) {
switch (aOp.type()) {
case OpDestroy::TPTextureParent: {
auto actor = aOp.get_PTextureParent();
case OpDestroy::TPTexture: {
auto actor = aOp.get_PTexture().AsParent();
TextureHost::ReceivedDestroy(actor);
break;
}
Expand Down
Loading

0 comments on commit 843507c

Please sign in to comment.