| Index: Source/modules/serviceworkers/ServiceWorkerContainer.cpp
|
| diff --git a/Source/modules/serviceworkers/ServiceWorkerContainer.cpp b/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
|
| index 8604b35afe12449d575a93efe59b3731c4cd9d0e..b61dbda521a09236af6784426e14110a765a9bd3 100644
|
| --- a/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
|
| +++ b/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
|
| @@ -81,6 +81,23 @@ private:
|
| WTF_MAKE_NONCOPYABLE(GetRegistrationCallback);
|
| };
|
|
|
| +class ServiceWorkerContainer::GetRegistrationForReadyCallback : public WebServiceWorkerProvider::WebServiceWorkerGetRegistrationForReadyCallbacks {
|
| +public:
|
| + explicit GetRegistrationForReadyCallback(ReadyProperty* ready)
|
| + : m_ready(ready) { }
|
| + ~GetRegistrationForReadyCallback() { }
|
| + void onSuccess(WebServiceWorkerRegistration* registration) override
|
| + {
|
| + ASSERT(registration);
|
| + ASSERT(m_ready->state() == ReadyProperty::Pending);
|
| + if (m_ready->executionContext() && !m_ready->executionContext()->activeDOMObjectsAreStopped())
|
| + m_ready->resolve(ServiceWorkerRegistration::from(m_ready->executionContext(), registration));
|
| + }
|
| +private:
|
| + Persistent<ReadyProperty> m_ready;
|
| + WTF_MAKE_NONCOPYABLE(GetRegistrationForReadyCallback);
|
| +};
|
| +
|
| ServiceWorkerContainer* ServiceWorkerContainer::create(ExecutionContext* executionContext)
|
| {
|
| return new ServiceWorkerContainer(executionContext);
|
| @@ -233,6 +250,12 @@ ScriptPromise ServiceWorkerContainer::ready(ScriptState* callerState)
|
| return ScriptPromise::rejectWithDOMException(callerState, DOMException::create(NotSupportedError, "'ready' is only supported in pages."));
|
| }
|
|
|
| + if (!m_ready) {
|
| + m_ready = createReadyProperty();
|
| + if (m_provider)
|
| + m_provider->getRegistrationForReady(new GetRegistrationForReadyCallback(m_ready.get()));
|
| + }
|
| +
|
| return m_ready->promise(callerState->world());
|
| }
|
|
|
| @@ -256,6 +279,7 @@ void ServiceWorkerContainer::setController(WebServiceWorker* serviceWorker, bool
|
| dispatchEvent(Event::create(EventTypeNames::controllerchange));
|
| }
|
|
|
| +// FIXME: Remove this after Chrome side CL landed.
|
| void ServiceWorkerContainer::setReadyRegistration(WebServiceWorkerRegistration* registration)
|
| {
|
| if (!executionContext()) {
|
| @@ -318,6 +342,7 @@ ServiceWorkerContainer::ServiceWorkerContainer(ExecutionContext* executionContex
|
| if (!executionContext)
|
| return;
|
|
|
| + // FIXME: Remove this after Chrome side CL landed.
|
| m_ready = createReadyProperty();
|
|
|
| if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::from(executionContext)) {
|
|
|