OLD | NEW |
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/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/threading/thread_local.h" | 10 #include "base/threading/thread_local.h" |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 if (provider == provider_contexts_.end() || | 578 if (provider == provider_contexts_.end() || |
579 provider->second->registration_handle_id() != registration_handle_id || | 579 provider->second->registration_handle_id() != registration_handle_id || |
580 provider->second->active_handle_id() == kInvalidServiceWorkerHandleId) { | 580 provider->second->active_handle_id() == kInvalidServiceWorkerHandleId) { |
581 return; | 581 return; |
582 } | 582 } |
583 | 583 |
584 ProviderClientMap::iterator client = provider_clients_.find(provider_id); | 584 ProviderClientMap::iterator client = provider_clients_.find(provider_id); |
585 if (client == provider_clients_.end()) | 585 if (client == provider_clients_.end()) |
586 return; | 586 return; |
587 | 587 |
588 ServiceWorkerRegistrationObjectInfo info = | 588 ServiceWorkerRegistrationObjectInfo info; |
589 provider->second->registration()->info(); | 589 ServiceWorkerVersionAttributes attrs; |
| 590 bool found = |
| 591 provider->second->GetRegistrationInfoAndVersionAttributes(&info, &attrs); |
| 592 DCHECK(found); |
| 593 |
590 WebServiceWorkerRegistrationImpl* registration = | 594 WebServiceWorkerRegistrationImpl* registration = |
591 FindServiceWorkerRegistration(info, false); | 595 FindServiceWorkerRegistration(info, false); |
592 if (!registration) { | 596 if (!registration) { |
593 registration = CreateServiceWorkerRegistration(info, false); | 597 registration = CreateServiceWorkerRegistration(info, false); |
594 ServiceWorkerVersionAttributes attrs = | |
595 provider->second->GetVersionAttributes(); | |
596 registration->SetInstalling(GetServiceWorker(attrs.installing, false)); | 598 registration->SetInstalling(GetServiceWorker(attrs.installing, false)); |
597 registration->SetWaiting(GetServiceWorker(attrs.waiting, false)); | 599 registration->SetWaiting(GetServiceWorker(attrs.waiting, false)); |
598 registration->SetActive(GetServiceWorker(attrs.active, false)); | 600 registration->SetActive(GetServiceWorker(attrs.active, false)); |
599 } | 601 } |
600 | 602 |
601 // Resolve the .ready promise with the registration object. | 603 // Resolve the .ready promise with the registration object. |
602 client->second->setReadyRegistration(registration); | 604 client->second->setReadyRegistration(registration); |
603 } | 605 } |
604 | 606 |
605 void ServiceWorkerDispatcher::OnSetControllerServiceWorker( | 607 void ServiceWorkerDispatcher::OnSetControllerServiceWorker( |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 attrs.installing, thread_safe_sender_.get()); | 729 attrs.installing, thread_safe_sender_.get()); |
728 ServiceWorkerHandleReference::Adopt( | 730 ServiceWorkerHandleReference::Adopt( |
729 attrs.waiting, thread_safe_sender_.get()); | 731 attrs.waiting, thread_safe_sender_.get()); |
730 ServiceWorkerHandleReference::Adopt( | 732 ServiceWorkerHandleReference::Adopt( |
731 attrs.active, thread_safe_sender_.get()); | 733 attrs.active, thread_safe_sender_.get()); |
732 } | 734 } |
733 return registration; | 735 return registration; |
734 } | 736 } |
735 | 737 |
736 } // namespace content | 738 } // namespace content |
OLD | NEW |