Chromium Code Reviews| 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/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| (...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 681 bool should_notify_controllerchange) { | 681 bool should_notify_controllerchange) { |
| 682 TRACE_EVENT2("ServiceWorker", | 682 TRACE_EVENT2("ServiceWorker", |
| 683 "ServiceWorkerDispatcher::OnSetControllerServiceWorker", | 683 "ServiceWorkerDispatcher::OnSetControllerServiceWorker", |
| 684 "Thread ID", thread_id, | 684 "Thread ID", thread_id, |
| 685 "Provider ID", provider_id); | 685 "Provider ID", provider_id); |
| 686 | 686 |
| 687 // Adopt the reference sent from the browser process and pass it to the | 687 // Adopt the reference sent from the browser process and pass it to the |
| 688 // provider context if it exists. | 688 // provider context if it exists. |
| 689 scoped_ptr<ServiceWorkerHandleReference> handle_ref = Adopt(info); | 689 scoped_ptr<ServiceWorkerHandleReference> handle_ref = Adopt(info); |
| 690 ProviderContextMap::iterator provider = provider_contexts_.find(provider_id); | 690 ProviderContextMap::iterator provider = provider_contexts_.find(provider_id); |
| 691 if (provider != provider_contexts_.end()) | 691 if (provider != provider_contexts_.end()) { |
| 692 provider->second->OnSetControllerServiceWorker(handle_ref.Pass()); | 692 if (info.handle_id == kInvalidServiceWorkerVersionId) |
|
horo
2015/11/27 10:03:26
Please add comment about when this happens.
I thin
falken
2015/12/01 03:46:06
We also call NotifyControllerLost when we fail to
falken
2015/12/01 05:08:00
Actually it happens in several other cases, lookin
horo
2015/12/02 03:10:42
Thank you for the detailed explanation.
| |
| 693 provider->second->OnSetControllerServiceWorker(nullptr); | |
|
nhiroki
2015/11/27 09:46:01
How about throwing away invalid reference handle c
falken
2015/12/01 03:46:06
Seems like a good idea, working on a patch to do t
| |
| 694 else | |
| 695 provider->second->OnSetControllerServiceWorker(handle_ref.Pass()); | |
| 696 } | |
| 693 | 697 |
| 694 ProviderClientMap::iterator found = provider_clients_.find(provider_id); | 698 ProviderClientMap::iterator found = provider_clients_.find(provider_id); |
| 695 if (found != provider_clients_.end()) { | 699 if (found != provider_clients_.end()) { |
| 696 // Get the existing worker object or create a new one with a new reference | 700 // Get the existing worker object or create a new one with a new reference |
| 697 // to populate the .controller field. | 701 // to populate the .controller field. |
| 698 scoped_refptr<WebServiceWorkerImpl> worker = GetOrCreateServiceWorker( | 702 scoped_refptr<WebServiceWorkerImpl> worker = GetOrCreateServiceWorker( |
| 699 ServiceWorkerHandleReference::Create(info, thread_safe_sender_.get())); | 703 ServiceWorkerHandleReference::Create(info, thread_safe_sender_.get())); |
| 700 found->second->setController(WebServiceWorkerImpl::CreateHandle(worker), | 704 found->second->setController(WebServiceWorkerImpl::CreateHandle(worker), |
| 701 should_notify_controllerchange); | 705 should_notify_controllerchange); |
| 702 } | 706 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 762 return ServiceWorkerRegistrationHandleReference::Adopt( | 766 return ServiceWorkerRegistrationHandleReference::Adopt( |
| 763 info, thread_safe_sender_.get()); | 767 info, thread_safe_sender_.get()); |
| 764 } | 768 } |
| 765 | 769 |
| 766 scoped_ptr<ServiceWorkerHandleReference> ServiceWorkerDispatcher::Adopt( | 770 scoped_ptr<ServiceWorkerHandleReference> ServiceWorkerDispatcher::Adopt( |
| 767 const ServiceWorkerObjectInfo& info) { | 771 const ServiceWorkerObjectInfo& info) { |
| 768 return ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get()); | 772 return ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get()); |
| 769 } | 773 } |
| 770 | 774 |
| 771 } // namespace content | 775 } // namespace content |
| OLD | NEW |