From e9dc1bae32dc3a92d9246a669ee9ed6076ea8147 Mon Sep 17 00:00:00 2001 From: Ben Kelly Date: Mon, 9 Jul 2018 16:02:40 -0700 Subject: [PATCH] Bug 1459209 P11 Propogate registration state changes back from the parent to the child. r=mrbkap --HG-- extra : rebase_source : 86bea6e7bcf6376d1fc5366a1a07b208f3805ce0 --- dom/serviceworkers/PServiceWorkerRegistration.ipdl | 2 ++ .../RemoteServiceWorkerRegistrationImpl.cpp | 8 ++++++++ .../RemoteServiceWorkerRegistrationImpl.h | 3 +++ dom/serviceworkers/ServiceWorkerRegistrationChild.cpp | 11 +++++++++++ dom/serviceworkers/ServiceWorkerRegistrationChild.h | 3 +++ dom/serviceworkers/ServiceWorkerRegistrationProxy.cpp | 2 +- 6 files changed, 28 insertions(+), 1 deletion(-) diff --git a/dom/serviceworkers/PServiceWorkerRegistration.ipdl b/dom/serviceworkers/PServiceWorkerRegistration.ipdl index 36812b86a939..1900a2777633 100644 --- a/dom/serviceworkers/PServiceWorkerRegistration.ipdl +++ b/dom/serviceworkers/PServiceWorkerRegistration.ipdl @@ -21,6 +21,8 @@ parent: child: async __delete__(); + + async UpdateState(IPCServiceWorkerRegistrationDescriptor aDescriptor); }; } // namespace dom diff --git a/dom/serviceworkers/RemoteServiceWorkerRegistrationImpl.cpp b/dom/serviceworkers/RemoteServiceWorkerRegistrationImpl.cpp index 188a5ca2c14e..df2129233ae0 100644 --- a/dom/serviceworkers/RemoteServiceWorkerRegistrationImpl.cpp +++ b/dom/serviceworkers/RemoteServiceWorkerRegistrationImpl.cpp @@ -161,5 +161,13 @@ RemoteServiceWorkerRegistrationImpl::RevokeActor(ServiceWorkerRegistrationChild* } } +void +RemoteServiceWorkerRegistrationImpl::UpdateState(const ServiceWorkerRegistrationDescriptor& aDescriptor) +{ + if (mOuter) { + mOuter->UpdateState(aDescriptor); + } +} + } // namespace dom } // namespace mozilla diff --git a/dom/serviceworkers/RemoteServiceWorkerRegistrationImpl.h b/dom/serviceworkers/RemoteServiceWorkerRegistrationImpl.h index 024b911ca743..5cd1f4ae8e2f 100644 --- a/dom/serviceworkers/RemoteServiceWorkerRegistrationImpl.h +++ b/dom/serviceworkers/RemoteServiceWorkerRegistrationImpl.h @@ -46,6 +46,9 @@ public: void RevokeActor(ServiceWorkerRegistrationChild* aActor); + void + UpdateState(const ServiceWorkerRegistrationDescriptor& aDescriptor); + NS_INLINE_DECL_REFCOUNTING(RemoteServiceWorkerRegistrationImpl, override) }; diff --git a/dom/serviceworkers/ServiceWorkerRegistrationChild.cpp b/dom/serviceworkers/ServiceWorkerRegistrationChild.cpp index 53979a4d8ac4..060ef7b4304c 100644 --- a/dom/serviceworkers/ServiceWorkerRegistrationChild.cpp +++ b/dom/serviceworkers/ServiceWorkerRegistrationChild.cpp @@ -11,6 +11,8 @@ namespace mozilla { namespace dom { +using mozilla::ipc::IPCResult; + void ServiceWorkerRegistrationChild::ActorDestroy(ActorDestroyReason aReason) { @@ -25,6 +27,15 @@ ServiceWorkerRegistrationChild::ActorDestroy(ActorDestroyReason aReason) } } +IPCResult +ServiceWorkerRegistrationChild::RecvUpdateState(const IPCServiceWorkerRegistrationDescriptor& aDescriptor) +{ + if (mOwner) { + mOwner->UpdateState(ServiceWorkerRegistrationDescriptor(aDescriptor)); + } + return IPC_OK(); +} + void ServiceWorkerRegistrationChild::WorkerShuttingDown() { diff --git a/dom/serviceworkers/ServiceWorkerRegistrationChild.h b/dom/serviceworkers/ServiceWorkerRegistrationChild.h index 2726d10c27ba..af05bd60a48f 100644 --- a/dom/serviceworkers/ServiceWorkerRegistrationChild.h +++ b/dom/serviceworkers/ServiceWorkerRegistrationChild.h @@ -26,6 +26,9 @@ class ServiceWorkerRegistrationChild final : public PServiceWorkerRegistrationCh void ActorDestroy(ActorDestroyReason aReason) override; + mozilla::ipc::IPCResult + RecvUpdateState(const IPCServiceWorkerRegistrationDescriptor& aDescriptor) override; + // WorkerHolderToken::Listener void WorkerShuttingDown() override; diff --git a/dom/serviceworkers/ServiceWorkerRegistrationProxy.cpp b/dom/serviceworkers/ServiceWorkerRegistrationProxy.cpp index 516cc382a518..50437db81c30 100644 --- a/dom/serviceworkers/ServiceWorkerRegistrationProxy.cpp +++ b/dom/serviceworkers/ServiceWorkerRegistrationProxy.cpp @@ -39,7 +39,7 @@ ServiceWorkerRegistrationProxy::UpdateStateOnBGThread(const ServiceWorkerRegistr if (!mActor) { return; } - // TODO: send update + Unused << mActor->SendUpdateState(aDescriptor.ToIPC()); } void