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

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

Issue 717353004: ServiceWorker: Add support for .skipWaiting and controllerchange event(2/3) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review update Created 6 years 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_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 baf906082ca7831063eddee3def52fd9dd97c968..1763ddc03e6f4912e28bd2db6bb920d6977eaa67 100644
--- a/content/renderer/service_worker/service_worker_script_context.cc
+++ b/content/renderer/service_worker/service_worker_script_context.cc
@@ -81,6 +81,7 @@ void ServiceWorkerScriptContext::OnMessageReceived(
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_MessageToWorker, OnPostMessage)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidGetClientDocuments,
OnDidGetClientDocuments)
+ IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidSkipWaiting, OnDidSkipWaiting)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -171,6 +172,13 @@ void ServiceWorkerScriptContext::PostMessageToDocument(
GetRoutingID(), client_id, message, base::Passed(&channels)));
}
+void ServiceWorkerScriptContext::SkipWaiting(
+ blink::WebServiceWorkerSkipWaitingCallbacks* callbacks) {
+ DCHECK(callbacks);
+ int request_id = pending_skip_waiting_callbacks_.Add(callbacks);
+ Send(new ServiceWorkerHostMsg_SkipWaiting(GetRoutingID(), request_id));
+}
+
void ServiceWorkerScriptContext::Send(IPC::Message* message) {
embedded_context_->Send(message);
}
@@ -294,4 +302,15 @@ void ServiceWorkerScriptContext::OnDidGetClientDocuments(
pending_clients_callbacks_.Remove(request_id);
}
+void ServiceWorkerScriptContext::OnDidSkipWaiting(int request_id) {
+ blink::WebServiceWorkerSkipWaitingCallbacks* callbacks =
+ pending_skip_waiting_callbacks_.Lookup(request_id);
+ if (!callbacks) {
+ NOTREACHED() << "Got stray response: " << request_id;
+ return;
+ }
+ callbacks->onSuccess();
+ pending_skip_waiting_callbacks_.Remove(request_id);
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698