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

Side by Side Diff: Source/modules/serviceworkers/ServiceWorkerClients.cpp

Issue 868463004: ServiceWorker: add ServiceWorkerClients.claim() support (1/3). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "modules/serviceworkers/ServiceWorkerClients.h" 6 #include "modules/serviceworkers/ServiceWorkerClients.h"
7 7
8 #include "bindings/core/v8/CallbackPromiseAdapter.h" 8 #include "bindings/core/v8/CallbackPromiseAdapter.h"
9 #include "bindings/core/v8/ScriptPromiseResolver.h" 9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "core/dom/ExceptionCode.h" 10 #include "core/dom/ExceptionCode.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 if (options.type() != "window") { 66 if (options.type() != "window") {
67 // FIXME: Currently we only support WindowClients. 67 // FIXME: Currently we only support WindowClients.
68 resolver->reject(DOMException::create(NotSupportedError, "type parameter of getAll is not supported.")); 68 resolver->reject(DOMException::create(NotSupportedError, "type parameter of getAll is not supported."));
69 return promise; 69 return promise;
70 } 70 }
71 71
72 ServiceWorkerGlobalScopeClient::from(scriptState->executionContext())->getCl ients(new CallbackPromiseAdapter<ClientArray, ServiceWorkerError>(resolver)); 72 ServiceWorkerGlobalScopeClient::from(scriptState->executionContext())->getCl ients(new CallbackPromiseAdapter<ClientArray, ServiceWorkerError>(resolver));
73 return promise; 73 return promise;
74 } 74 }
75 75
76 ScriptPromise ServiceWorkerClients::claim(ScriptState* scriptState)
77 {
78 ExecutionContext* executionContext = scriptState->executionContext();
79
80 // FIXME: May be null due to worker termination: http://crbug.coma/413518.
81 if (!executionContext)
82 return ScriptPromise();
83
84 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState);
85 ScriptPromise promise = resolver->promise();
86
87 WebServiceWorkerClientsClaimCallbacks* callbacks = new CallbackPromiseAdapte r<void, ServiceWorkerError>(resolver);
88 ServiceWorkerGlobalScopeClient::from(executionContext)->claim(callbacks);
89 return promise;
90 }
91
76 } // namespace blink 92 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/serviceworkers/ServiceWorkerClients.h ('k') | Source/modules/serviceworkers/ServiceWorkerError.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698