зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1559919 - Finish the WorkerHolder cleanup - part 4 - IPCWorkerRef in ServiceWorkerContainerChild, r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D35223 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
6e86832cf2
Коммит
dfb7f820f8
|
@ -199,22 +199,12 @@ RemoteServiceWorkerContainerImpl::RemoteServiceWorkerContainerImpl()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<WorkerHolderToken> workerHolderToken;
|
ServiceWorkerContainerChild* actor = ServiceWorkerContainerChild::Create();
|
||||||
if (!NS_IsMainThread()) {
|
if (NS_WARN_IF(!actor)) {
|
||||||
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
Shutdown();
|
||||||
MOZ_DIAGNOSTIC_ASSERT(workerPrivate);
|
return;
|
||||||
|
|
||||||
workerHolderToken = WorkerHolderToken::Create(
|
|
||||||
workerPrivate, Canceling, WorkerHolderToken::AllowIdleShutdownStart);
|
|
||||||
|
|
||||||
if (NS_WARN_IF(!workerHolderToken)) {
|
|
||||||
Shutdown();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceWorkerContainerChild* actor =
|
|
||||||
new ServiceWorkerContainerChild(workerHolderToken);
|
|
||||||
PServiceWorkerContainerChild* sentActor =
|
PServiceWorkerContainerChild* sentActor =
|
||||||
parentActor->SendPServiceWorkerContainerConstructor(actor);
|
parentActor->SendPServiceWorkerContainerConstructor(actor);
|
||||||
if (NS_WARN_IF(!sentActor)) {
|
if (NS_WARN_IF(!sentActor)) {
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#include "mozilla/dom/PServiceWorkerContainerChild.h"
|
#include "mozilla/dom/PServiceWorkerContainerChild.h"
|
||||||
|
#include "mozilla/dom/WorkerRef.h"
|
||||||
|
|
||||||
#include "RemoteServiceWorkerContainerImpl.h"
|
#include "RemoteServiceWorkerContainerImpl.h"
|
||||||
|
|
||||||
|
@ -12,10 +13,7 @@ namespace mozilla {
|
||||||
namespace dom {
|
namespace dom {
|
||||||
|
|
||||||
void ServiceWorkerContainerChild::ActorDestroy(ActorDestroyReason aReason) {
|
void ServiceWorkerContainerChild::ActorDestroy(ActorDestroyReason aReason) {
|
||||||
if (mWorkerHolderToken) {
|
mIPCWorkerRef = nullptr;
|
||||||
mWorkerHolderToken->RemoveListener(this);
|
|
||||||
mWorkerHolderToken = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mOwner) {
|
if (mOwner) {
|
||||||
mOwner->RevokeActor(this);
|
mOwner->RevokeActor(this);
|
||||||
|
@ -23,18 +21,32 @@ void ServiceWorkerContainerChild::ActorDestroy(ActorDestroyReason aReason) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServiceWorkerContainerChild::WorkerShuttingDown() { MaybeStartTeardown(); }
|
// static
|
||||||
|
ServiceWorkerContainerChild* ServiceWorkerContainerChild::Create() {
|
||||||
|
ServiceWorkerContainerChild* actor = new ServiceWorkerContainerChild();
|
||||||
|
|
||||||
ServiceWorkerContainerChild::ServiceWorkerContainerChild(
|
if (!NS_IsMainThread()) {
|
||||||
WorkerHolderToken* aWorkerHolderToken)
|
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
||||||
: mWorkerHolderToken(aWorkerHolderToken),
|
MOZ_DIAGNOSTIC_ASSERT(workerPrivate);
|
||||||
mOwner(nullptr),
|
|
||||||
mTeardownStarted(false) {
|
RefPtr<IPCWorkerRefHelper<ServiceWorkerContainerChild>> helper =
|
||||||
if (mWorkerHolderToken) {
|
new IPCWorkerRefHelper<ServiceWorkerContainerChild>(actor);
|
||||||
mWorkerHolderToken->AddListener(this);
|
|
||||||
|
actor->mIPCWorkerRef = IPCWorkerRef::Create(
|
||||||
|
workerPrivate, "ServiceWorkerContainerChild",
|
||||||
|
[helper] { helper->Actor()->MaybeStartTeardown(); });
|
||||||
|
if (NS_WARN_IF(!actor->mIPCWorkerRef)) {
|
||||||
|
delete actor;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return actor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ServiceWorkerContainerChild::ServiceWorkerContainerChild()
|
||||||
|
: mOwner(nullptr), mTeardownStarted(false) {}
|
||||||
|
|
||||||
void ServiceWorkerContainerChild::SetOwner(
|
void ServiceWorkerContainerChild::SetOwner(
|
||||||
RemoteServiceWorkerContainerImpl* aOwner) {
|
RemoteServiceWorkerContainerImpl* aOwner) {
|
||||||
MOZ_DIAGNOSTIC_ASSERT(!mOwner);
|
MOZ_DIAGNOSTIC_ASSERT(!mOwner);
|
||||||
|
|
|
@ -8,25 +8,25 @@
|
||||||
#define mozilla_dom_serviceworkercontainerchild_h__
|
#define mozilla_dom_serviceworkercontainerchild_h__
|
||||||
|
|
||||||
#include "mozilla/dom/PServiceWorkerContainerChild.h"
|
#include "mozilla/dom/PServiceWorkerContainerChild.h"
|
||||||
#include "mozilla/dom/WorkerHolderToken.h"
|
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace dom {
|
namespace dom {
|
||||||
|
|
||||||
class ServiceWorkerContainerChild final : public PServiceWorkerContainerChild,
|
class IPCWorkerRef;
|
||||||
public WorkerHolderToken::Listener {
|
|
||||||
RefPtr<WorkerHolderToken> mWorkerHolderToken;
|
class ServiceWorkerContainerChild final : public PServiceWorkerContainerChild {
|
||||||
|
RefPtr<IPCWorkerRef> mIPCWorkerRef;
|
||||||
RemoteServiceWorkerContainerImpl* mOwner;
|
RemoteServiceWorkerContainerImpl* mOwner;
|
||||||
bool mTeardownStarted;
|
bool mTeardownStarted;
|
||||||
|
|
||||||
|
ServiceWorkerContainerChild();
|
||||||
|
|
||||||
// PServiceWorkerContainerChild
|
// PServiceWorkerContainerChild
|
||||||
void ActorDestroy(ActorDestroyReason aReason) override;
|
void ActorDestroy(ActorDestroyReason aReason) override;
|
||||||
|
|
||||||
// WorkerHolderToken::Listener
|
|
||||||
void WorkerShuttingDown() override;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ServiceWorkerContainerChild(WorkerHolderToken* aWorkerHolderToken);
|
static ServiceWorkerContainerChild* Create();
|
||||||
|
|
||||||
~ServiceWorkerContainerChild() = default;
|
~ServiceWorkerContainerChild() = default;
|
||||||
|
|
||||||
void SetOwner(RemoteServiceWorkerContainerImpl* aOwner);
|
void SetOwner(RemoteServiceWorkerContainerImpl* aOwner);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче