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 |