Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Unified Diff: Source/modules/serviceworkers/ServiceWorkerContainer.cpp

Issue 894983002: ServiceWorker: Make "ready" fetches registration from browser process(1/3). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: pass layout tests Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/serviceworkers/ServiceWorkerContainer.h ('k') | public/platform/WebServiceWorkerProvider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)) {
« no previous file with comments | « Source/modules/serviceworkers/ServiceWorkerContainer.h ('k') | public/platform/WebServiceWorkerProvider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698