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

Unified Diff: Source/modules/serviceworkers/ServiceWorkerClients.cpp

Issue 958933004: ServiceWorker: plumbing for ClientQueryOptions (1/2, blink) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/modules/serviceworkers/ServiceWorkerGlobalScopeClient.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/serviceworkers/ServiceWorkerClients.cpp
diff --git a/Source/modules/serviceworkers/ServiceWorkerClients.cpp b/Source/modules/serviceworkers/ServiceWorkerClients.cpp
index cd8927c737b2621a7b0cef2106999cd7d6667302..cb15214cdb0457344b218ce07a643314c783f57a 100644
--- a/Source/modules/serviceworkers/ServiceWorkerClients.cpp
+++ b/Source/modules/serviceworkers/ServiceWorkerClients.cpp
@@ -13,6 +13,7 @@
#include "modules/serviceworkers/ServiceWorkerError.h"
#include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h"
#include "modules/serviceworkers/ServiceWorkerWindowClient.h"
+#include "public/platform/WebServiceWorkerClientQueryOptions.h"
#include "public/platform/WebServiceWorkerClientsInfo.h"
#include "wtf/RefPtr.h"
#include "wtf/Vector.h"
@@ -21,27 +22,43 @@ namespace blink {
namespace {
- class ClientArray {
- public:
- typedef blink::WebServiceWorkerClientsInfo WebType;
- static HeapVector<Member<ServiceWorkerClient>> take(ScriptPromiseResolver*, WebType* webClientsRaw)
- {
- OwnPtr<WebType> webClients = adoptPtr(webClientsRaw);
- HeapVector<Member<ServiceWorkerClient>> clients;
- for (size_t i = 0; i < webClients->clients.size(); ++i) {
- clients.append(ServiceWorkerWindowClient::create(webClients->clients[i]));
- }
- return clients;
- }
- static void dispose(WebType* webClientsRaw)
- {
- delete webClientsRaw;
+class ClientArray {
+public:
+ typedef blink::WebServiceWorkerClientsInfo WebType;
+ static HeapVector<Member<ServiceWorkerClient>> take(ScriptPromiseResolver*, WebType* webClientsRaw)
+ {
+ OwnPtr<WebType> webClients = adoptPtr(webClientsRaw);
+ HeapVector<Member<ServiceWorkerClient>> clients;
+ for (size_t i = 0; i < webClients->clients.size(); ++i) {
+ // FIXME: For now we only support getting "window" type clients.
+ ASSERT(webClients->clients[i].clientType == WebServiceWorkerClientTypeWindow);
+ clients.append(ServiceWorkerWindowClient::create(webClients->clients[i]));
}
+ return clients;
+ }
+ static void dispose(WebType* webClientsRaw)
+ {
+ delete webClientsRaw;
+ }
- private:
- WTF_MAKE_NONCOPYABLE(ClientArray);
- ClientArray() = delete;
- };
+private:
+ WTF_MAKE_NONCOPYABLE(ClientArray);
+ ClientArray() = delete;
+};
+
+WebServiceWorkerClientType getClientType(const String& type)
+{
+ if (type == "window")
+ return WebServiceWorkerClientTypeWindow;
+ if (type == "worker")
+ return WebServiceWorkerClientTypeWorker;
+ if (type == "sharedworker")
+ return WebServiceWorkerClientTypeSharedWorker;
+ if (type == "all")
+ return WebServiceWorkerClientTypeAll;
+ ASSERT_NOT_REACHED();
+ return WebServiceWorkerClientTypeWindow;
+}
} // namespace
@@ -65,18 +82,21 @@ ScriptPromise ServiceWorkerClients::matchAll(ScriptState* scriptState, const Cli
ScriptPromise promise = resolver->promise();
if (options.includeUncontrolled()) {
- // FIXME: Currently we don't support includeUncontrolled=true.
+ // FIXME: Remove this when query options are supported in the embedder.
resolver->reject(DOMException::create(NotSupportedError, "includeUncontrolled parameter of getAll is not supported."));
return promise;
}
if (options.type() != "window") {
- // FIXME: Currently we only support WindowClients.
+ // FIXME: Remove this when query options are supported in the embedder.
resolver->reject(DOMException::create(NotSupportedError, "type parameter of getAll is not supported."));
return promise;
}
- ServiceWorkerGlobalScopeClient::from(executionContext)->getClients(new CallbackPromiseAdapter<ClientArray, ServiceWorkerError>(resolver));
+ WebServiceWorkerClientQueryOptions webOptions;
+ webOptions.clientType = getClientType(options.type());
+ webOptions.includeUncontrolled = options.includeUncontrolled();
+ ServiceWorkerGlobalScopeClient::from(executionContext)->getClients(webOptions, new CallbackPromiseAdapter<ClientArray, ServiceWorkerError>(resolver));
return promise;
}
« no previous file with comments | « no previous file | Source/modules/serviceworkers/ServiceWorkerGlobalScopeClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698