| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 void onSuccess(std::unique_ptr<WebServiceWorkerClientInfo> webClient) overri
de | 69 void onSuccess(std::unique_ptr<WebServiceWorkerClientInfo> webClient) overri
de |
| 70 { | 70 { |
| 71 OwnPtr<WebServiceWorkerClientInfo> client = adoptPtr(webClient.release()
); | 71 OwnPtr<WebServiceWorkerClientInfo> client = adoptPtr(webClient.release()
); |
| 72 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContex
t()->activeDOMObjectsAreStopped()) | 72 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContex
t()->activeDOMObjectsAreStopped()) |
| 73 return; | 73 return; |
| 74 if (!client) { | 74 if (!client) { |
| 75 // Resolve the promise with undefined. | 75 // Resolve the promise with undefined. |
| 76 m_resolver->resolve(); | 76 m_resolver->resolve(); |
| 77 return; | 77 return; |
| 78 } | 78 } |
| 79 m_resolver->resolve(ServiceWorkerClient::take(m_resolver, client.release
())); | 79 m_resolver->resolve(ServiceWorkerClient::take(m_resolver, std::move(clie
nt))); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void onError(const WebServiceWorkerError& error) override | 82 void onError(const WebServiceWorkerError& error) override |
| 83 { | 83 { |
| 84 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContex
t()->activeDOMObjectsAreStopped()) | 84 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContex
t()->activeDOMObjectsAreStopped()) |
| 85 return; | 85 return; |
| 86 m_resolver->reject(ServiceWorkerError::take(m_resolver.get(), error)); | 86 m_resolver->reject(ServiceWorkerError::take(m_resolver.get(), error)); |
| 87 } | 87 } |
| 88 | 88 |
| 89 private: | 89 private: |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 resolver->reject(DOMException::create(InvalidAccessError, "Not allowed t
o open a window.")); | 170 resolver->reject(DOMException::create(InvalidAccessError, "Not allowed t
o open a window.")); |
| 171 return promise; | 171 return promise; |
| 172 } | 172 } |
| 173 context->consumeWindowInteraction(); | 173 context->consumeWindowInteraction(); |
| 174 | 174 |
| 175 ServiceWorkerGlobalScopeClient::from(context)->openWindow(parsedUrl, new Nav
igateClientCallback(resolver)); | 175 ServiceWorkerGlobalScopeClient::from(context)->openWindow(parsedUrl, new Nav
igateClientCallback(resolver)); |
| 176 return promise; | 176 return promise; |
| 177 } | 177 } |
| 178 | 178 |
| 179 } // namespace blink | 179 } // namespace blink |
| OLD | NEW |