mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 12:20:56 +00:00
Bug 1459209 P15 Implement RemoteServiceWorkerContainerImpl::GetReady() across IPC to the parent-side SWM. r=mrbkap
--HG-- extra : rebase_source : 119a1cb66828c3dbb21cce86aca67793f0657321
This commit is contained in:
parent
d7b64230f7
commit
87bf0f7f23
@ -27,6 +27,9 @@ parent:
|
||||
async GetRegistrations(IPCClientInfo aClientInfo)
|
||||
returns (IPCServiceWorkerRegistrationDescriptorListOrCopyableErrorResult aResult);
|
||||
|
||||
async GetReady(IPCClientInfo aClientInfo)
|
||||
returns (IPCServiceWorkerRegistrationDescriptorOrCopyableErrorResult aResult);
|
||||
|
||||
child:
|
||||
async __delete__();
|
||||
};
|
||||
|
@ -157,7 +157,28 @@ RemoteServiceWorkerContainerImpl::GetReady(const ClientInfo& aClientInfo,
|
||||
ServiceWorkerRegistrationCallback&& aSuccessCB,
|
||||
ServiceWorkerFailureCallback&& aFailureCB) const
|
||||
{
|
||||
// TODO
|
||||
if (!mActor) {
|
||||
aFailureCB(CopyableErrorResult(NS_ERROR_DOM_INVALID_STATE_ERR));
|
||||
return;
|
||||
}
|
||||
|
||||
mActor->SendGetReady(aClientInfo.ToIPC(),
|
||||
[successCB = std::move(aSuccessCB), aFailureCB]
|
||||
(const IPCServiceWorkerRegistrationDescriptorOrCopyableErrorResult& aResult) {
|
||||
if (aResult.type() == IPCServiceWorkerRegistrationDescriptorOrCopyableErrorResult::TCopyableErrorResult) {
|
||||
// application layer error
|
||||
auto& rv = aResult.get_CopyableErrorResult();
|
||||
MOZ_DIAGNOSTIC_ASSERT(rv.Failed());
|
||||
aFailureCB(CopyableErrorResult(rv));
|
||||
return;
|
||||
}
|
||||
// success
|
||||
auto& ipcDesc = aResult.get_IPCServiceWorkerRegistrationDescriptor();
|
||||
successCB(ServiceWorkerRegistrationDescriptor(ipcDesc));
|
||||
}, [aFailureCB] (ResponseRejectReason aReason) {
|
||||
// IPC layer error
|
||||
aFailureCB(CopyableErrorResult(NS_ERROR_DOM_INVALID_STATE_ERR));
|
||||
});
|
||||
}
|
||||
|
||||
RemoteServiceWorkerContainerImpl::RemoteServiceWorkerContainerImpl()
|
||||
|
@ -97,6 +97,26 @@ ServiceWorkerContainerParent::RecvGetRegistrations(const IPCClientInfo& aClientI
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
IPCResult
|
||||
ServiceWorkerContainerParent::RecvGetReady(const IPCClientInfo& aClientInfo,
|
||||
GetReadyResolver&& aResolver)
|
||||
{
|
||||
if (!mProxy) {
|
||||
aResolver(CopyableErrorResult(NS_ERROR_DOM_INVALID_STATE_ERR));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mProxy->GetReady(ClientInfo(aClientInfo))->Then(
|
||||
GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[aResolver] (const ServiceWorkerRegistrationDescriptor& aDescriptor) {
|
||||
aResolver(aDescriptor.ToIPC());
|
||||
}, [aResolver] (const CopyableErrorResult& aResult) {
|
||||
aResolver(aResult);
|
||||
});
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
ServiceWorkerContainerParent::ServiceWorkerContainerParent()
|
||||
{
|
||||
}
|
||||
|
@ -41,6 +41,10 @@ class ServiceWorkerContainerParent final : public PServiceWorkerContainerParent
|
||||
RecvGetRegistrations(const IPCClientInfo& aClientInfo,
|
||||
GetRegistrationsResolver&& aResolver) override;
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
RecvGetReady(const IPCClientInfo& aClientInfo,
|
||||
GetReadyResolver&& aResolver) override;
|
||||
|
||||
public:
|
||||
ServiceWorkerContainerParent();
|
||||
~ServiceWorkerContainerParent();
|
||||
|
@ -126,5 +126,32 @@ ServiceWorkerContainerProxy::GetRegistrations(const ClientInfo& aClientInfo)
|
||||
return promise;
|
||||
}
|
||||
|
||||
RefPtr<ServiceWorkerRegistrationPromise>
|
||||
ServiceWorkerContainerProxy::GetReady(const ClientInfo& aClientInfo)
|
||||
{
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
RefPtr<ServiceWorkerRegistrationPromise::Private> promise =
|
||||
new ServiceWorkerRegistrationPromise::Private(__func__);
|
||||
|
||||
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(__func__,
|
||||
[aClientInfo, promise] () mutable {
|
||||
auto scopeExit = MakeScopeExit([&] {
|
||||
promise->Reject(NS_ERROR_DOM_INVALID_STATE_ERR, __func__);
|
||||
});
|
||||
|
||||
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
||||
NS_ENSURE_TRUE_VOID(swm);
|
||||
|
||||
swm->WhenReady(aClientInfo)->ChainTo(promise.forget(), __func__);
|
||||
|
||||
scopeExit.release();
|
||||
});
|
||||
|
||||
MOZ_ALWAYS_SUCCEEDS(SystemGroup::Dispatch(TaskCategory::Other, r.forget()));
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -36,6 +36,9 @@ public:
|
||||
RefPtr<ServiceWorkerRegistrationListPromise>
|
||||
GetRegistrations(const ClientInfo& aClientInfo);
|
||||
|
||||
RefPtr<ServiceWorkerRegistrationPromise>
|
||||
GetReady(const ClientInfo& aClientInfo);
|
||||
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ServiceWorkerContainerProxy);
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user