Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: Source/modules/serviceworkers/ServiceWorkerClients.cpp

Issue 247263010: ServiceWorker: Wait for registration promise to resolve before changing states. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: yhirano comments Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698