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