Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 55cad8d

Browse files
committed
Bug 1847298: IPC constructor cleanup r=nika,padenot,dom-storage-reviewers,necko-reviewers,cookie-reviewers,asuth,Jamie
Differential Revision: https://phabricator.services.mozilla.com/D185472
1 parent 2523752 commit 55cad8d

26 files changed

+90
-77
lines changed

accessible/generic/DocAccessible.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,17 +1601,12 @@ void DocAccessible::DoInitialUpdate() {
16011601
// RootAccessibles.
16021602
MOZ_ASSERT(IsRoot());
16031603
DocAccessibleChild* ipcDoc = IPCDoc();
1604-
if (ipcDoc) {
1605-
browserChild->SetTopLevelDocAccessibleChild(ipcDoc);
1606-
} else {
1604+
if (!ipcDoc) {
16071605
ipcDoc = new DocAccessibleChild(this, browserChild);
1606+
MOZ_RELEASE_ASSERT(browserChild->SendPDocAccessibleConstructor(
1607+
ipcDoc, nullptr, 0, mDocumentNode->GetBrowsingContext()));
1608+
// trying to recover from this failing is problematic
16081609
SetIPCDoc(ipcDoc);
1609-
// Subsequent initialization might depend on being able to get the
1610-
// top level DocAccessibleChild, so set that as early as possible.
1611-
browserChild->SetTopLevelDocAccessibleChild(ipcDoc);
1612-
1613-
browserChild->SendPDocAccessibleConstructor(
1614-
ipcDoc, nullptr, 0, mDocumentNode->GetBrowsingContext());
16151610
}
16161611
}
16171612
}

accessible/generic/DocAccessible.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,7 @@ class DocAccessible : public HyperTextAccessible,
782782
PresShell* mPresShell;
783783

784784
// Exclusively owned by IPDL so don't manually delete it!
785+
// Cleared in ActorDestroy
785786
DocAccessibleChild* mIPCDoc;
786787

787788
// These data structures map between LocalAccessibles and CacheDomains,

