зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1653470
- refcount PServiceWorkerContainer r=dom-workers-and-storage-reviewers,asuth
Depends on D83883 Differential Revision: https://phabricator.services.mozilla.com/D83884
This commit is contained in:
Родитель
bad3dff4d7
Коммит
260415ed7c
|
@ -10,7 +10,7 @@ include IPCServiceWorkerRegistrationDescriptor;
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
protocol PServiceWorkerContainer
|
||||
refcounted protocol PServiceWorkerContainer
|
||||
{
|
||||
manager PBackground;
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
#include "RemoteServiceWorkerContainerImpl.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "mozilla/ipc/BackgroundChild.h"
|
||||
#include "mozilla/ipc/PBackgroundChild.h"
|
||||
#include "ServiceWorkerContainerChild.h"
|
||||
|
@ -195,7 +197,7 @@ void RemoteServiceWorkerContainerImpl::GetReady(
|
|||
}
|
||||
|
||||
RemoteServiceWorkerContainerImpl::RemoteServiceWorkerContainerImpl()
|
||||
: mActor(nullptr), mOuter(nullptr), mShutdown(false) {
|
||||
: mOuter(nullptr), mShutdown(false) {
|
||||
PBackgroundChild* parentActor =
|
||||
BackgroundChild::GetOrCreateForCurrentThread();
|
||||
if (NS_WARN_IF(!parentActor)) {
|
||||
|
@ -203,7 +205,8 @@ RemoteServiceWorkerContainerImpl::RemoteServiceWorkerContainerImpl()
|
|||
return;
|
||||
}
|
||||
|
||||
ServiceWorkerContainerChild* actor = ServiceWorkerContainerChild::Create();
|
||||
RefPtr<ServiceWorkerContainerChild> actor =
|
||||
ServiceWorkerContainerChild::Create();
|
||||
if (NS_WARN_IF(!actor)) {
|
||||
Shutdown();
|
||||
return;
|
||||
|
@ -217,7 +220,7 @@ RemoteServiceWorkerContainerImpl::RemoteServiceWorkerContainerImpl()
|
|||
}
|
||||
MOZ_DIAGNOSTIC_ASSERT(sentActor == actor);
|
||||
|
||||
mActor = actor;
|
||||
mActor = std::move(actor);
|
||||
mActor->SetOwner(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ class ServiceWorkerContainerChild;
|
|||
|
||||
class RemoteServiceWorkerContainerImpl final
|
||||
: public ServiceWorkerContainer::Inner {
|
||||
ServiceWorkerContainerChild* mActor;
|
||||
RefPtr<ServiceWorkerContainerChild> mActor;
|
||||
ServiceWorkerContainer* mOuter;
|
||||
bool mShutdown;
|
||||
|
||||
|
|
|
@ -22,27 +22,6 @@ void InitServiceWorkerParent(PServiceWorkerParent* aActor,
|
|||
actor->Init(aDescriptor);
|
||||
}
|
||||
|
||||
PServiceWorkerContainerChild* AllocServiceWorkerContainerChild() {
|
||||
MOZ_CRASH("should not be called");
|
||||
}
|
||||
|
||||
bool DeallocServiceWorkerContainerChild(PServiceWorkerContainerChild* aActor) {
|
||||
auto actor = static_cast<ServiceWorkerContainerChild*>(aActor);
|
||||
delete actor;
|
||||
return true;
|
||||
}
|
||||
|
||||
PServiceWorkerContainerParent* AllocServiceWorkerContainerParent() {
|
||||
return new ServiceWorkerContainerParent();
|
||||
}
|
||||
|
||||
bool DeallocServiceWorkerContainerParent(
|
||||
PServiceWorkerContainerParent* aActor) {
|
||||
auto actor = static_cast<ServiceWorkerContainerParent*>(aActor);
|
||||
delete actor;
|
||||
return true;
|
||||
}
|
||||
|
||||
void InitServiceWorkerContainerParent(PServiceWorkerContainerParent* aActor) {
|
||||
auto actor = static_cast<ServiceWorkerContainerParent*>(aActor);
|
||||
actor->Init();
|
||||
|
|
|
@ -21,17 +21,8 @@ void InitServiceWorkerParent(PServiceWorkerParent* aActor,
|
|||
|
||||
// PServiceWorkerContainer
|
||||
|
||||
class PServiceWorkerContainerChild;
|
||||
class PServiceWorkerContainerParent;
|
||||
|
||||
PServiceWorkerContainerChild* AllocServiceWorkerContainerChild();
|
||||
|
||||
bool DeallocServiceWorkerContainerChild(PServiceWorkerContainerChild* aActor);
|
||||
|
||||
PServiceWorkerContainerParent* AllocServiceWorkerContainerParent();
|
||||
|
||||
bool DeallocServiceWorkerContainerParent(PServiceWorkerContainerParent* aActor);
|
||||
|
||||
void InitServiceWorkerContainerParent(PServiceWorkerContainerParent* aActor);
|
||||
|
||||
// PServiceWorkerRegistration
|
||||
|
|
|
@ -22,8 +22,9 @@ void ServiceWorkerContainerChild::ActorDestroy(ActorDestroyReason aReason) {
|
|||
}
|
||||
|
||||
// static
|
||||
ServiceWorkerContainerChild* ServiceWorkerContainerChild::Create() {
|
||||
ServiceWorkerContainerChild* actor = new ServiceWorkerContainerChild();
|
||||
already_AddRefed<ServiceWorkerContainerChild>
|
||||
ServiceWorkerContainerChild::Create() {
|
||||
RefPtr actor = new ServiceWorkerContainerChild;
|
||||
|
||||
if (!NS_IsMainThread()) {
|
||||
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
||||
|
@ -36,12 +37,11 @@ ServiceWorkerContainerChild* ServiceWorkerContainerChild::Create() {
|
|||
workerPrivate, "ServiceWorkerContainerChild",
|
||||
[helper] { helper->Actor()->MaybeStartTeardown(); });
|
||||
if (NS_WARN_IF(!actor->mIPCWorkerRef)) {
|
||||
delete actor;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return actor;
|
||||
return actor.forget();
|
||||
}
|
||||
|
||||
ServiceWorkerContainerChild::ServiceWorkerContainerChild()
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class RemoteServiceWorkerContainerImpl;
|
||||
|
||||
class IPCWorkerRef;
|
||||
|
||||
class ServiceWorkerContainerChild final : public PServiceWorkerContainerChild {
|
||||
|
@ -21,13 +23,15 @@ class ServiceWorkerContainerChild final : public PServiceWorkerContainerChild {
|
|||
|
||||
ServiceWorkerContainerChild();
|
||||
|
||||
~ServiceWorkerContainerChild() = default;
|
||||
|
||||
// PServiceWorkerContainerChild
|
||||
void ActorDestroy(ActorDestroyReason aReason) override;
|
||||
|
||||
public:
|
||||
static ServiceWorkerContainerChild* Create();
|
||||
NS_INLINE_DECL_REFCOUNTING(ServiceWorkerContainerChild, override);
|
||||
|
||||
~ServiceWorkerContainerChild() = default;
|
||||
static already_AddRefed<ServiceWorkerContainerChild> Create();
|
||||
|
||||
void SetOwner(RemoteServiceWorkerContainerImpl* aOwner);
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@ class ServiceWorkerContainerParent final
|
|||
: public PServiceWorkerContainerParent {
|
||||
RefPtr<ServiceWorkerContainerProxy> mProxy;
|
||||
|
||||
~ServiceWorkerContainerParent();
|
||||
|
||||
// PServiceWorkerContainerParent
|
||||
void ActorDestroy(ActorDestroyReason aReason) override;
|
||||
|
||||
|
@ -42,8 +44,9 @@ class ServiceWorkerContainerParent final
|
|||
GetReadyResolver&& aResolver) override;
|
||||
|
||||
public:
|
||||
NS_INLINE_DECL_REFCOUNTING(ServiceWorkerContainerParent, override);
|
||||
|
||||
ServiceWorkerContainerParent();
|
||||
~ServiceWorkerContainerParent();
|
||||
|
||||
void Init();
|
||||
};
|
||||
|
|
|
@ -14,7 +14,7 @@ class ServiceWorkerContainerParent;
|
|||
|
||||
class ServiceWorkerContainerProxy final {
|
||||
// Background thread only
|
||||
ServiceWorkerContainerParent* mActor;
|
||||
RefPtr<ServiceWorkerContainerParent> mActor;
|
||||
|
||||
~ServiceWorkerContainerProxy();
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@ EXPORTS.mozilla.dom += [
|
|||
'ServiceWorkerChild.h',
|
||||
'ServiceWorkerCloneData.h',
|
||||
'ServiceWorkerContainer.h',
|
||||
'ServiceWorkerContainerChild.h',
|
||||
'ServiceWorkerContainerParent.h',
|
||||
'ServiceWorkerDescriptor.h',
|
||||
'ServiceWorkerEvents.h',
|
||||
'ServiceWorkerInfo.h',
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "mozilla/dom/LocalStorage.h"
|
||||
#include "mozilla/dom/MessagePortChild.h"
|
||||
#include "mozilla/dom/ServiceWorkerActors.h"
|
||||
#include "mozilla/dom/ServiceWorkerContainerChild.h"
|
||||
#include "mozilla/dom/ServiceWorkerManagerChild.h"
|
||||
#include "mozilla/dom/BrowserChild.h"
|
||||
#include "mozilla/ipc/IPCStreamAlloc.h"
|
||||
|
@ -647,14 +648,9 @@ BackgroundChildImpl::AllocPServiceWorkerChild(
|
|||
return {};
|
||||
}
|
||||
|
||||
PServiceWorkerContainerChild*
|
||||
already_AddRefed<PServiceWorkerContainerChild>
|
||||
BackgroundChildImpl::AllocPServiceWorkerContainerChild() {
|
||||
return dom::AllocServiceWorkerContainerChild();
|
||||
}
|
||||
|
||||
bool BackgroundChildImpl::DeallocPServiceWorkerContainerChild(
|
||||
PServiceWorkerContainerChild* aActor) {
|
||||
return dom::DeallocServiceWorkerContainerChild(aActor);
|
||||
return mozilla::dom::ServiceWorkerContainerChild::Create();
|
||||
}
|
||||
|
||||
PServiceWorkerRegistrationChild*
|
||||
|
|
|
@ -246,11 +246,8 @@ class BackgroundChildImpl : public PBackgroundChild,
|
|||
already_AddRefed<PServiceWorkerChild> AllocPServiceWorkerChild(
|
||||
const IPCServiceWorkerDescriptor&);
|
||||
|
||||
virtual PServiceWorkerContainerChild* AllocPServiceWorkerContainerChild()
|
||||
override;
|
||||
|
||||
virtual bool DeallocPServiceWorkerContainerChild(
|
||||
PServiceWorkerContainerChild*) override;
|
||||
already_AddRefed<PServiceWorkerContainerChild>
|
||||
AllocPServiceWorkerContainerChild();
|
||||
|
||||
virtual PServiceWorkerRegistrationChild* AllocPServiceWorkerRegistrationChild(
|
||||
const IPCServiceWorkerRegistrationDescriptor&) override;
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "mozilla/dom/RemoteWorkerServiceParent.h"
|
||||
#include "mozilla/dom/ReportingHeader.h"
|
||||
#include "mozilla/dom/ServiceWorkerActors.h"
|
||||
#include "mozilla/dom/ServiceWorkerContainerParent.h"
|
||||
#include "mozilla/dom/ServiceWorkerManagerParent.h"
|
||||
#include "mozilla/dom/ServiceWorkerParent.h"
|
||||
#include "mozilla/dom/ServiceWorkerRegistrar.h"
|
||||
|
@ -1255,7 +1256,6 @@ already_AddRefed<PServiceWorkerParent>
|
|||
BackgroundParentImpl::AllocPServiceWorkerParent(
|
||||
const IPCServiceWorkerDescriptor&) {
|
||||
return MakeAndAddRef<ServiceWorkerParent>();
|
||||
;
|
||||
}
|
||||
|
||||
IPCResult BackgroundParentImpl::RecvPServiceWorkerConstructor(
|
||||
|
@ -1265,14 +1265,9 @@ IPCResult BackgroundParentImpl::RecvPServiceWorkerConstructor(
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
PServiceWorkerContainerParent*
|
||||
already_AddRefed<PServiceWorkerContainerParent>
|
||||
BackgroundParentImpl::AllocPServiceWorkerContainerParent() {
|
||||
return dom::AllocServiceWorkerContainerParent();
|
||||
}
|
||||
|
||||
bool BackgroundParentImpl::DeallocPServiceWorkerContainerParent(
|
||||
PServiceWorkerContainerParent* aActor) {
|
||||
return dom::DeallocServiceWorkerContainerParent(aActor);
|
||||
return MakeAndAddRef<mozilla::dom::ServiceWorkerContainerParent>();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
|
|
|
@ -368,10 +368,8 @@ class BackgroundParentImpl : public PBackgroundParent,
|
|||
PServiceWorkerParent* aActor,
|
||||
const IPCServiceWorkerDescriptor& aDescriptor) override;
|
||||
|
||||
PServiceWorkerContainerParent* AllocPServiceWorkerContainerParent() override;
|
||||
|
||||
bool DeallocPServiceWorkerContainerParent(
|
||||
PServiceWorkerContainerParent*) override;
|
||||
already_AddRefed<PServiceWorkerContainerParent>
|
||||
AllocPServiceWorkerContainerParent() final;
|
||||
|
||||
mozilla::ipc::IPCResult RecvPServiceWorkerContainerConstructor(
|
||||
PServiceWorkerContainerParent* aActor) override;
|
||||
|
|
Загрузка…
Ссылка в новой задаче