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 "modules/serviceworkers/ServiceWorkerClients.h" | 5 #include "modules/serviceworkers/ServiceWorkerClients.h" |
6 | 6 |
7 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
8 #include "bindings/core/v8/ScriptPromiseResolver.h" | 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
9 #include "core/dom/DOMException.h" | 9 #include "core/dom/DOMException.h" |
10 #include "core/dom/ExceptionCode.h" | 10 #include "core/dom/ExceptionCode.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 | 64 |
65 ServiceWorkerClients* ServiceWorkerClients::create() | 65 ServiceWorkerClients* ServiceWorkerClients::create() |
66 { | 66 { |
67 return new ServiceWorkerClients(); | 67 return new ServiceWorkerClients(); |
68 } | 68 } |
69 | 69 |
70 ServiceWorkerClients::ServiceWorkerClients() | 70 ServiceWorkerClients::ServiceWorkerClients() |
71 { | 71 { |
72 } | 72 } |
73 | 73 |
74 ScriptPromise ServiceWorkerClients::get(ScriptState* scriptState, const String& id) | |
75 { | |
76 ExecutionContext* executionContext = scriptState->executionContext(); | |
77 // FIXME: May be null due to worker termination: http://crbug.com/413518. | |
78 if (!executionContext) | |
79 return ScriptPromise(); | |
80 | |
81 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; | |
82 ScriptPromise promise = resolver->promise(); | |
83 | |
84 // TODO(jungkees): Use ServiceWorkerClient for typename S of CallBackPromise Adpater. | |
zino
2016/01/04 09:05:27
I'm not sure but you are already done?
| |
85 ServiceWorkerGlobalScopeClient::from(executionContext)->getClient(id, new Ca llbackPromiseAdapter<ServiceWorkerClient, ServiceWorkerError>(resolver)); | |
86 return promise; | |
87 } | |
88 | |
74 ScriptPromise ServiceWorkerClients::matchAll(ScriptState* scriptState, const Cli entQueryOptions& options) | 89 ScriptPromise ServiceWorkerClients::matchAll(ScriptState* scriptState, const Cli entQueryOptions& options) |
75 { | 90 { |
76 ExecutionContext* executionContext = scriptState->executionContext(); | 91 ExecutionContext* executionContext = scriptState->executionContext(); |
77 // FIXME: May be null due to worker termination: http://crbug.com/413518. | 92 // FIXME: May be null due to worker termination: http://crbug.com/413518. |
78 if (!executionContext) | 93 if (!executionContext) |
79 return ScriptPromise(); | 94 return ScriptPromise(); |
80 | 95 |
81 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; | 96 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; |
82 ScriptPromise promise = resolver->promise(); | 97 ScriptPromise promise = resolver->promise(); |
83 | 98 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 resolver->reject(DOMException::create(InvalidAccessError, "Not allowed t o open a window.")); | 140 resolver->reject(DOMException::create(InvalidAccessError, "Not allowed t o open a window.")); |
126 return promise; | 141 return promise; |
127 } | 142 } |
128 context->consumeWindowInteraction(); | 143 context->consumeWindowInteraction(); |
129 | 144 |
130 ServiceWorkerGlobalScopeClient::from(context)->openWindow(parsedUrl, new Nav igateClientCallback(resolver)); | 145 ServiceWorkerGlobalScopeClient::from(context)->openWindow(parsedUrl, new Nav igateClientCallback(resolver)); |
131 return promise; | 146 return promise; |
132 } | 147 } |
133 | 148 |
134 } // namespace blink | 149 } // namespace blink |
OLD | NEW |