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

Side by Side 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: rebase again 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/service_worker/service_worker_script_context.h" 5 #include "content/renderer/service_worker/service_worker_script_context.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "content/child/thread_safe_sender.h" 10 #include "content/child/thread_safe_sender.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_SyncEvent, OnSyncEvent) 79 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_SyncEvent, OnSyncEvent)
80 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_NotificationClickEvent, 80 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_NotificationClickEvent,
81 OnNotificationClickEvent) 81 OnNotificationClickEvent)
82 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_PushEvent, OnPushEvent) 82 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_PushEvent, OnPushEvent)
83 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_GeofencingEvent, OnGeofencingEvent) 83 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_GeofencingEvent, OnGeofencingEvent)
84 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_MessageToWorker, OnPostMessage) 84 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_MessageToWorker, OnPostMessage)
85 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidGetClientDocuments, 85 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidGetClientDocuments,
86 OnDidGetClientDocuments) 86 OnDidGetClientDocuments)
87 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_FocusClientResponse, 87 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_FocusClientResponse,
88 OnFocusClientResponse) 88 OnFocusClientResponse)
89 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidSkipWaiting, OnDidSkipWaiting)
89 IPC_MESSAGE_UNHANDLED(handled = false) 90 IPC_MESSAGE_UNHANDLED(handled = false)
90 IPC_END_MESSAGE_MAP() 91 IPC_END_MESSAGE_MAP()
91 92
92 // TODO(gavinp): Would it be preferable to put an AddListener() method to 93 // TODO(gavinp): Would it be preferable to put an AddListener() method to
93 // EmbeddedWorkerContextClient? 94 // EmbeddedWorkerContextClient?
94 if (!handled) 95 if (!handled)
95 handled = cache_storage_dispatcher_->OnMessageReceived(message); 96 handled = cache_storage_dispatcher_->OnMessageReceived(message);
96 97
97 DCHECK(handled); 98 DCHECK(handled);
98 } 99 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 } 190 }
190 191
191 void ServiceWorkerScriptContext::FocusClient( 192 void ServiceWorkerScriptContext::FocusClient(
192 int client_id, blink::WebServiceWorkerClientFocusCallback* callback) { 193 int client_id, blink::WebServiceWorkerClientFocusCallback* callback) {
193 DCHECK(callback); 194 DCHECK(callback);
194 int request_id = pending_focus_client_callbacks_.Add(callback); 195 int request_id = pending_focus_client_callbacks_.Add(callback);
195 Send(new ServiceWorkerHostMsg_FocusClient( 196 Send(new ServiceWorkerHostMsg_FocusClient(
196 GetRoutingID(), request_id, client_id)); 197 GetRoutingID(), request_id, client_id));
197 } 198 }
198 199
200 void ServiceWorkerScriptContext::SkipWaiting(
201 blink::WebServiceWorkerSkipWaitingCallbacks* callbacks) {
202 DCHECK(callbacks);
203 int request_id = pending_skip_waiting_callbacks_.Add(callbacks);
204 Send(new ServiceWorkerHostMsg_SkipWaiting(GetRoutingID(), request_id));
205 }
206
199 void ServiceWorkerScriptContext::Send(IPC::Message* message) { 207 void ServiceWorkerScriptContext::Send(IPC::Message* message) {
200 embedded_context_->Send(message); 208 embedded_context_->Send(message);
201 } 209 }
202 210
203 int ServiceWorkerScriptContext::GetRoutingID() const { 211 int ServiceWorkerScriptContext::GetRoutingID() const {
204 return embedded_context_->embedded_worker_id(); 212 return embedded_context_->embedded_worker_id();
205 } 213 }
206 214
207 void ServiceWorkerScriptContext::OnActivateEvent(int request_id) { 215 void ServiceWorkerScriptContext::OnActivateEvent(int request_id) {
208 TRACE_EVENT0("ServiceWorker", 216 TRACE_EVENT0("ServiceWorker",
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 blink::WebServiceWorkerClientFocusCallback* callback = 369 blink::WebServiceWorkerClientFocusCallback* callback =
362 pending_focus_client_callbacks_.Lookup(request_id); 370 pending_focus_client_callbacks_.Lookup(request_id);
363 if (!callback) { 371 if (!callback) {
364 NOTREACHED() << "Got stray response: " << request_id; 372 NOTREACHED() << "Got stray response: " << request_id;
365 return; 373 return;
366 } 374 }
367 callback->onSuccess(&result); 375 callback->onSuccess(&result);
368 pending_focus_client_callbacks_.Remove(request_id); 376 pending_focus_client_callbacks_.Remove(request_id);
369 } 377 }
370 378
379 void ServiceWorkerScriptContext::OnDidSkipWaiting(int request_id) {
380 TRACE_EVENT0("ServiceWorker",
381 "ServiceWorkerScriptContext::OnDidSkipWaiting");
382 blink::WebServiceWorkerSkipWaitingCallbacks* callbacks =
383 pending_skip_waiting_callbacks_.Lookup(request_id);
384 if (!callbacks) {
385 NOTREACHED() << "Got stray response: " << request_id;
386 return;
387 }
388 callbacks->onSuccess();
389 pending_skip_waiting_callbacks_.Remove(request_id);
390 }
391
371 } // namespace content 392 } // namespace content
OLDNEW
« 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