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

Unified Diff: content/renderer/service_worker/service_worker_context_client.cc

Issue 1439333002: Service Worker: Add Clients.get(id) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unnecessary condition Created 4 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
Index: content/renderer/service_worker/service_worker_context_client.cc
diff --git a/content/renderer/service_worker/service_worker_context_client.cc b/content/renderer/service_worker/service_worker_context_client.cc
index 5d0f45bf51830a5d3836fb0453b83955e101fb8d..c4563824ff1ce9c577ffaef9241fa25e4f67fd04 100644
--- a/content/renderer/service_worker/service_worker_context_client.cc
+++ b/content/renderer/service_worker/service_worker_context_client.cc
@@ -266,6 +266,7 @@ void ServiceWorkerContextClient::OnMessageReceived(
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_MessageToWorker, OnPostMessage)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_CrossOriginMessageToWorker,
OnCrossOriginMessageToWorker)
+ IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidGetClient, OnDidGetClient)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidGetClients, OnDidGetClients)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_OpenWindowResponse,
OnOpenWindowResponse)
@@ -298,6 +299,15 @@ blink::WebURL ServiceWorkerContextClient::scope() const {
return service_worker_scope_;
}
+void ServiceWorkerContextClient::getClient(
+ const blink::WebString& id,
+ blink::WebServiceWorkerClientCallbacks* callbacks) {
+ DCHECK(callbacks);
+ int request_id = context_->client_callbacks.Add(callbacks);
+ Send(new ServiceWorkerHostMsg_GetClient(
+ GetRoutingID(), request_id, base::UTF16ToUTF8(base::StringPiece16(id))));
+}
+
void ServiceWorkerContextClient::getClients(
const blink::WebServiceWorkerClientQueryOptions& weboptions,
blink::WebServiceWorkerClientsCallbacks* callbacks) {
@@ -872,6 +882,26 @@ void ServiceWorkerContextClient::OnCrossOriginMessageToWorker(
proxy_->dispatchCrossOriginMessageEvent(web_client, message, ports);
}
+void ServiceWorkerContextClient::OnDidGetClient(
+ int request_id,
+ const ServiceWorkerClientInfo& client) {
+ TRACE_EVENT0("ServiceWorker", "ServiceWorkerContextClient::OnDidGetClient");
+ blink::WebServiceWorkerClientCallbacks* callbacks =
+ context_->client_callbacks.Lookup(request_id);
+ if (!callbacks) {
+ NOTREACHED() << "Got stray response: " << request_id;
+ return;
+ }
+ scoped_ptr<blink::WebServiceWorkerClientInfo> web_client;
+ if (!client.IsEmpty()) {
+ DCHECK(client.IsValid());
+ web_client.reset(new blink::WebServiceWorkerClientInfo(
+ ToWebServiceWorkerClientInfo(client)));
+ }
+ callbacks->onSuccess(blink::adoptWebPtr(web_client.release()));
+ context_->client_callbacks.Remove(request_id);
+}
+
void ServiceWorkerContextClient::OnDidGetClients(
int request_id, const std::vector<ServiceWorkerClientInfo>& clients) {
TRACE_EVENT0("ServiceWorker",
@@ -909,7 +939,7 @@ void ServiceWorkerContextClient::OnOpenWindowResponse(
web_client.reset(new blink::WebServiceWorkerClientInfo(
ToWebServiceWorkerClientInfo(client)));
}
- callbacks->onSuccess(adoptWebPtr(web_client.release()));
+ callbacks->onSuccess(blink::adoptWebPtr(web_client.release()));
context_->client_callbacks.Remove(request_id);
}
@@ -945,7 +975,7 @@ void ServiceWorkerContextClient::OnFocusClientResponse(
scoped_ptr<blink::WebServiceWorkerClientInfo> web_client (
new blink::WebServiceWorkerClientInfo(
ToWebServiceWorkerClientInfo(client)));
- callback->onSuccess(adoptWebPtr(web_client.release()));
+ callback->onSuccess(blink::adoptWebPtr(web_client.release()));
} else {
callback->onError(blink::WebServiceWorkerError(
blink::WebServiceWorkerError::ErrorTypeNotFound,
@@ -972,7 +1002,7 @@ void ServiceWorkerContextClient::OnNavigateClientResponse(
web_client.reset(new blink::WebServiceWorkerClientInfo(
ToWebServiceWorkerClientInfo(client)));
}
- callbacks->onSuccess(adoptWebPtr(web_client.release()));
+ callbacks->onSuccess(blink::adoptWebPtr(web_client.release()));
context_->client_callbacks.Remove(request_id);
}

Powered by Google App Engine
This is Rietveld 408576698