| 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 "config.h" | 5 #include "config.h" |
| 6 #include "modules/serviceworkers/ServiceWorkerClients.h" | 6 #include "modules/serviceworkers/ServiceWorkerClients.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 10 #include "core/dom/ExceptionCode.h" | 10 #include "core/dom/ExceptionCode.h" |
| 11 #include "modules/serviceworkers/ServiceWorkerClient.h" | 11 #include "modules/serviceworkers/ServiceWorkerClient.h" |
| 12 #include "modules/serviceworkers/ServiceWorkerError.h" | 12 #include "modules/serviceworkers/ServiceWorkerError.h" |
| 13 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" | 13 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" |
| 14 #include "public/platform/WebServiceWorkerClientsInfo.h" | 14 #include "public/platform/WebServiceWorkerClientsInfo.h" |
| 15 #include "wtf/RefPtr.h" | 15 #include "wtf/RefPtr.h" |
| 16 #include "wtf/Vector.h" | 16 #include "wtf/Vector.h" |
| 17 | 17 |
| 18 namespace blink { | 18 namespace blink { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 class ClientArray { | 22 class ClientArray { |
| 23 public: | 23 public: |
| 24 typedef blink::WebServiceWorkerClientsInfo WebType; | 24 typedef blink::WebServiceWorkerClientsInfo WebType; |
| 25 static HeapVector<Member<ServiceWorkerClient> > take(ScriptPromiseResolv
er*, WebType* webClientsRaw) | 25 static HeapVector<Member<ServiceWorkerClient> > take(ScriptPromiseResolv
er*, WebType* webClientsRaw) |
| 26 { | 26 { |
| 27 OwnPtr<WebType> webClients = adoptPtr(webClientsRaw); | 27 OwnPtr<WebType> webClients = adoptPtr(webClientsRaw); |
| 28 HeapVector<Member<ServiceWorkerClient> > clients; | 28 HeapVector<Member<ServiceWorkerClient> > clients; |
| 29 for (size_t i = 0; i < webClients->clients.size(); ++i) { | 29 for (size_t i = 0; i < webClients->clients.size(); ++i) { |
| 30 clients.append(ServiceWorkerClient::create(webClients->clients[i
].clientID)); | 30 clients.append(ServiceWorkerClient::create(webClients->clients[i
])); |
| 31 } | |
| 32 for (size_t i = 0; i < webClients->clientIDs.size(); ++i) { | |
| 33 clients.append(ServiceWorkerClient::create(webClients->clientIDs
[i])); | |
| 34 } | 31 } |
| 35 return clients; | 32 return clients; |
| 36 } | 33 } |
| 37 static void dispose(WebType* webClientsRaw) | 34 static void dispose(WebType* webClientsRaw) |
| 38 { | 35 { |
| 39 delete webClientsRaw; | 36 delete webClientsRaw; |
| 40 } | 37 } |
| 41 | 38 |
| 42 private: | 39 private: |
| 43 WTF_MAKE_NONCOPYABLE(ClientArray); | 40 WTF_MAKE_NONCOPYABLE(ClientArray); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 64 // FIXME: Currently we don't support includeUncontrolled=true. | 61 // FIXME: Currently we don't support includeUncontrolled=true. |
| 65 resolver->reject(DOMException::create(NotSupportedError, "includeUncontr
olled parameter of getAll is not supported.")); | 62 resolver->reject(DOMException::create(NotSupportedError, "includeUncontr
olled parameter of getAll is not supported.")); |
| 66 return promise; | 63 return promise; |
| 67 } | 64 } |
| 68 | 65 |
| 69 ServiceWorkerGlobalScopeClient::from(scriptState->executionContext())->getCl
ients(new CallbackPromiseAdapter<ClientArray, ServiceWorkerError>(resolver)); | 66 ServiceWorkerGlobalScopeClient::from(scriptState->executionContext())->getCl
ients(new CallbackPromiseAdapter<ClientArray, ServiceWorkerError>(resolver)); |
| 70 return promise; | 67 return promise; |
| 71 } | 68 } |
| 72 | 69 |
| 73 } // namespace blink | 70 } // namespace blink |
| OLD | NEW |