OLD | NEW |
---|---|
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 Loading... | |
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 | |
falken
2015/01/27 03:25:18
typo: .coma
xiang
2015/01/28 05:57:49
Done.
| |
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 |
OLD | NEW |