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

Side by Side Diff: content/renderer/service_worker/service_worker_script_context.cc

Issue 894853007: [ServiceWorker] Update SWProviderHost::Focus() to return a Client. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sw_open_window
Patch Set: 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 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/logging.h" 7 #include "base/logging.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "content/child/notifications/notification_data_conversions.h" 10 #include "content/child/notifications/notification_data_conversions.h"
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 // (with thread hopping), so we need to do the same thread hopping here not 257 // (with thread hopping), so we need to do the same thread hopping here not
258 // to overtake those messages. 258 // to overtake those messages.
259 embedded_context_->main_thread_proxy()->PostTask( 259 embedded_context_->main_thread_proxy()->PostTask(
260 FROM_HERE, 260 FROM_HERE,
261 base::Bind(&SendCrossOriginMessageToClientOnMainThread, 261 base::Bind(&SendCrossOriginMessageToClientOnMainThread,
262 make_scoped_refptr(embedded_context_->thread_safe_sender()), 262 make_scoped_refptr(embedded_context_->thread_safe_sender()),
263 client.clientID, message, base::Passed(&channels))); 263 client.clientID, message, base::Passed(&channels)));
264 } 264 }
265 265
266 void ServiceWorkerScriptContext::FocusClient( 266 void ServiceWorkerScriptContext::FocusClient(
267 int client_id, blink::WebServiceWorkerClientFocusCallback* callback) { 267 int client_id, blink::WebServiceWorkerClientCallbacks* callback) {
268 DCHECK(callback); 268 DCHECK(callback);
269 int request_id = pending_focus_client_callbacks_.Add(callback); 269 int request_id = pending_client_callbacks_.Add(callback);
270 Send(new ServiceWorkerHostMsg_FocusClient( 270 Send(new ServiceWorkerHostMsg_FocusClient(
271 GetRoutingID(), request_id, client_id)); 271 GetRoutingID(), request_id, client_id));
272 } 272 }
273 273
274 void ServiceWorkerScriptContext::ClaimClients( 274 void ServiceWorkerScriptContext::ClaimClients(
275 blink::WebServiceWorkerClientsClaimCallbacks* callbacks) { 275 blink::WebServiceWorkerClientsClaimCallbacks* callbacks) {
276 DCHECK(callbacks); 276 DCHECK(callbacks);
277 int request_id = pending_claim_clients_callbacks_.Add(callbacks); 277 int request_id = pending_claim_clients_callbacks_.Add(callbacks);
278 Send(new ServiceWorkerHostMsg_ClaimClients(GetRoutingID(), request_id)); 278 Send(new ServiceWorkerHostMsg_ClaimClients(GetRoutingID(), request_id));
279 } 279 }
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 return; 493 return;
494 } 494 }
495 scoped_ptr<blink::WebServiceWorkerError> error( 495 scoped_ptr<blink::WebServiceWorkerError> error(
496 new blink::WebServiceWorkerError( 496 new blink::WebServiceWorkerError(
497 blink::WebServiceWorkerError::ErrorTypeUnknown, 497 blink::WebServiceWorkerError::ErrorTypeUnknown,
498 "Something went wrong while trying to open the window.")); 498 "Something went wrong while trying to open the window."));
499 callbacks->onError(error.release()); 499 callbacks->onError(error.release());
500 pending_client_callbacks_.Remove(request_id); 500 pending_client_callbacks_.Remove(request_id);
501 } 501 }
502 502
503 void ServiceWorkerScriptContext::OnFocusClientResponse(int request_id, 503 void ServiceWorkerScriptContext::OnFocusClientResponse(
504 bool result) { 504 int request_id, const ServiceWorkerClientInfo& client) {
505 TRACE_EVENT0("ServiceWorker", 505 TRACE_EVENT0("ServiceWorker",
506 "ServiceWorkerScriptContext::OnFocusClientResponse"); 506 "ServiceWorkerScriptContext::OnFocusClientResponse");
507 blink::WebServiceWorkerClientFocusCallback* callback = 507 blink::WebServiceWorkerClientCallbacks* callback =
508 pending_focus_client_callbacks_.Lookup(request_id); 508 pending_client_callbacks_.Lookup(request_id);
509 if (!callback) { 509 if (!callback) {
510 NOTREACHED() << "Got stray response: " << request_id; 510 NOTREACHED() << "Got stray response: " << request_id;
511 return; 511 return;
512 } 512 }
513 callback->onSuccess(&result); 513 if (!client.IsEmpty()) {
514 pending_focus_client_callbacks_.Remove(request_id); 514 DCHECK(client.IsValid());
515 scoped_ptr<blink::WebServiceWorkerClientInfo> web_client (
516 new blink::WebServiceWorkerClientInfo(
517 ToWebServiceWorkerClientInfo(client)));
518 callback->onSuccess(web_client.release());
519 } else {
520 scoped_ptr<blink::WebServiceWorkerError> error(
521 new blink::WebServiceWorkerError(
522 blink::WebServiceWorkerError::ErrorTypeNotFound,
523 "The WindowClient was not found."));
524 callback->onError(error.release());
525 }
526
527 pending_client_callbacks_.Remove(request_id);
515 } 528 }
516 529
517 void ServiceWorkerScriptContext::OnDidSkipWaiting(int request_id) { 530 void ServiceWorkerScriptContext::OnDidSkipWaiting(int request_id) {
518 TRACE_EVENT0("ServiceWorker", 531 TRACE_EVENT0("ServiceWorker",
519 "ServiceWorkerScriptContext::OnDidSkipWaiting"); 532 "ServiceWorkerScriptContext::OnDidSkipWaiting");
520 blink::WebServiceWorkerSkipWaitingCallbacks* callbacks = 533 blink::WebServiceWorkerSkipWaitingCallbacks* callbacks =
521 pending_skip_waiting_callbacks_.Lookup(request_id); 534 pending_skip_waiting_callbacks_.Lookup(request_id);
522 if (!callbacks) { 535 if (!callbacks) {
523 NOTREACHED() << "Got stray response: " << request_id; 536 NOTREACHED() << "Got stray response: " << request_id;
524 return; 537 return;
(...skipping 27 matching lines...) Expand all
552 NOTREACHED() << "Got stray response: " << request_id; 565 NOTREACHED() << "Got stray response: " << request_id;
553 return; 566 return;
554 } 567 }
555 scoped_ptr<blink::WebServiceWorkerError> error( 568 scoped_ptr<blink::WebServiceWorkerError> error(
556 new blink::WebServiceWorkerError(error_type, message)); 569 new blink::WebServiceWorkerError(error_type, message));
557 callbacks->onError(error.release()); 570 callbacks->onError(error.release());
558 pending_claim_clients_callbacks_.Remove(request_id); 571 pending_claim_clients_callbacks_.Remove(request_id);
559 } 572 }
560 573
561 } // namespace content 574 } // 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