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/v8/CallbackPromiseAdapter.h" | 8 #include "bindings/v8/CallbackPromiseAdapter.h" |
9 #include "bindings/v8/NewScriptState.h" | |
10 #include "bindings/v8/ScriptPromise.h" | |
11 #include "bindings/v8/ScriptPromiseResolver.h" | 9 #include "bindings/v8/ScriptPromiseResolver.h" |
12 #include "bindings/v8/ScriptPromiseResolverWithContext.h" | 10 #include "bindings/v8/ScriptPromiseResolverWithContext.h" |
13 #include "modules/serviceworkers/Client.h" | 11 #include "modules/serviceworkers/Client.h" |
14 #include "modules/serviceworkers/ServiceWorkerError.h" | 12 #include "modules/serviceworkers/ServiceWorkerError.h" |
15 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" | 13 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" |
16 #include "public/platform/WebServiceWorkerClientsInfo.h" | 14 #include "public/platform/WebServiceWorkerClientsInfo.h" |
17 #include "wtf/RefPtr.h" | 15 #include "wtf/RefPtr.h" |
18 #include "wtf/Vector.h" | 16 #include "wtf/Vector.h" |
19 | 17 |
20 namespace WebCore { | 18 namespace WebCore { |
21 | 19 |
22 namespace { | 20 namespace { |
23 | 21 |
24 class ClientArray { | 22 class ClientArray { |
25 public: | 23 public: |
26 typedef blink::WebServiceWorkerClientsInfo WebType; | 24 typedef blink::WebServiceWorkerClientsInfo WebType; |
27 static Vector<RefPtr<Client> > from(NewScriptState*, WebType* webClients
Raw) | 25 static Vector<RefPtr<Client> > from(ScriptPromiseResolverWithContext*, W
ebType* webClientsRaw) |
28 { | 26 { |
29 OwnPtr<WebType> webClients = adoptPtr(webClientsRaw); | 27 OwnPtr<WebType> webClients = adoptPtr(webClientsRaw); |
30 Vector<RefPtr<Client> > clients; | 28 Vector<RefPtr<Client> > clients; |
31 for (size_t i = 0; i < webClients->clientIDs.size(); ++i) { | 29 for (size_t i = 0; i < webClients->clientIDs.size(); ++i) { |
32 clients.append(Client::create(webClients->clientIDs[i])); | 30 clients.append(Client::create(webClients->clientIDs[i])); |
33 } | 31 } |
34 return clients; | 32 return clients; |
35 } | 33 } |
36 | 34 |
37 private: | 35 private: |
(...skipping 18 matching lines...) Expand all Loading... |
56 } | 54 } |
57 | 55 |
58 ScriptPromise ServiceWorkerClients::getServiced(ExecutionContext* context) | 56 ScriptPromise ServiceWorkerClients::getServiced(ExecutionContext* context) |
59 { | 57 { |
60 RefPtr<ScriptPromiseResolverWithContext> resolver = ScriptPromiseResolverWit
hContext::create(NewScriptState::current(toIsolate(context))); | 58 RefPtr<ScriptPromiseResolverWithContext> resolver = ScriptPromiseResolverWit
hContext::create(NewScriptState::current(toIsolate(context))); |
61 ServiceWorkerGlobalScopeClient::from(context)->getClients(new CallbackPromis
eAdapter<ClientArray, ServiceWorkerError>(resolver)); | 59 ServiceWorkerGlobalScopeClient::from(context)->getClients(new CallbackPromis
eAdapter<ClientArray, ServiceWorkerError>(resolver)); |
62 return resolver->promise(); | 60 return resolver->promise(); |
63 } | 61 } |
64 | 62 |
65 } // namespace WebCore | 63 } // namespace WebCore |
OLD | NEW |