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

Side by Side Diff: content/child/service_worker/service_worker_dispatcher.cc

Issue 1235803003: ServiceWorker: Introduce ExtendableMessageEvent to replace MessageEvent Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/child/service_worker/service_worker_dispatcher.h" 5 #include "content/child/service_worker/service_worker_dispatcher.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/thread_task_runner_handle.h" 9 #include "base/thread_task_runner_handle.h"
10 #include "base/threading/thread_local.h" 10 #include "base/threading/thread_local.h"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 return NULL; 255 return NULL;
256 return g_dispatcher_tls.Pointer()->Get(); 256 return g_dispatcher_tls.Pointer()->Get();
257 } 257 }
258 258
259 void ServiceWorkerDispatcher::OnWorkerRunLoopStopped() { 259 void ServiceWorkerDispatcher::OnWorkerRunLoopStopped() {
260 delete this; 260 delete this;
261 } 261 }
262 262
263 WebServiceWorkerImpl* ServiceWorkerDispatcher::GetServiceWorker( 263 WebServiceWorkerImpl* ServiceWorkerDispatcher::GetServiceWorker(
264 const ServiceWorkerObjectInfo& info, 264 const ServiceWorkerObjectInfo& info,
265 int provider_id,
265 bool adopt_handle) { 266 bool adopt_handle) {
266 if (info.handle_id == kInvalidServiceWorkerHandleId) 267 if (info.handle_id == kInvalidServiceWorkerHandleId)
267 return NULL; 268 return NULL;
268 269
269 WorkerObjectMap::iterator existing_worker = 270 WorkerObjectMap::iterator existing_worker =
270 service_workers_.find(info.handle_id); 271 service_workers_.find(info.handle_id);
271 272
272 if (existing_worker != service_workers_.end()) { 273 if (existing_worker != service_workers_.end()) {
273 if (adopt_handle) { 274 if (adopt_handle) {
274 // We are instructed to adopt a handle but we already have one, so 275 // We are instructed to adopt a handle but we already have one, so
275 // adopt and destroy a handle ref. 276 // adopt and destroy a handle ref.
276 ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get()); 277 ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get());
277 } 278 }
278 return existing_worker->second; 279 return existing_worker->second;
279 } 280 }
280 281
281 scoped_ptr<ServiceWorkerHandleReference> handle_ref = 282 scoped_ptr<ServiceWorkerHandleReference> handle_ref =
282 adopt_handle 283 adopt_handle
283 ? ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get()) 284 ? ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get())
284 : ServiceWorkerHandleReference::Create(info, 285 : ServiceWorkerHandleReference::Create(info,
285 thread_safe_sender_.get()); 286 thread_safe_sender_.get());
286 // WebServiceWorkerImpl constructor calls AddServiceWorker. 287 // WebServiceWorkerImpl constructor calls AddServiceWorker.
287 return new WebServiceWorkerImpl(handle_ref.Pass(), thread_safe_sender_.get()); 288 return new WebServiceWorkerImpl(handle_ref.Pass(), provider_id,
289 thread_safe_sender_.get());
288 } 290 }
289 291
290 WebServiceWorkerRegistrationImpl* 292 WebServiceWorkerRegistrationImpl*
291 ServiceWorkerDispatcher::CreateServiceWorkerRegistration( 293 ServiceWorkerDispatcher::CreateServiceWorkerRegistration(
292 const ServiceWorkerRegistrationObjectInfo& info, 294 const ServiceWorkerRegistrationObjectInfo& info,
293 bool adopt_handle) { 295 bool adopt_handle) {
294 DCHECK(!ContainsKey(registrations_, info.handle_id)); 296 DCHECK(!ContainsKey(registrations_, info.handle_id));
295 if (info.handle_id == kInvalidServiceWorkerRegistrationHandleId) 297 if (info.handle_id == kInvalidServiceWorkerRegistrationHandleId)
296 return NULL; 298 return NULL;
297 299
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 worker_to_provider_.erase(provider->second->installing_handle_id()); 355 worker_to_provider_.erase(provider->second->installing_handle_id());
354 worker_to_provider_.erase(provider->second->waiting_handle_id()); 356 worker_to_provider_.erase(provider->second->waiting_handle_id());
355 worker_to_provider_.erase(provider->second->active_handle_id()); 357 worker_to_provider_.erase(provider->second->active_handle_id());
356 worker_to_provider_.erase(provider->second->controller_handle_id()); 358 worker_to_provider_.erase(provider->second->controller_handle_id());
357 provider->second->OnDisassociateRegistration(); 359 provider->second->OnDisassociateRegistration();
358 } 360 }
359 361
360 void ServiceWorkerDispatcher::OnRegistered( 362 void ServiceWorkerDispatcher::OnRegistered(
361 int thread_id, 363 int thread_id,
362 int request_id, 364 int request_id,
365 int provider_id,
363 const ServiceWorkerRegistrationObjectInfo& info, 366 const ServiceWorkerRegistrationObjectInfo& info,
364 const ServiceWorkerVersionAttributes& attrs) { 367 const ServiceWorkerVersionAttributes& attrs) {
365 TRACE_EVENT_ASYNC_STEP_INTO0("ServiceWorker", 368 TRACE_EVENT_ASYNC_STEP_INTO0("ServiceWorker",
366 "ServiceWorkerDispatcher::RegisterServiceWorker", 369 "ServiceWorkerDispatcher::RegisterServiceWorker",
367 request_id, 370 request_id,
368 "OnRegistered"); 371 "OnRegistered");
369 TRACE_EVENT_ASYNC_END0("ServiceWorker", 372 TRACE_EVENT_ASYNC_END0("ServiceWorker",
370 "ServiceWorkerDispatcher::RegisterServiceWorker", 373 "ServiceWorkerDispatcher::RegisterServiceWorker",
371 request_id); 374 request_id);
372 WebServiceWorkerRegistrationCallbacks* callbacks = 375 WebServiceWorkerRegistrationCallbacks* callbacks =
373 pending_registration_callbacks_.Lookup(request_id); 376 pending_registration_callbacks_.Lookup(request_id);
374 DCHECK(callbacks); 377 DCHECK(callbacks);
375 if (!callbacks) 378 if (!callbacks)
376 return; 379 return;
377 380
378 callbacks->onSuccess(FindOrCreateRegistration(info, attrs)); 381 callbacks->onSuccess(FindOrCreateRegistration(provider_id, info, attrs));
379 pending_registration_callbacks_.Remove(request_id); 382 pending_registration_callbacks_.Remove(request_id);
380 } 383 }
381 384
382 void ServiceWorkerDispatcher::OnUnregistered(int thread_id, 385 void ServiceWorkerDispatcher::OnUnregistered(int thread_id,
383 int request_id, 386 int request_id,
384 bool is_success) { 387 bool is_success) {
385 TRACE_EVENT_ASYNC_STEP_INTO0( 388 TRACE_EVENT_ASYNC_STEP_INTO0(
386 "ServiceWorker", 389 "ServiceWorker",
387 "ServiceWorkerDispatcher::UnregisterServiceWorker", 390 "ServiceWorkerDispatcher::UnregisterServiceWorker",
388 request_id, 391 request_id,
389 "OnUnregistered"); 392 "OnUnregistered");
390 TRACE_EVENT_ASYNC_END0("ServiceWorker", 393 TRACE_EVENT_ASYNC_END0("ServiceWorker",
391 "ServiceWorkerDispatcher::UnregisterServiceWorker", 394 "ServiceWorkerDispatcher::UnregisterServiceWorker",
392 request_id); 395 request_id);
393 WebServiceWorkerUnregistrationCallbacks* callbacks = 396 WebServiceWorkerUnregistrationCallbacks* callbacks =
394 pending_unregistration_callbacks_.Lookup(request_id); 397 pending_unregistration_callbacks_.Lookup(request_id);
395 DCHECK(callbacks); 398 DCHECK(callbacks);
396 if (!callbacks) 399 if (!callbacks)
397 return; 400 return;
398 callbacks->onSuccess(&is_success); 401 callbacks->onSuccess(&is_success);
399 pending_unregistration_callbacks_.Remove(request_id); 402 pending_unregistration_callbacks_.Remove(request_id);
400 } 403 }
401 404
402 void ServiceWorkerDispatcher::OnDidGetRegistration( 405 void ServiceWorkerDispatcher::OnDidGetRegistration(
403 int thread_id, 406 int thread_id,
404 int request_id, 407 int request_id,
408 int provider_id,
405 const ServiceWorkerRegistrationObjectInfo& info, 409 const ServiceWorkerRegistrationObjectInfo& info,
406 const ServiceWorkerVersionAttributes& attrs) { 410 const ServiceWorkerVersionAttributes& attrs) {
407 TRACE_EVENT_ASYNC_STEP_INTO0( 411 TRACE_EVENT_ASYNC_STEP_INTO0(
408 "ServiceWorker", 412 "ServiceWorker",
409 "ServiceWorkerDispatcher::GetRegistration", 413 "ServiceWorkerDispatcher::GetRegistration",
410 request_id, 414 request_id,
411 "OnDidGetRegistration"); 415 "OnDidGetRegistration");
412 TRACE_EVENT_ASYNC_END0("ServiceWorker", 416 TRACE_EVENT_ASYNC_END0("ServiceWorker",
413 "ServiceWorkerDispatcher::GetRegistration", 417 "ServiceWorkerDispatcher::GetRegistration",
414 request_id); 418 request_id);
415 WebServiceWorkerRegistrationCallbacks* callbacks = 419 WebServiceWorkerRegistrationCallbacks* callbacks =
416 pending_get_registration_callbacks_.Lookup(request_id); 420 pending_get_registration_callbacks_.Lookup(request_id);
417 DCHECK(callbacks); 421 DCHECK(callbacks);
418 if (!callbacks) 422 if (!callbacks)
419 return; 423 return;
420 424
421 WebServiceWorkerRegistrationImpl* registration = NULL; 425 WebServiceWorkerRegistrationImpl* registration = NULL;
422 if (info.handle_id != kInvalidServiceWorkerHandleId) 426 if (info.handle_id != kInvalidServiceWorkerHandleId)
423 registration = FindOrCreateRegistration(info, attrs); 427 registration = FindOrCreateRegistration(provider_id, info, attrs);
424 428
425 callbacks->onSuccess(registration); 429 callbacks->onSuccess(registration);
426 pending_get_registration_callbacks_.Remove(request_id); 430 pending_get_registration_callbacks_.Remove(request_id);
427 } 431 }
428 432
429 void ServiceWorkerDispatcher::OnDidGetRegistrations( 433 void ServiceWorkerDispatcher::OnDidGetRegistrations(
430 int thread_id, 434 int thread_id,
431 int request_id, 435 int request_id,
436 int provider_id,
432 const std::vector<ServiceWorkerRegistrationObjectInfo>& infos, 437 const std::vector<ServiceWorkerRegistrationObjectInfo>& infos,
433 const std::vector<ServiceWorkerVersionAttributes>& attrs) { 438 const std::vector<ServiceWorkerVersionAttributes>& attrs) {
434 TRACE_EVENT_ASYNC_STEP_INTO0( 439 TRACE_EVENT_ASYNC_STEP_INTO0(
435 "ServiceWorker", 440 "ServiceWorker",
436 "ServiceWorkerDispatcher::GetRegistrations", 441 "ServiceWorkerDispatcher::GetRegistrations",
437 request_id, 442 request_id,
438 "OnDidGetRegistrations"); 443 "OnDidGetRegistrations");
439 TRACE_EVENT_ASYNC_END0("ServiceWorker", 444 TRACE_EVENT_ASYNC_END0("ServiceWorker",
440 "ServiceWorkerDispatcher::GetRegistrations", 445 "ServiceWorkerDispatcher::GetRegistrations",
441 request_id); 446 request_id);
442 447
443 WebServiceWorkerGetRegistrationsCallbacks* callbacks = 448 WebServiceWorkerGetRegistrationsCallbacks* callbacks =
444 pending_get_registrations_callbacks_.Lookup(request_id); 449 pending_get_registrations_callbacks_.Lookup(request_id);
445 DCHECK(callbacks); 450 DCHECK(callbacks);
446 if (!callbacks) 451 if (!callbacks)
447 return; 452 return;
448 453
449 typedef blink::WebVector<blink::WebServiceWorkerRegistration*> 454 typedef blink::WebVector<blink::WebServiceWorkerRegistration*>
450 WebServiceWorkerRegistrationArray; 455 WebServiceWorkerRegistrationArray;
451 scoped_ptr<WebServiceWorkerRegistrationArray> 456 scoped_ptr<WebServiceWorkerRegistrationArray>
452 registrations(new WebServiceWorkerRegistrationArray(infos.size())); 457 registrations(new WebServiceWorkerRegistrationArray(infos.size()));
453 for (size_t i = 0; i < infos.size(); ++i) { 458 for (size_t i = 0; i < infos.size(); ++i) {
454 if (infos[i].handle_id != kInvalidServiceWorkerHandleId) { 459 if (infos[i].handle_id != kInvalidServiceWorkerHandleId) {
455 ServiceWorkerRegistrationObjectInfo info(infos[i]); 460 ServiceWorkerRegistrationObjectInfo info(infos[i]);
456 ServiceWorkerVersionAttributes attr(attrs[i]); 461 ServiceWorkerVersionAttributes attr(attrs[i]);
457 (*registrations)[i] = FindOrCreateRegistration(info, attr); 462 (*registrations)[i] = FindOrCreateRegistration(provider_id, info, attr);
458 } 463 }
459 } 464 }
460 465
461 callbacks->onSuccess(registrations.release()); 466 callbacks->onSuccess(registrations.release());
462 pending_get_registrations_callbacks_.Remove(request_id); 467 pending_get_registrations_callbacks_.Remove(request_id);
463 } 468 }
464 469
465 void ServiceWorkerDispatcher::OnDidGetRegistrationForReady( 470 void ServiceWorkerDispatcher::OnDidGetRegistrationForReady(
466 int thread_id, 471 int thread_id,
467 int request_id, 472 int request_id,
473 int provider_id,
468 const ServiceWorkerRegistrationObjectInfo& info, 474 const ServiceWorkerRegistrationObjectInfo& info,
469 const ServiceWorkerVersionAttributes& attrs) { 475 const ServiceWorkerVersionAttributes& attrs) {
470 TRACE_EVENT_ASYNC_STEP_INTO0( 476 TRACE_EVENT_ASYNC_STEP_INTO0(
471 "ServiceWorker", 477 "ServiceWorker",
472 "ServiceWorkerDispatcher::GetRegistrationForReady", 478 "ServiceWorkerDispatcher::GetRegistrationForReady",
473 request_id, 479 request_id,
474 "OnDidGetRegistrationForReady"); 480 "OnDidGetRegistrationForReady");
475 TRACE_EVENT_ASYNC_END0("ServiceWorker", 481 TRACE_EVENT_ASYNC_END0("ServiceWorker",
476 "ServiceWorkerDispatcher::GetRegistrationForReady", 482 "ServiceWorkerDispatcher::GetRegistrationForReady",
477 request_id); 483 request_id);
478 WebServiceWorkerGetRegistrationForReadyCallbacks* callbacks = 484 WebServiceWorkerGetRegistrationForReadyCallbacks* callbacks =
479 get_for_ready_callbacks_.Lookup(request_id); 485 get_for_ready_callbacks_.Lookup(request_id);
480 DCHECK(callbacks); 486 DCHECK(callbacks);
481 if (!callbacks) 487 if (!callbacks)
482 return; 488 return;
483 489
484 WebServiceWorkerRegistrationImpl* registration = NULL; 490 WebServiceWorkerRegistrationImpl* registration = NULL;
485 DCHECK(info.handle_id != kInvalidServiceWorkerHandleId); 491 DCHECK(info.handle_id != kInvalidServiceWorkerHandleId);
486 registration = FindOrCreateRegistration(info, attrs); 492 registration = FindOrCreateRegistration(provider_id, info, attrs);
487 callbacks->onSuccess(registration); 493 callbacks->onSuccess(registration);
488 get_for_ready_callbacks_.Remove(request_id); 494 get_for_ready_callbacks_.Remove(request_id);
489 } 495 }
490 496
491 void ServiceWorkerDispatcher::OnRegistrationError( 497 void ServiceWorkerDispatcher::OnRegistrationError(
492 int thread_id, 498 int thread_id,
493 int request_id, 499 int request_id,
494 WebServiceWorkerError::ErrorType error_type, 500 WebServiceWorkerError::ErrorType error_type,
495 const base::string16& message) { 501 const base::string16& message) {
496 TRACE_EVENT_ASYNC_STEP_INTO0("ServiceWorker", 502 TRACE_EVENT_ASYNC_STEP_INTO0("ServiceWorker",
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 worker_to_provider_[attrs.active.handle_id] = provider->second; 640 worker_to_provider_[attrs.active.handle_id] = provider->second;
635 } 641 }
636 provider->second->SetVersionAttributes(mask, attrs); 642 provider->second->SetVersionAttributes(mask, attrs);
637 } 643 }
638 644
639 RegistrationObjectMap::iterator found = 645 RegistrationObjectMap::iterator found =
640 registrations_.find(registration_handle_id); 646 registrations_.find(registration_handle_id);
641 if (found != registrations_.end()) { 647 if (found != registrations_.end()) {
642 // Populate the version fields (eg. .installing) with new worker objects. 648 // Populate the version fields (eg. .installing) with new worker objects.
643 if (mask.installing_changed()) 649 if (mask.installing_changed())
644 found->second->SetInstalling(GetServiceWorker(attrs.installing, false)); 650 found->second->SetInstalling(
651 GetServiceWorker(attrs.installing, provider_id, false));
645 if (mask.waiting_changed()) 652 if (mask.waiting_changed())
646 found->second->SetWaiting(GetServiceWorker(attrs.waiting, false)); 653 found->second->SetWaiting(
654 GetServiceWorker(attrs.waiting, provider_id, false));
647 if (mask.active_changed()) 655 if (mask.active_changed())
648 found->second->SetActive(GetServiceWorker(attrs.active, false)); 656 found->second->SetActive(
657 GetServiceWorker(attrs.active, provider_id, false));
649 } 658 }
650 } 659 }
651 660
652 void ServiceWorkerDispatcher::OnUpdateFound( 661 void ServiceWorkerDispatcher::OnUpdateFound(
653 int thread_id, 662 int thread_id,
654 int registration_handle_id) { 663 int registration_handle_id) {
655 TRACE_EVENT0("ServiceWorker", 664 TRACE_EVENT0("ServiceWorker",
656 "ServiceWorkerDispatcher::OnUpdateFound"); 665 "ServiceWorkerDispatcher::OnUpdateFound");
657 RegistrationObjectMap::iterator found = 666 RegistrationObjectMap::iterator found =
658 registrations_.find(registration_handle_id); 667 registrations_.find(registration_handle_id);
(...skipping 15 matching lines...) Expand all
674 if (provider != provider_contexts_.end()) { 683 if (provider != provider_contexts_.end()) {
675 worker_to_provider_.erase(provider->second->controller_handle_id()); 684 worker_to_provider_.erase(provider->second->controller_handle_id());
676 if (info.handle_id != kInvalidServiceWorkerHandleId) 685 if (info.handle_id != kInvalidServiceWorkerHandleId)
677 worker_to_provider_[info.handle_id] = provider->second; 686 worker_to_provider_[info.handle_id] = provider->second;
678 provider->second->OnSetControllerServiceWorker(info); 687 provider->second->OnSetControllerServiceWorker(info);
679 } 688 }
680 689
681 ProviderClientMap::iterator found = provider_clients_.find(provider_id); 690 ProviderClientMap::iterator found = provider_clients_.find(provider_id);
682 if (found != provider_clients_.end()) { 691 if (found != provider_clients_.end()) {
683 // Populate the .controller field with the new worker object. 692 // Populate the .controller field with the new worker object.
684 found->second->setController(GetServiceWorker(info, false), 693 found->second->setController(GetServiceWorker(info, provider_id, false),
685 should_notify_controllerchange); 694 should_notify_controllerchange);
686 } 695 }
687 } 696 }
688 697
689 void ServiceWorkerDispatcher::OnPostMessage( 698 void ServiceWorkerDispatcher::OnPostMessage(
690 const ServiceWorkerMsg_MessageToDocument_Params& params) { 699 const ServiceWorkerMsg_MessageToDocument_Params& params) {
691 // Make sure we're on the main document thread. (That must be the only 700 // Make sure we're on the main document thread. (That must be the only
692 // thread we get this message) 701 // thread we get this message)
693 DCHECK(ChildThreadImpl::current()); 702 DCHECK(ChildThreadImpl::current());
694 TRACE_EVENT1("ServiceWorker", "ServiceWorkerDispatcher::OnPostMessage", 703 TRACE_EVENT1("ServiceWorker", "ServiceWorkerDispatcher::OnPostMessage",
695 "Thread ID", params.thread_id); 704 "Thread ID", params.thread_id);
696 705
697 ProviderClientMap::iterator found = 706 ProviderClientMap::iterator found =
698 provider_clients_.find(params.provider_id); 707 provider_clients_.find(params.provider_id);
699 if (found == provider_clients_.end()) { 708 if (found == provider_clients_.end()) {
700 // For now we do no queueing for messages sent to nonexistent / unattached 709 // For now we do no queueing for messages sent to nonexistent / unattached
701 // client. 710 // client.
702 return; 711 return;
703 } 712 }
704 713
705 blink::WebMessagePortChannelArray ports = 714 blink::WebMessagePortChannelArray ports =
706 WebMessagePortChannelImpl::CreatePorts( 715 WebMessagePortChannelImpl::CreatePorts(
707 params.message_ports, params.new_routing_ids, 716 params.message_ports, params.new_routing_ids,
708 base::ThreadTaskRunnerHandle::Get()); 717 base::ThreadTaskRunnerHandle::Get());
709 718
710 found->second->dispatchMessageEvent( 719 found->second->dispatchMessageEvent(
711 GetServiceWorker(params.service_worker_info, false /* adopt_handle */), 720 GetServiceWorker(params.service_worker_info, params.provider_id,
721 false /* adopt_handle */),
712 params.message, ports); 722 params.message, ports);
713 } 723 }
714 724
715 void ServiceWorkerDispatcher::AddServiceWorker( 725 void ServiceWorkerDispatcher::AddServiceWorker(
716 int handle_id, WebServiceWorkerImpl* worker) { 726 int handle_id, WebServiceWorkerImpl* worker) {
717 DCHECK(!ContainsKey(service_workers_, handle_id)); 727 DCHECK(!ContainsKey(service_workers_, handle_id));
718 service_workers_[handle_id] = worker; 728 service_workers_[handle_id] = worker;
719 } 729 }
720 730
721 void ServiceWorkerDispatcher::RemoveServiceWorker(int handle_id) { 731 void ServiceWorkerDispatcher::RemoveServiceWorker(int handle_id) {
722 DCHECK(ContainsKey(service_workers_, handle_id)); 732 DCHECK(ContainsKey(service_workers_, handle_id));
723 service_workers_.erase(handle_id); 733 service_workers_.erase(handle_id);
724 } 734 }
725 735
726 void ServiceWorkerDispatcher::AddServiceWorkerRegistration( 736 void ServiceWorkerDispatcher::AddServiceWorkerRegistration(
727 int registration_handle_id, 737 int registration_handle_id,
728 WebServiceWorkerRegistrationImpl* registration) { 738 WebServiceWorkerRegistrationImpl* registration) {
729 DCHECK(!ContainsKey(registrations_, registration_handle_id)); 739 DCHECK(!ContainsKey(registrations_, registration_handle_id));
730 registrations_[registration_handle_id] = registration; 740 registrations_[registration_handle_id] = registration;
731 } 741 }
732 742
733 void ServiceWorkerDispatcher::RemoveServiceWorkerRegistration( 743 void ServiceWorkerDispatcher::RemoveServiceWorkerRegistration(
734 int registration_handle_id) { 744 int registration_handle_id) {
735 DCHECK(ContainsKey(registrations_, registration_handle_id)); 745 DCHECK(ContainsKey(registrations_, registration_handle_id));
736 registrations_.erase(registration_handle_id); 746 registrations_.erase(registration_handle_id);
737 } 747 }
738 748
739 WebServiceWorkerRegistrationImpl* 749 WebServiceWorkerRegistrationImpl*
740 ServiceWorkerDispatcher::FindOrCreateRegistration( 750 ServiceWorkerDispatcher::FindOrCreateRegistration(
751 int provider_id,
741 const ServiceWorkerRegistrationObjectInfo& info, 752 const ServiceWorkerRegistrationObjectInfo& info,
742 const ServiceWorkerVersionAttributes& attrs) { 753 const ServiceWorkerVersionAttributes& attrs) {
743 RegistrationObjectMap::iterator found = registrations_.find(info.handle_id); 754 RegistrationObjectMap::iterator found = registrations_.find(info.handle_id);
744 if (found != registrations_.end()) { 755 if (found != registrations_.end()) {
745 ServiceWorkerRegistrationHandleReference::Adopt(info, 756 ServiceWorkerRegistrationHandleReference::Adopt(info,
746 thread_safe_sender_.get()); 757 thread_safe_sender_.get());
747 ServiceWorkerHandleReference::Adopt(attrs.installing, 758 ServiceWorkerHandleReference::Adopt(attrs.installing,
748 thread_safe_sender_.get()); 759 thread_safe_sender_.get());
749 ServiceWorkerHandleReference::Adopt(attrs.waiting, 760 ServiceWorkerHandleReference::Adopt(attrs.waiting,
750 thread_safe_sender_.get()); 761 thread_safe_sender_.get());
751 ServiceWorkerHandleReference::Adopt(attrs.active, 762 ServiceWorkerHandleReference::Adopt(attrs.active,
752 thread_safe_sender_.get()); 763 thread_safe_sender_.get());
753 return found->second; 764 return found->second;
754 } 765 }
755 766
756 bool adopt_handle = true; 767 bool adopt_handle = true;
757 WebServiceWorkerRegistrationImpl* registration = 768 WebServiceWorkerRegistrationImpl* registration =
758 CreateServiceWorkerRegistration(info, adopt_handle); 769 CreateServiceWorkerRegistration(info, adopt_handle);
759 registration->SetInstalling(GetServiceWorker(attrs.installing, adopt_handle)); 770 registration->SetInstalling(
760 registration->SetWaiting(GetServiceWorker(attrs.waiting, adopt_handle)); 771 GetServiceWorker(attrs.installing, provider_id, adopt_handle));
761 registration->SetActive(GetServiceWorker(attrs.active, adopt_handle)); 772 registration->SetWaiting(
773 GetServiceWorker(attrs.waiting, provider_id, adopt_handle));
774 registration->SetActive(
775 GetServiceWorker(attrs.active, provider_id, adopt_handle));
762 return registration; 776 return registration;
763 } 777 }
764 778
765 } // namespace content 779 } // namespace content
OLDNEW
« no previous file with comments | « content/child/service_worker/service_worker_dispatcher.h ('k') | content/child/service_worker/service_worker_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698