dom/base/nsContentPermissionHelper.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,12 @@ nsresult nsContentPermissionUtils::AskPermission(
293293
NS_ENSURE_SUCCESS(rv, rv);
294294

295295
req->IPDLAddRef();
296-
ContentChild::GetSingleton()->SendPContentPermissionRequestConstructor(
297-
req, permArray, principal, topLevelPrincipal,
298-
hasValidTransientUserGestureActivation,
299-
isRequestDelegatedToUnsafeThirdParty, child->GetTabId());
296+
if (!ContentChild::GetSingleton()->SendPContentPermissionRequestConstructor(
297+
req, permArray, principal, topLevelPrincipal,
298+
hasValidTransientUserGestureActivation,
299+
isRequestDelegatedToUnsafeThirdParty, child->GetTabId())) {
300+
return NS_ERROR_FAILURE;
301+
}
300302
ContentPermissionRequestChildMap()[req.get()] = child->GetTabId();
301303

302304
req->Sendprompt();

dom/broadcastchannel/BroadcastChannel.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,13 @@ already_AddRefed<BroadcastChannel> BroadcastChannel::Constructor(
255255

256256
PBroadcastChannelChild* actor = actorChild->SendPBroadcastChannelConstructor(
257257
storagePrincipalInfo, origin, nsString(aChannel));
258+
if (!actor) {
259+
// The PBackground actor is shutting down, return a 'generic' error.
260+
aRv.Throw(NS_ERROR_FAILURE);
261+
return nullptr;
262+
}
258263

259264
bc->mActor = static_cast<BroadcastChannelChild*>(actor);
260-
MOZ_ASSERT(bc->mActor);
261-
262265
bc->mActor->SetParent(bc);
263266
bc->mOriginForEvents = std::move(originForEvents);
264267

dom/file/FileCreatorHelper.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ already_AddRefed<Promise> FileCreatorHelper::CreateFile(
5959
PFileCreatorChild* actor = actorChild->SendPFileCreatorConstructor(
6060
path, aBag.mType, aBag.mName, lastModified, aBag.mExistenceCheck,
6161
aIsFromNsIFile);
62+
if (!actor) {
63+
aRv.Throw(NS_ERROR_FAILURE);
64+
return nullptr;
65+
}
6266

6367
static_cast<FileCreatorChild*>(actor)->SetPromise(promise);
6468
return promise.forget();

dom/indexedDB/IDBDatabase.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -609,16 +609,20 @@ RefPtr<IDBTransaction> IDBDatabase::Transaction(
609609
return nullptr;
610610
}
611611

612-
BackgroundTransactionChild* actor =
612+
RefPtr<BackgroundTransactionChild> actor =
613613
new BackgroundTransactionChild(transaction.clonePtr());
614614

615615
IDB_LOG_MARK_CHILD_TRANSACTION(
616616
"database(%s).transaction(%s)", "IDBDatabase.transaction(%.0s%.0s)",
617617
transaction->LoggingSerialNumber(), IDB_LOG_STRINGIFY(this),
618618
IDB_LOG_STRINGIFY(*transaction));
619619

620-
MOZ_ALWAYS_TRUE(mBackgroundActor->SendPBackgroundIDBTransactionConstructor(
621-
actor, sortedStoreNames, mode));
620+
if (!mBackgroundActor->SendPBackgroundIDBTransactionConstructor(
621+
actor, sortedStoreNames, mode)) {
622+
IDB_REPORT_INTERNAL_ERR();
623+
aRv.ThrowUnknownError("Failed to create IndexedDB transaction");
624+
return nullptr;
625+
}
622626

623627
transaction->SetBackgroundActor(actor);
624628

dom/ipc/BrowserChild.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,6 @@ BrowserChild::BrowserChild(ContentChild* aManager, const TabId& aTabId,
291291
mIsPreservingLayers(false),
292292
#if defined(XP_WIN) && defined(ACCESSIBILITY)
293293
mNativeWindowHandle(0),
294-
#endif
295-
#if defined(ACCESSIBILITY)
296-
mTopLevelDocAccessibleChild(nullptr),
297294
#endif
298295
mCancelContentJSEpoch(0) {
299296
mozilla::HoldJSObjects(this);

dom/ipc/BrowserChild.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -583,16 +583,6 @@ class BrowserChild final : public nsMessageManagerScriptExecutor,
583583

584584
BrowsingContext* GetBrowsingContext() const { return mBrowsingContext; }
585585

586-
#if defined(ACCESSIBILITY)
587-
void SetTopLevelDocAccessibleChild(PDocAccessibleChild* aTopLevelChild) {
588-
mTopLevelDocAccessibleChild = aTopLevelChild;
589-
}
590-
591-
PDocAccessibleChild* GetTopLevelDocAccessibleChild() {
592-
return mTopLevelDocAccessibleChild;
593-
}
594-
#endif
595-
596586
// The transform from the coordinate space of this BrowserChild to the
597587
// coordinate space of the native window its BrowserParent is in.
598588
mozilla::LayoutDeviceToLayoutDeviceMatrix4x4
@@ -839,9 +829,6 @@ class BrowserChild final : public nsMessageManagerScriptExecutor,
839829
uintptr_t mNativeWindowHandle;
840830
#endif // defined(XP_WIN)
841831

842-
#if defined(ACCESSIBILITY)
843-
PDocAccessibleChild* mTopLevelDocAccessibleChild;
844-
#endif
845832
int32_t mCancelContentJSEpoch;
846833

847834
Maybe<LayoutDeviceToLayoutDeviceMatrix4x4> mChildToParentConversionMatrix;

dom/media/ipc/MFCDMChild.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ RefPtr<MFCDMChild::RemotePromise> MFCDMChild::EnsureRemote() {
103103
}
104104

105105
mIPDLSelfRef = this;
106-
Unused << manager->SendPMFCDMConstructor(this, mKeySystem);
106+
MOZ_ALWAYS_TRUE(manager->SendPMFCDMConstructor(this, mKeySystem));
107107
mState = NS_OK;
108108
mRemotePromiseHolder.ResolveIfExists(true, __func__);
109109
},

dom/media/ipc/RemoteAudioDecoder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ MediaResult RemoteAudioDecoderChild::InitIPDL(
5656
}
5757

5858
mIPDLSelfRef = this;
59-
Unused << manager->SendPRemoteDecoderConstructor(
60-
this, aAudioInfo, aOptions, Nothing(), aMediaEngineId, Nothing());
59+
MOZ_ALWAYS_TRUE(manager->SendPRemoteDecoderConstructor(
60+
this, aAudioInfo, aOptions, Nothing(), aMediaEngineId, Nothing()));
6161
return NS_OK;
6262
}
6363

0 commit comments

Comments
 (0)