mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 1559919 - Finish the WorkerHolder cleanup - part 5 - IPCWorkerRef in ServiceWorkerRegistrationChild, r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D35224 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
dfb7f820f8
commit
dda55c2dec
@ -114,22 +114,13 @@ RemoteServiceWorkerRegistrationImpl::RemoteServiceWorkerRegistrationImpl(
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<WorkerHolderToken> workerHolderToken;
|
||||
if (!NS_IsMainThread()) {
|
||||
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
||||
MOZ_DIAGNOSTIC_ASSERT(workerPrivate);
|
||||
|
||||
workerHolderToken = WorkerHolderToken::Create(
|
||||
workerPrivate, Canceling, WorkerHolderToken::AllowIdleShutdownStart);
|
||||
|
||||
if (NS_WARN_IF(!workerHolderToken)) {
|
||||
Shutdown();
|
||||
return;
|
||||
}
|
||||
ServiceWorkerRegistrationChild* actor =
|
||||
ServiceWorkerRegistrationChild::Create();
|
||||
if (NS_WARN_IF(!actor)) {
|
||||
Shutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
ServiceWorkerRegistrationChild* actor =
|
||||
new ServiceWorkerRegistrationChild(workerHolderToken);
|
||||
PServiceWorkerRegistrationChild* sentActor =
|
||||
parentActor->SendPServiceWorkerRegistrationConstructor(
|
||||
actor, aDescriptor.ToIPC());
|
||||
|
@ -14,10 +14,7 @@ namespace dom {
|
||||
using mozilla::ipc::IPCResult;
|
||||
|
||||
void ServiceWorkerRegistrationChild::ActorDestroy(ActorDestroyReason aReason) {
|
||||
if (mWorkerHolderToken) {
|
||||
mWorkerHolderToken->RemoveListener(this);
|
||||
mWorkerHolderToken = nullptr;
|
||||
}
|
||||
mIPCWorkerRef = nullptr;
|
||||
|
||||
if (mOwner) {
|
||||
mOwner->RevokeActor(this);
|
||||
@ -40,19 +37,32 @@ IPCResult ServiceWorkerRegistrationChild::RecvFireUpdateFound() {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
void ServiceWorkerRegistrationChild::WorkerShuttingDown() {
|
||||
MaybeStartTeardown();
|
||||
// static
|
||||
ServiceWorkerRegistrationChild* ServiceWorkerRegistrationChild::Create() {
|
||||
ServiceWorkerRegistrationChild* actor = new ServiceWorkerRegistrationChild();
|
||||
|
||||
if (!NS_IsMainThread()) {
|
||||
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
||||
MOZ_DIAGNOSTIC_ASSERT(workerPrivate);
|
||||
|
||||
RefPtr<IPCWorkerRefHelper<ServiceWorkerRegistrationChild>> helper =
|
||||
new IPCWorkerRefHelper<ServiceWorkerRegistrationChild>(actor);
|
||||
|
||||
actor->mIPCWorkerRef = IPCWorkerRef::Create(
|
||||
workerPrivate, "ServiceWorkerRegistrationChild",
|
||||
[helper] { helper->Actor()->MaybeStartTeardown(); });
|
||||
|
||||
if (NS_WARN_IF(!actor->mIPCWorkerRef)) {
|
||||
delete actor;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return actor;
|
||||
}
|
||||
|
||||
ServiceWorkerRegistrationChild::ServiceWorkerRegistrationChild(
|
||||
WorkerHolderToken* aWorkerHolderToken)
|
||||
: mWorkerHolderToken(aWorkerHolderToken),
|
||||
mOwner(nullptr),
|
||||
mTeardownStarted(false) {
|
||||
if (mWorkerHolderToken) {
|
||||
mWorkerHolderToken->AddListener(this);
|
||||
}
|
||||
}
|
||||
ServiceWorkerRegistrationChild::ServiceWorkerRegistrationChild()
|
||||
: mOwner(nullptr), mTeardownStarted(false) {}
|
||||
|
||||
void ServiceWorkerRegistrationChild::SetOwner(
|
||||
RemoteServiceWorkerRegistrationImpl* aOwner) {
|
||||
|
@ -8,20 +8,21 @@
|
||||
#define mozilla_dom_serviceworkerregistrationchild_h__
|
||||
|
||||
#include "mozilla/dom/PServiceWorkerRegistrationChild.h"
|
||||
#include "mozilla/dom/WorkerHolderToken.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class IPCWorkerRef;
|
||||
class RemoteServiceWorkerRegistrationImpl;
|
||||
|
||||
class ServiceWorkerRegistrationChild final
|
||||
: public PServiceWorkerRegistrationChild,
|
||||
public WorkerHolderToken::Listener {
|
||||
RefPtr<WorkerHolderToken> mWorkerHolderToken;
|
||||
: public PServiceWorkerRegistrationChild {
|
||||
RefPtr<IPCWorkerRef> mIPCWorkerRef;
|
||||
RemoteServiceWorkerRegistrationImpl* mOwner;
|
||||
bool mTeardownStarted;
|
||||
|
||||
ServiceWorkerRegistrationChild();
|
||||
|
||||
// PServiceWorkerRegistrationChild
|
||||
void ActorDestroy(ActorDestroyReason aReason) override;
|
||||
|
||||
@ -30,12 +31,9 @@ class ServiceWorkerRegistrationChild final
|
||||
|
||||
mozilla::ipc::IPCResult RecvFireUpdateFound() override;
|
||||
|
||||
// WorkerHolderToken::Listener
|
||||
void WorkerShuttingDown() override;
|
||||
|
||||
public:
|
||||
explicit ServiceWorkerRegistrationChild(
|
||||
WorkerHolderToken* aWorkerHolderToken);
|
||||
static ServiceWorkerRegistrationChild* Create();
|
||||
|
||||
~ServiceWorkerRegistrationChild() = default;
|
||||
|
||||
void SetOwner(RemoteServiceWorkerRegistrationImpl* aOwner);
|
||||
|
Loading…
Reference in New Issue
Block a user