Index: Source/modules/serviceworkers/ServiceWorkerClients.cpp |
diff --git a/Source/modules/serviceworkers/ServiceWorkerClients.cpp b/Source/modules/serviceworkers/ServiceWorkerClients.cpp |
index 364f5a5cb00e21a2f1811cc08025e3e44d0dddca..7d9e8d4da331d370b77ffeea089b38fc25e1f6fe 100644 |
--- a/Source/modules/serviceworkers/ServiceWorkerClients.cpp |
+++ b/Source/modules/serviceworkers/ServiceWorkerClients.cpp |
@@ -73,4 +73,20 @@ ScriptPromise ServiceWorkerClients::getAll(ScriptState* scriptState, const Clien |
return promise; |
} |
+ScriptPromise ServiceWorkerClients::claim(ScriptState* scriptState) |
+{ |
+ ExecutionContext* executionContext = scriptState->executionContext(); |
+ |
+ // FIXME: May be null due to worker termination: http://crbug.coma/413518. |
+ if (!executionContext) |
+ return ScriptPromise(); |
+ |
+ RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState); |
+ ScriptPromise promise = resolver->promise(); |
+ |
+ WebServiceWorkerClientsClaimCallbacks* callbacks = new CallbackPromiseAdapter<void, ServiceWorkerError>(resolver); |
+ ServiceWorkerGlobalScopeClient::from(executionContext)->claim(callbacks); |
+ return promise; |
+} |
+ |
} // namespace blink |