Bug 1874739 - Part 3: Make PClientSource 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/D198613
This commit is contained in:
Nika Layzell 2024-01-19 20:23:18 +00:00
Родитель be638e433f
Коммит bbe8741d2d
9 изменённых файлов: 17 добавлений и 32 удалений

Просмотреть файл

@ -60,16 +60,6 @@ mozilla::ipc::IPCResult ClientManagerChild::RecvPClientNavigateOpConstructor(
return IPC_OK();
}
PClientSourceChild* ClientManagerChild::AllocPClientSourceChild(
const ClientSourceConstructorArgs& aArgs) {
return new ClientSourceChild(aArgs);
}
bool ClientManagerChild::DeallocPClientSourceChild(PClientSourceChild* aActor) {
delete aActor;
return true;
}
// static
already_AddRefed<ClientManagerChild> ClientManagerChild::Create() {
RefPtr<ClientManagerChild> actor = new ClientManagerChild();

Просмотреть файл

@ -40,11 +40,6 @@ class ClientManagerChild final : public PClientManagerChild {
PClientNavigateOpChild* aActor,
const ClientNavigateOpConstructorArgs& aArgs) override;
PClientSourceChild* AllocPClientSourceChild(
const ClientSourceConstructorArgs& aArgs) override;
bool DeallocPClientSourceChild(PClientSourceChild* aActor) override;
public:
NS_INLINE_DECL_REFCOUNTING(ClientManagerChild, override)

Просмотреть файл

@ -72,7 +72,8 @@ bool ClientManagerParent::DeallocPClientNavigateOpParent(
return true;
}
PClientSourceParent* ClientManagerParent::AllocPClientSourceParent(
already_AddRefed<PClientSourceParent>
ClientManagerParent::AllocPClientSourceParent(
const ClientSourceConstructorArgs& aArgs) {
Maybe<ContentParentId> contentParentId;
@ -81,13 +82,7 @@ PClientSourceParent* ClientManagerParent::AllocPClientSourceParent(
contentParentId = Some(ContentParentId(childID));
}
return new ClientSourceParent(aArgs, contentParentId);
}
bool ClientManagerParent::DeallocPClientSourceParent(
PClientSourceParent* aActor) {
delete aActor;
return true;
return MakeAndAddRef<ClientSourceParent>(aArgs, contentParentId);
}
IPCResult ClientManagerParent::RecvPClientSourceConstructor(

Просмотреть файл

@ -42,11 +42,9 @@ class ClientManagerParent final : public PClientManagerParent {
bool DeallocPClientNavigateOpParent(PClientNavigateOpParent* aActor) override;
PClientSourceParent* AllocPClientSourceParent(
already_AddRefed<PClientSourceParent> AllocPClientSourceParent(
const ClientSourceConstructorArgs& aArgs) override;
bool DeallocPClientSourceParent(PClientSourceParent* aActor) override;
mozilla::ipc::IPCResult RecvPClientSourceConstructor(
PClientSourceParent* aActor,
const ClientSourceConstructorArgs& aArgs) override;

Просмотреть файл

@ -281,7 +281,7 @@ bool ClientManagerService::AddSource(ClientSourceParent* aSource) {
return true;
}
if (!mSourceTable.WithEntryHandle(aSource->Info().Id(),
[aSource](auto&& entry) {
[&aSource](auto&& entry) {
if (NS_WARN_IF(entry.HasEntry())) {
return false;
}

Просмотреть файл

@ -189,13 +189,13 @@ void ClientSource::Activate(PClientManagerChild* aActor) {
ClientSourceConstructorArgs args(mClientInfo.Id(), mClientInfo.Type(),
mClientInfo.PrincipalInfo(),
mClientInfo.CreationTime());
PClientSourceChild* actor = aActor->SendPClientSourceConstructor(args);
if (!actor) {
RefPtr<ClientSourceChild> actor = new ClientSourceChild(args);
if (!aActor->SendPClientSourceConstructor(actor, args)) {
Shutdown();
return;
}
ActivateThing(static_cast<ClientSourceChild*>(actor));
ActivateThing(actor);
}
ClientSource::~ClientSource() { Shutdown(); }

Просмотреть файл

@ -19,6 +19,8 @@ class ClientSourceChild final : public PClientSourceChild {
ClientSource* mSource;
bool mTeardownStarted;
~ClientSourceChild() = default;
// PClientSourceChild interface
void ActorDestroy(ActorDestroyReason aReason) override;
@ -34,6 +36,8 @@ class ClientSourceChild final : public PClientSourceChild {
mozilla::ipc::IPCResult RecvEvictFromBFCache() override;
public:
NS_INLINE_DECL_REFCOUNTING(ClientSourceChild, override)
explicit ClientSourceChild(const ClientSourceConstructorArgs& aArgs);
void SetOwner(ClientThing<ClientSourceChild>* aThing);

Просмотреть файл

@ -30,6 +30,8 @@ class ClientSourceParent final : public PClientSourceParent {
void KillInvalidChild();
~ClientSourceParent();
// PClientSourceParent
mozilla::ipc::IPCResult RecvWorkerSyncPing() override;
@ -55,9 +57,10 @@ class ClientSourceParent final : public PClientSourceParent {
bool DeallocPClientSourceOpParent(PClientSourceOpParent* aActor) override;
public:
NS_INLINE_DECL_REFCOUNTING(ClientSourceParent, override)
explicit ClientSourceParent(const ClientSourceConstructorArgs& aArgs,
const Maybe<ContentParentId>& aContentParentId);
~ClientSourceParent();
void Init();

Просмотреть файл

@ -9,7 +9,7 @@ include ClientIPCTypes;
namespace mozilla {
namespace dom {
[ManualDealloc, ChildImpl=virtual, ParentImpl=virtual]
[ChildImpl=virtual, ParentImpl=virtual]
sync protocol PClientSource
{
manager PClientManager;