| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 ASSERT_NOT_REACHED(); | 59 ASSERT_NOT_REACHED(); |
| 60 return WebServiceWorkerClientTypeWindow; | 60 return WebServiceWorkerClientTypeWindow; |
| 61 } | 61 } |
| 62 | 62 |
| 63 class GetCallback : public WebServiceWorkerClientCallbacks { | 63 class GetCallback : public WebServiceWorkerClientCallbacks { |
| 64 public: | 64 public: |
| 65 explicit GetCallback(ScriptPromiseResolver* resolver) | 65 explicit GetCallback(ScriptPromiseResolver* resolver) |
| 66 : m_resolver(resolver) { } | 66 : m_resolver(resolver) { } |
| 67 ~GetCallback() override { } | 67 ~GetCallback() override { } |
| 68 | 68 |
| 69 void onSuccess(WebPassOwnPtr<WebServiceWorkerClientInfo> webClient) override | 69 void onSuccess(std::unique_ptr<WebServiceWorkerClientInfo> webClient) overri
de |
| 70 { | 70 { |
| 71 OwnPtr<WebServiceWorkerClientInfo> client = 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, client.release
())); |
| 80 } | 80 } |
| 81 | 81 |
| (...skipping 88 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 |