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

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

Issue 871853002: ServiceWorker: add ServiceWorkerClients.claim() support (2/3). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove assignment within conditional expression 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 | « content/renderer/service_worker/service_worker_script_context.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/service_worker/service_worker_script_context.cc
diff --git a/content/renderer/service_worker/service_worker_script_context.cc b/content/renderer/service_worker/service_worker_script_context.cc
index 9d8acc4467084af6fcc0801e0911e91bf054dc0f..f68a00535f31bd46f1e31b9872b3ca07bc12b1ee 100644
--- a/content/renderer/service_worker/service_worker_script_context.cc
+++ b/content/renderer/service_worker/service_worker_script_context.cc
@@ -106,6 +106,8 @@ void ServiceWorkerScriptContext::OnMessageReceived(
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_FocusClientResponse,
OnFocusClientResponse)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidSkipWaiting, OnDidSkipWaiting)
+ IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidClaimClients, OnDidClaimClients)
+ IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ClaimClientsError, OnClaimClientsError)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -243,6 +245,13 @@ void ServiceWorkerScriptContext::FocusClient(
GetRoutingID(), request_id, client_id));
}
+void ServiceWorkerScriptContext::ClaimClients(
+ blink::WebServiceWorkerClientsClaimCallbacks* callbacks) {
+ DCHECK(callbacks);
+ int request_id = pending_claim_clients_callbacks_.Add(callbacks);
+ Send(new ServiceWorkerHostMsg_ClaimClients(GetRoutingID(), request_id));
+}
+
void ServiceWorkerScriptContext::SkipWaiting(
blink::WebServiceWorkerSkipWaitingCallbacks* callbacks) {
DCHECK(callbacks);
@@ -460,4 +469,35 @@ void ServiceWorkerScriptContext::OnDidSkipWaiting(int request_id) {
pending_skip_waiting_callbacks_.Remove(request_id);
}
+void ServiceWorkerScriptContext::OnDidClaimClients(int request_id) {
+ TRACE_EVENT0("ServiceWorker",
+ "ServiceWorkerScriptContext::OnDidClaimClients");
+ blink::WebServiceWorkerClientsClaimCallbacks* callbacks =
+ pending_claim_clients_callbacks_.Lookup(request_id);
+ if (!callbacks) {
+ NOTREACHED() << "Got stray response: " << request_id;
+ return;
+ }
+ callbacks->onSuccess();
+ pending_claim_clients_callbacks_.Remove(request_id);
+}
+
+void ServiceWorkerScriptContext::OnClaimClientsError(
+ int request_id,
+ blink::WebServiceWorkerError::ErrorType error_type,
+ const base::string16& message) {
+ TRACE_EVENT0("ServiceWorker",
+ "ServiceWorkerScriptContext::OnClaimClientsError");
+ blink::WebServiceWorkerClientsClaimCallbacks* callbacks =
+ pending_claim_clients_callbacks_.Lookup(request_id);
+ if (!callbacks) {
+ NOTREACHED() << "Got stray response: " << request_id;
+ return;
+ }
+ scoped_ptr<blink::WebServiceWorkerError> error(
+ new blink::WebServiceWorkerError(error_type, message));
+ callbacks->onError(error.release());
+ pending_claim_clients_callbacks_.Remove(request_id);
+}
+
} // namespace content
« no previous file with comments | « content/renderer/service_worker/service_worker_script_context.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698