| Index: Source/modules/serviceworkers/ServiceWorkerClients.cpp
|
| diff --git a/Source/modules/serviceworkers/ServiceWorkerClients.cpp b/Source/modules/serviceworkers/ServiceWorkerClients.cpp
|
| index cd8927c737b2621a7b0cef2106999cd7d6667302..32eeb2ece333c369ea597b245d2cc756ca13ba3f 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,41 @@ 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) {
|
| + 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 +80,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;
|
| }
|
|
|
|
|