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/ServiceWorkerError.h" | 11 #include "modules/serviceworkers/ServiceWorkerError.h" |
12 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" | 12 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" |
13 #include "modules/serviceworkers/ServiceWorkerWindowClient.h" | 13 #include "modules/serviceworkers/ServiceWorkerWindowClient.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(ScriptPromiseResolve
r*, 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(ServiceWorkerWindowClient::create(webClients->cli
ents[i])); | 30 clients.append(ServiceWorkerWindowClient::create(webClients->cli
ents[i])); |
31 } | 31 } |
32 return clients; | 32 return clients; |
33 } | 33 } |
34 static void dispose(WebType* webClientsRaw) | 34 static void dispose(WebType* webClientsRaw) |
35 { | 35 { |
36 delete webClientsRaw; | 36 delete webClientsRaw; |
37 } | 37 } |
38 | 38 |
(...skipping 28 matching lines...) Expand all Loading... |
67 // FIXME: Currently we only support WindowClients. | 67 // FIXME: Currently we only support WindowClients. |
68 resolver->reject(DOMException::create(NotSupportedError, "type parameter
of getAll is not supported.")); | 68 resolver->reject(DOMException::create(NotSupportedError, "type parameter
of getAll is not supported.")); |
69 return promise; | 69 return promise; |
70 } | 70 } |
71 | 71 |
72 ServiceWorkerGlobalScopeClient::from(scriptState->executionContext())->getCl
ients(new CallbackPromiseAdapter<ClientArray, ServiceWorkerError>(resolver)); | 72 ServiceWorkerGlobalScopeClient::from(scriptState->executionContext())->getCl
ients(new CallbackPromiseAdapter<ClientArray, ServiceWorkerError>(resolver)); |
73 return promise; | 73 return promise; |
74 } | 74 } |
75 | 75 |
76 } // namespace blink | 76 } // namespace blink |
OLD | NEW |