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

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: add missing '!' Created 6 years, 1 month 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 9aa65d5661b8de5cea8cff80e8c0d87a61bfce04..47b4a448497ac93c470562faa3a7527d62071e6f 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()
@@ -157,6 +158,12 @@ void ServiceWorkerScriptContext::PostMessageToDocument(
GetRoutingID(), client_id, message, base::Passed(&channels)));
}
+void ServiceWorkerScriptContext::SkipWaiting(blink::WebCallback* callback) {
+ DCHECK(callback);
+ int request_id = pending_skip_waiting_callbacks_.Add(callback);
+ Send(new ServiceWorkerHostMsg_SkipWaiting(GetRoutingID(), request_id));
+}
+
void ServiceWorkerScriptContext::Send(IPC::Message* message) {
embedded_context_->Send(message);
}
@@ -281,4 +288,15 @@ void ServiceWorkerScriptContext::OnDidGetClientDocuments(
pending_clients_callbacks_.Remove(request_id);
}
+void ServiceWorkerScriptContext::OnDidSkipWaiting(int request_id) {
+ blink::WebCallback* callback =
+ pending_skip_waiting_callbacks_.Lookup(request_id);
+ if (!callback) {
+ NOTREACHED() << "Got stray response: " << request_id;
+ return;
+ }
+ callback->run();
+ pending_skip_waiting_callbacks_.Remove(request_id);
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698