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

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

Issue 1260833003: Service Worker: (Re-commit) Make ServiceWorkerRegistration.update() return a promise. (Blink 1/3) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove |this| for calling its own method. Created 5 years, 4 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
Index: Source/modules/serviceworkers/ServiceWorkerRegistration.cpp
diff --git a/Source/modules/serviceworkers/ServiceWorkerRegistration.cpp b/Source/modules/serviceworkers/ServiceWorkerRegistration.cpp
index 7c701b4998cbf5cca150e04625530d6aebd0c36b..999a62087e8ec9937a1d6ab6e218ad57691abf82 100644
--- a/Source/modules/serviceworkers/ServiceWorkerRegistration.cpp
+++ b/Source/modules/serviceworkers/ServiceWorkerRegistration.cpp
@@ -86,13 +86,18 @@ String ServiceWorkerRegistration::scope() const
return m_outerRegistration->scope().string();
}
-void ServiceWorkerRegistration::update(ScriptState* scriptState, ExceptionState& exceptionState)
+ScriptPromise ServiceWorkerRegistration::update(ScriptState* scriptState)
{
+ RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState);
+ ScriptPromise promise = resolver->promise();
+
if (!m_provider) {
- exceptionState.throwDOMException(InvalidStateError, "Failed to update a ServiceWorkerRegistration: No associated provider is available.");
- return;
+ resolver->reject(DOMException::create(InvalidStateError, "Failed to update a ServiceWorkerRegistration: No associated provider is available."));
+ return promise;
}
- m_outerRegistration->update(m_provider);
+
+ m_outerRegistration->update(m_provider, new CallbackPromiseAdapter<void, ServiceWorkerError>(resolver));
+ return promise;
}
ScriptPromise ServiceWorkerRegistration::unregister(ScriptState* scriptState)
« no previous file with comments | « Source/modules/serviceworkers/ServiceWorkerRegistration.h ('k') | Source/modules/serviceworkers/ServiceWorkerRegistration.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698