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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 98 |
99 ServiceWorkerClients* ServiceWorkerClients::create() { | 99 ServiceWorkerClients* ServiceWorkerClients::create() { |
100 return new ServiceWorkerClients(); | 100 return new ServiceWorkerClients(); |
101 } | 101 } |
102 | 102 |
103 ServiceWorkerClients::ServiceWorkerClients() {} | 103 ServiceWorkerClients::ServiceWorkerClients() {} |
104 | 104 |
105 ScriptPromise ServiceWorkerClients::get(ScriptState* scriptState, | 105 ScriptPromise ServiceWorkerClients::get(ScriptState* scriptState, |
106 const String& id) { | 106 const String& id) { |
107 ExecutionContext* executionContext = scriptState->getExecutionContext(); | 107 ExecutionContext* executionContext = scriptState->getExecutionContext(); |
108 // TODO(jungkees): May be null due to worker termination: http://crbug.com/413
518. | 108 // TODO(jungkees): May be null due to worker termination: |
| 109 // http://crbug.com/413518. |
109 if (!executionContext) | 110 if (!executionContext) |
110 return ScriptPromise(); | 111 return ScriptPromise(); |
111 | 112 |
112 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); | 113 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
113 ScriptPromise promise = resolver->promise(); | 114 ScriptPromise promise = resolver->promise(); |
114 | 115 |
115 ServiceWorkerGlobalScopeClient::from(executionContext) | 116 ServiceWorkerGlobalScopeClient::from(executionContext) |
116 ->getClient(id, new GetCallback(resolver)); | 117 ->getClient(id, new GetCallback(resolver)); |
117 return promise; | 118 return promise; |
118 } | 119 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 return promise; | 181 return promise; |
181 } | 182 } |
182 context->consumeWindowInteraction(); | 183 context->consumeWindowInteraction(); |
183 | 184 |
184 ServiceWorkerGlobalScopeClient::from(context)->openWindow( | 185 ServiceWorkerGlobalScopeClient::from(context)->openWindow( |
185 parsedUrl, new NavigateClientCallback(resolver)); | 186 parsedUrl, new NavigateClientCallback(resolver)); |
186 return promise; | 187 return promise; |
187 } | 188 } |
188 | 189 |
189 } // namespace blink | 190 } // namespace blink |
OLD | NEW |