Bug 1754508 - P1: Make PNecko refcounted, r=necko-reviewers,dragana

This is the rebased version of D138486.
This patch is supposed to be landed on nightly and D138486 is for beta.

Differential Revision: https://phabricator.services.mozilla.com/D138755
This commit is contained in:
Kershaw Chang 2022-02-15 19:18:11 +00:00
Родитель 14a809c16b
Коммит eec2793ed4
8 изменённых файлов: 15 добавлений и 24 удалений

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

@ -115,7 +115,6 @@
#include "mozilla/net/CookieServiceChild.h"
#include "mozilla/net/DocumentChannelChild.h"
#include "mozilla/net/HttpChannelChild.h"
#include "mozilla/net/NeckoChild.h"
#include "mozilla/widget/RemoteLookAndFeel.h"
#include "mozilla/widget/ScreenManager.h"
#include "mozilla/widget/WidgetMessageUtils.h"
@ -1994,8 +1993,6 @@ mozilla::ipc::IPCResult ContentChild::RecvPScriptCacheConstructor(
return IPC_OK();
}
PNeckoChild* ContentChild::AllocPNeckoChild() { return new NeckoChild(); }
mozilla::ipc::IPCResult ContentChild::RecvNetworkLinkTypeChange(
const uint32_t& aType) {
mNetworkLinkType = aType;
@ -2007,11 +2004,6 @@ mozilla::ipc::IPCResult ContentChild::RecvNetworkLinkTypeChange(
return IPC_OK();
}
bool ContentChild::DeallocPNeckoChild(PNeckoChild* necko) {
delete necko;
return true;
}
PPrintingChild* ContentChild::AllocPPrintingChild() {
// The ContentParent should never attempt to allocate the nsPrintingProxy,
// which implements PPrintingChild. Instead, the nsPrintingProxy service is

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

@ -239,10 +239,6 @@ class ContentChild final : public PContentChild,
PScriptCacheChild*, const FileDescOrError& cacheFile,
const bool& wantCacheData) override;
PNeckoChild* AllocPNeckoChild();
bool DeallocPNeckoChild(PNeckoChild*);
PPrintingChild* AllocPPrintingChild();
bool DeallocPPrintingChild(PPrintingChild*);

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

@ -4206,11 +4206,9 @@ bool ContentParent::DeallocPScriptCacheParent(PScriptCacheParent* cache) {
return true;
}
PNeckoParent* ContentParent::AllocPNeckoParent() { return new NeckoParent(); }
bool ContentParent::DeallocPNeckoParent(PNeckoParent* necko) {
delete necko;
return true;
already_AddRefed<PNeckoParent> ContentParent::AllocPNeckoParent() {
RefPtr<NeckoParent> actor = new NeckoParent();
return actor.forget();
}
PPrintingParent* ContentParent::AllocPPrintingParent() {

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

@ -443,7 +443,7 @@ class ContentParent final
mozilla::ipc::IPCResult RecvInitCrashReporter(
const NativeThreadId& aThreadId);
PNeckoParent* AllocPNeckoParent();
already_AddRefed<PNeckoParent> AllocPNeckoParent();
virtual mozilla::ipc::IPCResult RecvPNeckoConstructor(
PNeckoParent* aActor) override {
@ -966,8 +966,6 @@ class ContentParent final
bool DeallocPScriptCacheParent(PScriptCacheParent* shell);
bool DeallocPNeckoParent(PNeckoParent* necko);
already_AddRefed<PExternalHelperAppParent> AllocPExternalHelperAppParent(
nsIURI* aUri, const Maybe<mozilla::net::LoadInfoArgs>& aLoadInfoArgs,
const nsCString& aMimeContentType, const nsCString& aContentDisposition,

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

@ -71,7 +71,8 @@ void NeckoChild::InitNeckoChild() {
if (NS_WARN_IF(cpc->IsShuttingDown())) {
return;
}
gNeckoChild = cpc->SendPNeckoConstructor();
RefPtr<NeckoChild> child = new NeckoChild();
gNeckoChild = cpc->SendPNeckoConstructor(child);
NS_ASSERTION(gNeckoChild, "PNecko Protocol init failed!");
}
}

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

@ -19,12 +19,15 @@ class NeckoChild : public PNeckoChild {
friend class PNeckoChild;
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(NeckoChild, override)
NeckoChild() = default;
virtual ~NeckoChild();
static void InitNeckoChild();
protected:
virtual ~NeckoChild();
PStunAddrsRequestChild* AllocPStunAddrsRequestChild();
bool DeallocPStunAddrsRequestChild(PStunAddrsRequestChild* aActor);

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

@ -30,8 +30,9 @@ class NeckoParent : public PNeckoParent {
friend class PNeckoParent;
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(NeckoParent, override)
NeckoParent();
virtual ~NeckoParent() = default;
[[nodiscard]] static const char* GetValidatedOriginAttributes(
const SerializedLoadContext& aSerialized, PContentParent* aBrowser,
@ -57,6 +58,8 @@ class NeckoParent : public PNeckoParent {
}
protected:
virtual ~NeckoParent() = default;
bool mSocketProcessBridgeInited;
already_AddRefed<PHttpChannelParent> AllocPHttpChannelParent(

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

@ -49,7 +49,7 @@ namespace mozilla {
namespace net {
//-------------------------------------------------------------------
[ManualDealloc, NestedUpTo=inside_cpow] sync protocol PNecko
[NestedUpTo=inside_cpow] sync protocol PNecko
{
manager PContent;
manages PHttpChannel;