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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 63 |
64 class GetCallback : public WebServiceWorkerClientCallbacks { | 64 class GetCallback : public WebServiceWorkerClientCallbacks { |
65 public: | 65 public: |
66 explicit GetCallback(ScriptPromiseResolver* resolver) | 66 explicit GetCallback(ScriptPromiseResolver* resolver) |
67 : m_resolver(resolver) {} | 67 : m_resolver(resolver) {} |
68 ~GetCallback() override {} | 68 ~GetCallback() override {} |
69 | 69 |
70 void onSuccess( | 70 void onSuccess( |
71 std::unique_ptr<WebServiceWorkerClientInfo> webClient) override { | 71 std::unique_ptr<WebServiceWorkerClientInfo> webClient) override { |
72 std::unique_ptr<WebServiceWorkerClientInfo> client = | 72 std::unique_ptr<WebServiceWorkerClientInfo> client = |
73 wrapUnique(webClient.release()); | 73 WTF::wrapUnique(webClient.release()); |
74 if (!m_resolver->getExecutionContext() || | 74 if (!m_resolver->getExecutionContext() || |
75 m_resolver->getExecutionContext()->isContextDestroyed()) | 75 m_resolver->getExecutionContext()->isContextDestroyed()) |
76 return; | 76 return; |
77 if (!client) { | 77 if (!client) { |
78 // Resolve the promise with undefined. | 78 // Resolve the promise with undefined. |
79 m_resolver->resolve(); | 79 m_resolver->resolve(); |
80 return; | 80 return; |
81 } | 81 } |
82 m_resolver->resolve( | 82 m_resolver->resolve( |
83 ServiceWorkerClient::take(m_resolver, std::move(client))); | 83 ServiceWorkerClient::take(m_resolver, std::move(client))); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 return promise; | 185 return promise; |
186 } | 186 } |
187 context->consumeWindowInteraction(); | 187 context->consumeWindowInteraction(); |
188 | 188 |
189 ServiceWorkerGlobalScopeClient::from(context)->openWindow( | 189 ServiceWorkerGlobalScopeClient::from(context)->openWindow( |
190 parsedUrl, WTF::makeUnique<NavigateClientCallback>(resolver)); | 190 parsedUrl, WTF::makeUnique<NavigateClientCallback>(resolver)); |
191 return promise; | 191 return promise; |
192 } | 192 } |
193 | 193 |
194 } // namespace blink | 194 } // namespace blink |
OLD | NEW |