Bug 1454646 P2 Implement ServiceWorkerContainer::GetReady() via the Inner class. r=baku

This commit is contained in:
Ben Kelly 2018-04-17 07:46:14 -07:00
Родитель a7ef225557
Коммит 13c73ec777
4 изменённых файлов: 13 добавлений и 12 удалений

Просмотреть файл

@ -289,12 +289,6 @@ ServiceWorkerContainer::GetReady(ErrorResult& aRv)
return nullptr;
}
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
if (!swm) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return nullptr;
}
mReadyPromise = Promise::Create(GetParentObject(), aRv);
if (aRv.Failed()) {
return nullptr;
@ -303,7 +297,7 @@ ServiceWorkerContainer::GetReady(ErrorResult& aRv)
RefPtr<ServiceWorkerContainer> self = this;
RefPtr<Promise> outer = mReadyPromise;
swm->WhenReady(clientInfo.ref())->Then(
mInner->GetReady(clientInfo.ref())->Then(
global->EventTargetFor(TaskCategory::Other), __func__,
[self, outer] (const ServiceWorkerRegistrationDescriptor& aDescriptor) {
self->mReadyPromiseHolder.Complete();

Просмотреть файл

@ -37,7 +37,7 @@ public:
GetRegistrations() = 0;
virtual RefPtr<ServiceWorkerRegistrationPromise>
GetReady() = 0;
GetReady(const ClientInfo& aClientInfo) const = 0;
NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
};

Просмотреть файл

@ -32,10 +32,15 @@ ServiceWorkerContainerImpl::GetRegistrations()
}
RefPtr<ServiceWorkerRegistrationPromise>
ServiceWorkerContainerImpl::GetReady()
ServiceWorkerContainerImpl::GetReady(const ClientInfo& aClientInfo) const
{
// TODO
return nullptr;
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
if (NS_WARN_IF(!swm)) {
return ServiceWorkerRegistrationPromise::CreateAndReject(NS_ERROR_DOM_INVALID_STATE_ERR,
__func__);
}
return swm->WhenReady(aClientInfo);
}
} // namespace dom

Просмотреть файл

@ -18,6 +18,8 @@ class ServiceWorkerContainerImpl final : public ServiceWorkerContainer::Inner
~ServiceWorkerContainerImpl() = default;
public:
ServiceWorkerContainerImpl() = default;
RefPtr<ServiceWorkerRegistrationPromise>
Register(const nsAString& aScriptURL,
const RegistrationOptions& aOptions) override;
@ -29,7 +31,7 @@ public:
GetRegistrations() override;
RefPtr<ServiceWorkerRegistrationPromise>
GetReady() override;
GetReady(const ClientInfo& aClientInfo) const override;
NS_INLINE_DECL_REFCOUNTING(ServiceWorkerContainerImpl, override)
};