Bug 1874739 - Part 10: Make PTestShell refcounted, r=ipc-reviewers,mccr8

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

Differential Revision: https://phabricator.services.mozilla.com/D198620
This commit is contained in:
Nika Layzell 2024-01-19 20:23:21 +00:00
Родитель d780b66353
Коммит 0dad4f65ae
7 изменённых файлов: 17 добавлений и 25 удалений

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

@ -1914,13 +1914,8 @@ bool ContentChild::DeallocPHeapSnapshotTempFileHelperChild(
return true;
}
PTestShellChild* ContentChild::AllocPTestShellChild() {
return new TestShellChild();
}
bool ContentChild::DeallocPTestShellChild(PTestShellChild* shell) {
delete shell;
return true;
already_AddRefed<PTestShellChild> ContentChild::AllocPTestShellChild() {
return MakeAndAddRef<TestShellChild>();
}
mozilla::ipc::IPCResult ContentChild::RecvPTestShellConstructor(

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

@ -213,9 +213,7 @@ class ContentChild final : public PContentChild,
bool DeallocPWebBrowserPersistDocumentChild(
PWebBrowserPersistDocumentChild* aActor);
PTestShellChild* AllocPTestShellChild();
bool DeallocPTestShellChild(PTestShellChild*);
already_AddRefed<PTestShellChild> AllocPTestShellChild();
virtual mozilla::ipc::IPCResult RecvPTestShellConstructor(
PTestShellChild*) override;

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

@ -2493,7 +2493,11 @@ void ContentParent::NotifyTabDestroyed(const TabId& aTabId,
}
TestShellParent* ContentParent::CreateTestShell() {
return static_cast<TestShellParent*>(SendPTestShellConstructor());
RefPtr<TestShellParent> actor = new TestShellParent();
if (!SendPTestShellConstructor(actor)) {
return nullptr;
}
return actor;
}
bool ContentParent::DestroyTestShell(TestShellParent* aTestShell) {
@ -4673,15 +4677,6 @@ bool ContentParent::CycleCollectWithLogs(
this, aDumpAllTraces, aSink, aCallback);
}
PTestShellParent* ContentParent::AllocPTestShellParent() {
return new TestShellParent();
}
bool ContentParent::DeallocPTestShellParent(PTestShellParent* shell) {
delete shell;
return true;
}
PScriptCacheParent* ContentParent::AllocPScriptCacheParent(
const FileDescOrError& cacheFile, const bool& wantCacheData) {
return new loader::ScriptCacheParent(wantCacheData);

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

@ -923,10 +923,6 @@ class ContentParent final : public PContentParent,
bool DeallocPCycleCollectWithLogsParent(PCycleCollectWithLogsParent* aActor);
PTestShellParent* AllocPTestShellParent();
bool DeallocPTestShellParent(PTestShellParent* shell);
PScriptCacheParent* AllocPScriptCacheParent(const FileDescOrError& cacheFile,
const bool& wantCacheData);

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

@ -9,7 +9,6 @@ include protocol PTestShellCommand;
namespace mozilla {
namespace ipc {
[ManualDealloc]
async protocol PTestShell
{
manager PContent;

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

@ -18,6 +18,8 @@ class XPCShellEnvironment;
class TestShellChild : public PTestShellChild {
public:
NS_INLINE_DECL_REFCOUNTING(TestShellChild, override)
TestShellChild();
mozilla::ipc::IPCResult RecvExecuteCommand(const nsAString& aCommand);
@ -31,6 +33,8 @@ class TestShellChild : public PTestShellChild {
bool DeallocPTestShellCommandChild(PTestShellCommandChild* aCommand);
private:
~TestShellChild() = default;
UniquePtr<XPCShellEnvironment> mXPCShell;
};

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

@ -25,6 +25,8 @@ class TestShellParent : public PTestShellParent {
friend class PTestShellParent;
public:
NS_INLINE_DECL_REFCOUNTING(TestShellParent, override)
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
PTestShellCommandParent* AllocPTestShellCommandParent(
@ -33,6 +35,9 @@ class TestShellParent : public PTestShellParent {
bool DeallocPTestShellCommandParent(PTestShellCommandParent* aActor);
bool CommandDone(TestShellCommandParent* aActor, const nsAString& aResponse);
private:
~TestShellParent() = default;
};
class TestShellCommandParent : public PTestShellCommandParent {