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

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

Issue 1439333002: Service Worker: Add Clients.get(id) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add layout test Created 4 years, 11 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
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 "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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 ServiceWorkerClients* ServiceWorkerClients::create() 65 ServiceWorkerClients* ServiceWorkerClients::create()
66 { 66 {
67 return new ServiceWorkerClients(); 67 return new ServiceWorkerClients();
68 } 68 }
69 69
70 ServiceWorkerClients::ServiceWorkerClients() 70 ServiceWorkerClients::ServiceWorkerClients()
71 { 71 {
72 } 72 }
73 73
74 ScriptPromise ServiceWorkerClients::get(ScriptState* scriptState, const String& id)
75 {
76 ExecutionContext* executionContext = scriptState->executionContext();
77 // FIXME: May be null due to worker termination: http://crbug.com/413518.
78 if (!executionContext)
79 return ScriptPromise();
80
81 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
82 ScriptPromise promise = resolver->promise();
83
84 // TODO(jungkees): Use ServiceWorkerClient for typename S of CallBackPromise Adpater.
zino 2016/01/04 09:05:27 I'm not sure but you are already done?
85 ServiceWorkerGlobalScopeClient::from(executionContext)->getClient(id, new Ca llbackPromiseAdapter<ServiceWorkerClient, ServiceWorkerError>(resolver));
86 return promise;
87 }
88
74 ScriptPromise ServiceWorkerClients::matchAll(ScriptState* scriptState, const Cli entQueryOptions& options) 89 ScriptPromise ServiceWorkerClients::matchAll(ScriptState* scriptState, const Cli entQueryOptions& options)
75 { 90 {
76 ExecutionContext* executionContext = scriptState->executionContext(); 91 ExecutionContext* executionContext = scriptState->executionContext();
77 // FIXME: May be null due to worker termination: http://crbug.com/413518. 92 // FIXME: May be null due to worker termination: http://crbug.com/413518.
78 if (!executionContext) 93 if (!executionContext)
79 return ScriptPromise(); 94 return ScriptPromise();
80 95
81 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 96 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
82 ScriptPromise promise = resolver->promise(); 97 ScriptPromise promise = resolver->promise();
83 98
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 resolver->reject(DOMException::create(InvalidAccessError, "Not allowed t o open a window.")); 140 resolver->reject(DOMException::create(InvalidAccessError, "Not allowed t o open a window."));
126 return promise; 141 return promise;
127 } 142 }
128 context->consumeWindowInteraction(); 143 context->consumeWindowInteraction();
129 144
130 ServiceWorkerGlobalScopeClient::from(context)->openWindow(parsedUrl, new Nav igateClientCallback(resolver)); 145 ServiceWorkerGlobalScopeClient::from(context)->openWindow(parsedUrl, new Nav igateClientCallback(resolver));
131 return promise; 146 return promise;
132 } 147 }
133 148
134 } // namespace blink 149 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698