OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 14 matching lines...) Expand all Loading... |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 #include "config.h" | 30 #include "config.h" |
31 #include "modules/serviceworkers/ServiceWorkerContainer.h" | 31 #include "modules/serviceworkers/ServiceWorkerContainer.h" |
32 | 32 |
33 #include "RuntimeEnabledFeatures.h" | 33 #include "RuntimeEnabledFeatures.h" |
34 #include "bindings/v8/CallbackPromiseAdapter.h" | 34 #include "bindings/v8/CallbackPromiseAdapter.h" |
| 35 #include "bindings/v8/ScriptPromise.h" |
35 #include "bindings/v8/ScriptPromiseResolverWithContext.h" | 36 #include "bindings/v8/ScriptPromiseResolverWithContext.h" |
36 #include "bindings/v8/ScriptState.h" | 37 #include "bindings/v8/ScriptState.h" |
37 #include "bindings/v8/SerializedScriptValue.h" | 38 #include "bindings/v8/SerializedScriptValue.h" |
38 #include "core/dom/DOMException.h" | 39 #include "core/dom/DOMException.h" |
39 #include "core/dom/Document.h" | 40 #include "core/dom/Document.h" |
40 #include "core/dom/ExceptionCode.h" | 41 #include "core/dom/ExceptionCode.h" |
41 #include "core/dom/ExecutionContext.h" | 42 #include "core/dom/ExecutionContext.h" |
42 #include "core/dom/MessagePort.h" | 43 #include "core/dom/MessagePort.h" |
43 #include "core/events/MessageEvent.h" | 44 #include "core/events/MessageEvent.h" |
44 #include "modules/serviceworkers/RegistrationOptionList.h" | 45 #include "modules/serviceworkers/RegistrationOptionList.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 patternURL.removeFragmentIdentifier(); | 135 patternURL.removeFragmentIdentifier(); |
135 if (!pattern.isEmpty() && !documentOrigin->canRequest(patternURL)) { | 136 if (!pattern.isEmpty() && !documentOrigin->canRequest(patternURL)) { |
136 resolver->reject(DOMException::create(SecurityError, "Can only unregiste
r for patterns in the document's origin.")); | 137 resolver->reject(DOMException::create(SecurityError, "Can only unregiste
r for patterns in the document's origin.")); |
137 return promise; | 138 return promise; |
138 } | 139 } |
139 | 140 |
140 m_provider->unregisterServiceWorker(patternURL, new CallbackPromiseAdapter<U
ndefinedValue, ServiceWorkerError>(resolver)); | 141 m_provider->unregisterServiceWorker(patternURL, new CallbackPromiseAdapter<U
ndefinedValue, ServiceWorkerError>(resolver)); |
141 return promise; | 142 return promise; |
142 } | 143 } |
143 | 144 |
| 145 ScriptPromise ServiceWorkerContainer::ready(ScriptState* scriptState) |
| 146 { |
| 147 if (m_controller.get()) { |
| 148 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(s
criptState); |
| 149 ScriptPromise promise = resolver->promise(); |
| 150 resolver->resolve(m_controller.get()); |
| 151 return promise; |
| 152 } |
| 153 // FIXME: Elaborate the implementation when the "waiting" property |
| 154 // or replace() is implemented. |
| 155 return ScriptPromise(); |
| 156 } |
| 157 |
144 void ServiceWorkerContainer::setCurrentServiceWorker(blink::WebServiceWorker* se
rviceWorker) | 158 void ServiceWorkerContainer::setCurrentServiceWorker(blink::WebServiceWorker* se
rviceWorker) |
145 { | 159 { |
146 setController(serviceWorker); | 160 setController(serviceWorker); |
147 } | 161 } |
148 | 162 |
149 void ServiceWorkerContainer::setController(blink::WebServiceWorker* serviceWorke
r) | 163 void ServiceWorkerContainer::setController(blink::WebServiceWorker* serviceWorke
r) |
150 { | 164 { |
151 if (!executionContext()) { | 165 if (!executionContext()) { |
152 delete serviceWorker; | 166 delete serviceWorker; |
153 return; | 167 return; |
(...skipping 22 matching lines...) Expand all Loading... |
176 return; | 190 return; |
177 | 191 |
178 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro
m(executionContext)) { | 192 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro
m(executionContext)) { |
179 m_provider = client->provider(); | 193 m_provider = client->provider(); |
180 if (m_provider) | 194 if (m_provider) |
181 m_provider->setClient(this); | 195 m_provider->setClient(this); |
182 } | 196 } |
183 } | 197 } |
184 | 198 |
185 } // namespace WebCore | 199 } // namespace WebCore |
OLD | NEW |