mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1653470
- refcount PServiceWorkerRegistration r=dom-workers-and-storage-reviewers,asuth
Depends on D83884 Differential Revision: https://phabricator.services.mozilla.com/D83885
This commit is contained in:
parent
260415ed7c
commit
0e70329c0d
@ -9,7 +9,7 @@ include IPCServiceWorkerRegistrationDescriptor;
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
protocol PServiceWorkerRegistration
|
||||
refcounted protocol PServiceWorkerRegistration
|
||||
{
|
||||
manager PBackground;
|
||||
|
||||
|
@ -108,7 +108,7 @@ void RemoteServiceWorkerRegistrationImpl::Unregister(
|
||||
|
||||
RemoteServiceWorkerRegistrationImpl::RemoteServiceWorkerRegistrationImpl(
|
||||
const ServiceWorkerRegistrationDescriptor& aDescriptor)
|
||||
: mActor(nullptr), mOuter(nullptr), mShutdown(false) {
|
||||
: mOuter(nullptr), mShutdown(false) {
|
||||
PBackgroundChild* parentActor =
|
||||
BackgroundChild::GetOrCreateForCurrentThread();
|
||||
if (NS_WARN_IF(!parentActor)) {
|
||||
@ -116,8 +116,7 @@ RemoteServiceWorkerRegistrationImpl::RemoteServiceWorkerRegistrationImpl(
|
||||
return;
|
||||
}
|
||||
|
||||
ServiceWorkerRegistrationChild* actor =
|
||||
ServiceWorkerRegistrationChild::Create();
|
||||
auto actor = ServiceWorkerRegistrationChild::Create();
|
||||
if (NS_WARN_IF(!actor)) {
|
||||
Shutdown();
|
||||
return;
|
||||
@ -132,7 +131,7 @@ RemoteServiceWorkerRegistrationImpl::RemoteServiceWorkerRegistrationImpl(
|
||||
}
|
||||
MOZ_DIAGNOSTIC_ASSERT(sentActor == actor);
|
||||
|
||||
mActor = actor;
|
||||
mActor = std::move(actor);
|
||||
mActor->SetOwner(this);
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ class ServiceWorkerRegistrationChild;
|
||||
|
||||
class RemoteServiceWorkerRegistrationImpl final
|
||||
: public ServiceWorkerRegistration::Inner {
|
||||
ServiceWorkerRegistrationChild* mActor;
|
||||
RefPtr<ServiceWorkerRegistrationChild> mActor;
|
||||
ServiceWorkerRegistration* mOuter;
|
||||
bool mShutdown;
|
||||
|
||||
|
@ -27,28 +27,6 @@ void InitServiceWorkerContainerParent(PServiceWorkerContainerParent* aActor) {
|
||||
actor->Init();
|
||||
}
|
||||
|
||||
PServiceWorkerRegistrationChild* AllocServiceWorkerRegistrationChild() {
|
||||
MOZ_CRASH("should not be called");
|
||||
}
|
||||
|
||||
bool DeallocServiceWorkerRegistrationChild(
|
||||
PServiceWorkerRegistrationChild* aActor) {
|
||||
auto actor = static_cast<ServiceWorkerRegistrationChild*>(aActor);
|
||||
delete actor;
|
||||
return true;
|
||||
}
|
||||
|
||||
PServiceWorkerRegistrationParent* AllocServiceWorkerRegistrationParent() {
|
||||
return new ServiceWorkerRegistrationParent();
|
||||
}
|
||||
|
||||
bool DeallocServiceWorkerRegistrationParent(
|
||||
PServiceWorkerRegistrationParent* aActor) {
|
||||
auto actor = static_cast<ServiceWorkerRegistrationParent*>(aActor);
|
||||
delete actor;
|
||||
return true;
|
||||
}
|
||||
|
||||
void InitServiceWorkerRegistrationParent(
|
||||
PServiceWorkerRegistrationParent* aActor,
|
||||
const IPCServiceWorkerRegistrationDescriptor& aDescriptor) {
|
||||
|
@ -13,7 +13,6 @@ namespace dom {
|
||||
// PServiceWorker
|
||||
|
||||
class IPCServiceWorkerDescriptor;
|
||||
class PServiceWorkerChild;
|
||||
class PServiceWorkerParent;
|
||||
|
||||
void InitServiceWorkerParent(PServiceWorkerParent* aActor,
|
||||
@ -28,19 +27,8 @@ void InitServiceWorkerContainerParent(PServiceWorkerContainerParent* aActor);
|
||||
// PServiceWorkerRegistration
|
||||
|
||||
class IPCServiceWorkerRegistrationDescriptor;
|
||||
class PServiceWorkerRegistrationChild;
|
||||
class PServiceWorkerRegistrationParent;
|
||||
|
||||
PServiceWorkerRegistrationChild* AllocServiceWorkerRegistrationChild();
|
||||
|
||||
bool DeallocServiceWorkerRegistrationChild(
|
||||
PServiceWorkerRegistrationChild* aActor);
|
||||
|
||||
PServiceWorkerRegistrationParent* AllocServiceWorkerRegistrationParent();
|
||||
|
||||
bool DeallocServiceWorkerRegistrationParent(
|
||||
PServiceWorkerRegistrationParent* aActor);
|
||||
|
||||
void InitServiceWorkerRegistrationParent(
|
||||
PServiceWorkerRegistrationParent* aActor,
|
||||
const IPCServiceWorkerRegistrationDescriptor& aDescriptor);
|
||||
|
@ -39,8 +39,9 @@ IPCResult ServiceWorkerRegistrationChild::RecvFireUpdateFound() {
|
||||
}
|
||||
|
||||
// static
|
||||
ServiceWorkerRegistrationChild* ServiceWorkerRegistrationChild::Create() {
|
||||
ServiceWorkerRegistrationChild* actor = new ServiceWorkerRegistrationChild();
|
||||
RefPtr<ServiceWorkerRegistrationChild>
|
||||
ServiceWorkerRegistrationChild::Create() {
|
||||
RefPtr actor = new ServiceWorkerRegistrationChild;
|
||||
|
||||
if (!NS_IsMainThread()) {
|
||||
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
||||
@ -54,7 +55,6 @@ ServiceWorkerRegistrationChild* ServiceWorkerRegistrationChild::Create() {
|
||||
[helper] { helper->Actor()->MaybeStartTeardown(); });
|
||||
|
||||
if (NS_WARN_IF(!actor->mIPCWorkerRef)) {
|
||||
delete actor;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ class ServiceWorkerRegistrationChild final
|
||||
|
||||
ServiceWorkerRegistrationChild();
|
||||
|
||||
~ServiceWorkerRegistrationChild() = default;
|
||||
|
||||
// PServiceWorkerRegistrationChild
|
||||
void ActorDestroy(ActorDestroyReason aReason) override;
|
||||
|
||||
@ -32,9 +34,9 @@ class ServiceWorkerRegistrationChild final
|
||||
mozilla::ipc::IPCResult RecvFireUpdateFound() override;
|
||||
|
||||
public:
|
||||
static ServiceWorkerRegistrationChild* Create();
|
||||
NS_INLINE_DECL_REFCOUNTING(ServiceWorkerRegistrationChild, override);
|
||||
|
||||
~ServiceWorkerRegistrationChild() = default;
|
||||
static RefPtr<ServiceWorkerRegistrationChild> Create();
|
||||
|
||||
void SetOwner(RemoteServiceWorkerRegistrationImpl* aOwner);
|
||||
|
||||
|
@ -20,6 +20,8 @@ class ServiceWorkerRegistrationParent final
|
||||
RefPtr<ServiceWorkerRegistrationProxy> mProxy;
|
||||
bool mDeleteSent;
|
||||
|
||||
~ServiceWorkerRegistrationParent();
|
||||
|
||||
// PServiceWorkerRegistrationParent
|
||||
void ActorDestroy(ActorDestroyReason aReason) override;
|
||||
|
||||
@ -32,8 +34,9 @@ class ServiceWorkerRegistrationParent final
|
||||
UpdateResolver&& aResolver) override;
|
||||
|
||||
public:
|
||||
NS_INLINE_DECL_REFCOUNTING(ServiceWorkerRegistrationParent, override);
|
||||
|
||||
ServiceWorkerRegistrationParent();
|
||||
~ServiceWorkerRegistrationParent();
|
||||
|
||||
void Init(const IPCServiceWorkerRegistrationDescriptor& aDescriptor);
|
||||
|
||||
|
@ -166,9 +166,7 @@ bool ServiceWorkerRegistrationProxy::MatchesDescriptor(
|
||||
|
||||
ServiceWorkerRegistrationProxy::ServiceWorkerRegistrationProxy(
|
||||
const ServiceWorkerRegistrationDescriptor& aDescriptor)
|
||||
: mActor(nullptr),
|
||||
mEventTarget(GetCurrentSerialEventTarget()),
|
||||
mDescriptor(aDescriptor) {}
|
||||
: mEventTarget(GetCurrentSerialEventTarget()), mDescriptor(aDescriptor) {}
|
||||
|
||||
void ServiceWorkerRegistrationProxy::Init(
|
||||
ServiceWorkerRegistrationParent* aActor) {
|
||||
|
@ -22,7 +22,7 @@ class ServiceWorkerRegistrationParent;
|
||||
class ServiceWorkerRegistrationProxy final
|
||||
: public ServiceWorkerRegistrationListener {
|
||||
// Background thread only
|
||||
ServiceWorkerRegistrationParent* mActor;
|
||||
RefPtr<ServiceWorkerRegistrationParent> mActor;
|
||||
|
||||
// Written on background thread and read on main thread
|
||||
nsCOMPtr<nsISerialEventTarget> mEventTarget;
|
||||
|
@ -33,8 +33,10 @@ EXPORTS.mozilla.dom += [
|
||||
'ServiceWorkerParent.h',
|
||||
'ServiceWorkerRegistrar.h',
|
||||
'ServiceWorkerRegistration.h',
|
||||
'ServiceWorkerRegistrationChild.h',
|
||||
'ServiceWorkerRegistrationDescriptor.h',
|
||||
'ServiceWorkerRegistrationInfo.h',
|
||||
'ServiceWorkerRegistrationParent.h',
|
||||
'ServiceWorkerShutdownState.h',
|
||||
'ServiceWorkerUtils.h',
|
||||
]
|
||||
|
@ -653,15 +653,11 @@ BackgroundChildImpl::AllocPServiceWorkerContainerChild() {
|
||||
return mozilla::dom::ServiceWorkerContainerChild::Create();
|
||||
}
|
||||
|
||||
PServiceWorkerRegistrationChild*
|
||||
already_AddRefed<PServiceWorkerRegistrationChild>
|
||||
BackgroundChildImpl::AllocPServiceWorkerRegistrationChild(
|
||||
const IPCServiceWorkerRegistrationDescriptor&) {
|
||||
return dom::AllocServiceWorkerRegistrationChild();
|
||||
}
|
||||
|
||||
bool BackgroundChildImpl::DeallocPServiceWorkerRegistrationChild(
|
||||
PServiceWorkerRegistrationChild* aActor) {
|
||||
return dom::DeallocServiceWorkerRegistrationChild(aActor);
|
||||
MOZ_CRASH("Shouldn't be called.");
|
||||
return {};
|
||||
}
|
||||
|
||||
dom::PEndpointForReportChild* BackgroundChildImpl::AllocPEndpointForReportChild(
|
||||
|
@ -249,11 +249,9 @@ class BackgroundChildImpl : public PBackgroundChild,
|
||||
already_AddRefed<PServiceWorkerContainerChild>
|
||||
AllocPServiceWorkerContainerChild();
|
||||
|
||||
virtual PServiceWorkerRegistrationChild* AllocPServiceWorkerRegistrationChild(
|
||||
const IPCServiceWorkerRegistrationDescriptor&) override;
|
||||
|
||||
virtual bool DeallocPServiceWorkerRegistrationChild(
|
||||
PServiceWorkerRegistrationChild*) override;
|
||||
already_AddRefed<PServiceWorkerRegistrationChild>
|
||||
AllocPServiceWorkerRegistrationChild(
|
||||
const IPCServiceWorkerRegistrationDescriptor&);
|
||||
|
||||
virtual PEndpointForReportChild* AllocPEndpointForReportChild(
|
||||
const nsString& aGroupName, const PrincipalInfo& aPrincipalInfo) override;
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "mozilla/dom/ServiceWorkerManagerParent.h"
|
||||
#include "mozilla/dom/ServiceWorkerParent.h"
|
||||
#include "mozilla/dom/ServiceWorkerRegistrar.h"
|
||||
#include "mozilla/dom/ServiceWorkerRegistrationParent.h"
|
||||
#include "mozilla/dom/SessionStorageManager.h"
|
||||
#include "mozilla/dom/SharedWorkerParent.h"
|
||||
#include "mozilla/dom/StorageActivityService.h"
|
||||
@ -1277,15 +1278,10 @@ BackgroundParentImpl::RecvPServiceWorkerContainerConstructor(
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
PServiceWorkerRegistrationParent*
|
||||
already_AddRefed<PServiceWorkerRegistrationParent>
|
||||
BackgroundParentImpl::AllocPServiceWorkerRegistrationParent(
|
||||
const IPCServiceWorkerRegistrationDescriptor&) {
|
||||
return dom::AllocServiceWorkerRegistrationParent();
|
||||
}
|
||||
|
||||
bool BackgroundParentImpl::DeallocPServiceWorkerRegistrationParent(
|
||||
PServiceWorkerRegistrationParent* aActor) {
|
||||
return dom::DeallocServiceWorkerRegistrationParent(aActor);
|
||||
return MakeAndAddRef<mozilla::dom::ServiceWorkerRegistrationParent>();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
|
@ -374,11 +374,9 @@ class BackgroundParentImpl : public PBackgroundParent,
|
||||
mozilla::ipc::IPCResult RecvPServiceWorkerContainerConstructor(
|
||||
PServiceWorkerContainerParent* aActor) override;
|
||||
|
||||
PServiceWorkerRegistrationParent* AllocPServiceWorkerRegistrationParent(
|
||||
const IPCServiceWorkerRegistrationDescriptor&) override;
|
||||
|
||||
bool DeallocPServiceWorkerRegistrationParent(
|
||||
PServiceWorkerRegistrationParent*) override;
|
||||
already_AddRefed<PServiceWorkerRegistrationParent>
|
||||
AllocPServiceWorkerRegistrationParent(
|
||||
const IPCServiceWorkerRegistrationDescriptor&) final;
|
||||
|
||||
mozilla::ipc::IPCResult RecvPServiceWorkerRegistrationConstructor(
|
||||
PServiceWorkerRegistrationParent* aActor,
|
||||
|
Loading…
Reference in New Issue
Block a user