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

Unified Diff: content/browser/service_worker/service_worker_client_utils.cc

Issue 1439333002: Service Worker: Add Clients.get(id) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/service_worker/service_worker_client_utils.cc
diff --git a/content/browser/service_worker/service_worker_client_utils.cc b/content/browser/service_worker/service_worker_client_utils.cc
index 26ef4d35f181bd9a43c4bb5922c5698da78e6aa3..3462a08c8013397f59385f7c3590639ef010d86b 100644
--- a/content/browser/service_worker/service_worker_client_utils.cc
+++ b/content/browser/service_worker/service_worker_client_utils.cc
@@ -225,12 +225,11 @@ void AddNonWindowClient(ServiceWorkerProviderHost* host,
options.client_type != host_client_type)
return;
- ServiceWorkerClientInfo client_info(blink::WebPageVisibilityStateHidden,
- false, // is_focused
- host->document_url(),
- REQUEST_CONTEXT_FRAME_TYPE_NONE,
- base::TimeTicks(), host_client_type);
- client_info.client_uuid = host->client_uuid();
+ ServiceWorkerClientInfo client_info(
+ host->client_uuid(), blink::WebPageVisibilityStateHidden,
+ false, // is_focused
+ host->document_url(), REQUEST_CONTEXT_FRAME_TYPE_NONE, base::TimeTicks(),
+ host_client_type);
clients->push_back(client_info);
}
@@ -243,8 +242,8 @@ void OnGetWindowClientsOnUI(
for (const auto& it : clients_info) {
ServiceWorkerClientInfo info =
- ServiceWorkerProviderHost::GetWindowClientInfoOnUI(base::get<0>(it),
- base::get<1>(it));
+ ServiceWorkerProviderHost::GetWindowClientInfoOnUI(
+ base::get<0>(it), base::get<1>(it), base::get<2>(it));
// If the request to the provider_host returned an empty
// ServiceWorkerClientInfo, that means that it wasn't possible to associate
@@ -259,7 +258,6 @@ void OnGetWindowClientsOnUI(
if (info.url.GetOrigin() != script_url.GetOrigin())
continue;
- info.client_uuid = base::get<2>(it);
clients->push_back(info);
}
@@ -274,6 +272,13 @@ struct ServiceWorkerClientInfoSortMRU {
}
};
+void DidGetClient(const ClientCallback& callback,
+ const ServiceWorkerClientInfo& client_info) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+
+ callback.Run(client_info);
+}
+
void DidGetClients(const ClientsCallback& callback,
ServiceWorkerClients* clients) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
@@ -371,6 +376,34 @@ void NavigateClient(const GURL& url,
base::Bind(&DidNavigate, context, script_url.GetOrigin(), callback)));
}
+void GetClient(const base::WeakPtr<ServiceWorkerVersion>& controller,
+ const std::string& client_uuid,
+ const base::WeakPtr<ServiceWorkerContextCore>& context,
+ const ClientCallback& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+
+ ServiceWorkerProviderHost* provider_host =
+ context->GetProviderHostByClientID(client_uuid);
+
+ if (!provider_host) {
+ // The client may already have been closed, just ignore.
+ DidGetClient(callback, ServiceWorkerClientInfo());
+ return;
+ }
+
+ if (provider_host->client_type() == blink::WebServiceWorkerClientTypeWindow) {
+ provider_host->GetWindowClientInfo(base::Bind(&DidGetClient, callback));
zino 2016/02/05 06:21:44 If you use GetClientInfoCallback, you can pass cal
jungkees 2016/02/12 15:03:21 Done.
+ return;
+ }
+
+ ServiceWorkerClientInfo client_info(
+ provider_host->client_uuid(), blink::WebPageVisibilityStateHidden,
+ false, // is_focused
+ provider_host->document_url(), REQUEST_CONTEXT_FRAME_TYPE_NONE,
+ base::TimeTicks(), provider_host->client_type());
+ DidGetClient(callback, client_info);
+}
+
void GetClients(const base::WeakPtr<ServiceWorkerVersion>& controller,
const ServiceWorkerClientQueryOptions& options,
const ClientsCallback& callback) {

Powered by Google App Engine
This is Rietveld 408576698