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

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

Issue 1166283006: ServiceWorker: Implement ServiceWorkerRegistration.update() (1) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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 1f7f2a6e4b6e28e0db7241f71704b52d93ae3a31..b5ed86678ff0387a49e1b23575f19588e88d3d43 100644
--- a/Source/modules/serviceworkers/ServiceWorkerRegistration.cpp
+++ b/Source/modules/serviceworkers/ServiceWorkerRegistration.cpp
@@ -86,6 +86,25 @@ String ServiceWorkerRegistration::scope() const
return m_outerRegistration->scope().string();
}
+void ServiceWorkerRegistration::update(ScriptState* scriptState, ExceptionState& exceptionState)
+{
+ if (!m_provider) {
+ exceptionState.throwDOMException(InvalidStateError, "Failed to update a ServiceWorkerRegistration: No associated provider is available.");
+ return;
+ }
+
+ RefPtr<SecurityOrigin> documentOrigin = scriptState->executionContext()->securityOrigin();
+ KURL scopeURL = scriptState->executionContext()->completeURL(scope());
+ scopeURL.removeFragmentIdentifier();
+ if (!scope().isEmpty() && !documentOrigin->canRequest(scopeURL)) {
+ RefPtr<SecurityOrigin> scopeOrigin = SecurityOrigin::create(scopeURL);
+ exceptionState.throwSecurityError("Failed to update a ServiceWorkerRegistration: The origin of the registration's scope ('" + scopeOrigin->toString() + "') does not match the current origin ('" + documentOrigin->toString() + "').");
+ return;
+ }
+
+ m_provider->updateServiceWorker(scopeURL);
+}
+
ScriptPromise ServiceWorkerRegistration::unregister(ScriptState* scriptState)
{
RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(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