Bug 1874739 - Part 7: Make PRemoteWorkerController refcounted, r=dom-worker-reviewers,janv,asuth

This is part of removing [ManualDealloc] from all protocols which manage other
protocols.

Differential Revision: https://phabricator.services.mozilla.com/D198617
This commit is contained in:
Nika Layzell 2024-01-19 20:23:20 +00:00
parent 57935aab6e
commit b22ff39055
7 changed files with 4 additions and 47 deletions

View File

@ -1156,14 +1156,6 @@ nsresult ServiceWorkerPrivate::SpawnWorkerIfNeeded() {
return NS_ERROR_DOM_INVALID_STATE_ERR;
}
/**
* Manually `AddRef()` because `DeallocPRemoteWorkerControllerChild()`
* calls `Release()` and the `AllocPRemoteWorkerControllerChild()` function
* is not called.
*/
// NOLINTNEXTLINE(readability-redundant-smartptr-get)
controllerChild.get()->AddRef();
mControllerChild = new RAIIActorPtrHolder(controllerChild.forget());
// Update Running count here because we may Terminate before we get

View File

@ -17,7 +17,6 @@ namespace dom {
* canonically controlled from the PBackground thread. Exclusively for use from
* the parent process main thread to the parent process PBackground thread.
*/
[ManualDealloc]
protocol PRemoteWorkerController {
manager PBackground;

View File

@ -23,7 +23,7 @@ class RemoteWorkerControllerChild final : public PRemoteWorkerControllerChild {
friend class PRemoteWorkerControllerChild;
public:
NS_INLINE_DECL_REFCOUNTING(RemoteWorkerControllerChild)
NS_INLINE_DECL_REFCOUNTING(RemoteWorkerControllerChild, override)
explicit RemoteWorkerControllerChild(RefPtr<RemoteWorkerObserver> aObserver);

View File

@ -265,23 +265,6 @@ IPCResult BackgroundChildImpl::RecvPRemoteWorkerConstructor(
return IPC_OK();
}
dom::PRemoteWorkerControllerChild*
BackgroundChildImpl::AllocPRemoteWorkerControllerChild(
const dom::RemoteWorkerData& aRemoteWorkerData) {
MOZ_CRASH(
"PRemoteWorkerControllerChild actors must be manually constructed!");
return nullptr;
}
bool BackgroundChildImpl::DeallocPRemoteWorkerControllerChild(
dom::PRemoteWorkerControllerChild* aActor) {
MOZ_ASSERT(aActor);
RefPtr<dom::RemoteWorkerControllerChild> actor =
dont_AddRef(static_cast<dom::RemoteWorkerControllerChild*>(aActor));
return true;
}
dom::PSharedWorkerChild* BackgroundChildImpl::AllocPSharedWorkerChild(
const dom::RemoteWorkerData& aData, const uint64_t& aWindowID,
const dom::MessagePortIdentifier& aPortIdentifier) {

View File

@ -108,13 +108,6 @@ class BackgroundChildImpl : public PBackgroundChild {
virtual mozilla::ipc::IPCResult RecvPRemoteWorkerConstructor(
PRemoteWorkerChild* aActor, const RemoteWorkerData& aData) override;
virtual mozilla::dom::PRemoteWorkerControllerChild*
AllocPRemoteWorkerControllerChild(
const mozilla::dom::RemoteWorkerData& aRemoteWorkerData) override;
virtual bool DeallocPRemoteWorkerControllerChild(
mozilla::dom::PRemoteWorkerControllerChild* aActor) override;
virtual mozilla::dom::PSharedWorkerChild* AllocPSharedWorkerChild(
const mozilla::dom::RemoteWorkerData& aData, const uint64_t& aWindowID,
const mozilla::dom::MessagePortIdentifier& aPortIdentifier) override;

View File

@ -509,12 +509,12 @@ BackgroundParentImpl::AllocPIdleSchedulerParent() {
return actor.forget();
}
dom::PRemoteWorkerControllerParent*
already_AddRefed<dom::PRemoteWorkerControllerParent>
BackgroundParentImpl::AllocPRemoteWorkerControllerParent(
const dom::RemoteWorkerData& aRemoteWorkerData) {
RefPtr<dom::RemoteWorkerControllerParent> actor =
new dom::RemoteWorkerControllerParent(aRemoteWorkerData);
return actor.forget().take();
return actor.forget();
}
IPCResult BackgroundParentImpl::RecvPRemoteWorkerControllerConstructor(
@ -525,13 +525,6 @@ IPCResult BackgroundParentImpl::RecvPRemoteWorkerControllerConstructor(
return IPC_OK();
}
bool BackgroundParentImpl::DeallocPRemoteWorkerControllerParent(
dom::PRemoteWorkerControllerParent* aActor) {
RefPtr<dom::RemoteWorkerControllerParent> actor =
dont_AddRef(static_cast<dom::RemoteWorkerControllerParent*>(aActor));
return true;
}
already_AddRefed<dom::PRemoteWorkerServiceParent>
BackgroundParentImpl::AllocPRemoteWorkerServiceParent() {
return MakeAndAddRef<dom::RemoteWorkerServiceParent>();

View File

@ -160,7 +160,7 @@ class BackgroundParentImpl : public PBackgroundParent {
bool DeallocPFileCreatorParent(PFileCreatorParent* aActor) override;
mozilla::dom::PRemoteWorkerControllerParent*
already_AddRefed<mozilla::dom::PRemoteWorkerControllerParent>
AllocPRemoteWorkerControllerParent(
const mozilla::dom::RemoteWorkerData& aRemoteWorkerData) override;
@ -168,9 +168,6 @@ class BackgroundParentImpl : public PBackgroundParent {
mozilla::dom::PRemoteWorkerControllerParent* aActor,
const mozilla::dom::RemoteWorkerData& aRemoteWorkerData) override;
bool DeallocPRemoteWorkerControllerParent(
mozilla::dom::PRemoteWorkerControllerParent* aActor) override;
already_AddRefed<PRemoteWorkerServiceParent> AllocPRemoteWorkerServiceParent()
override;