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/browser/service_worker/service_worker_context_wrapper.h" | 5 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 97 |
98 bool ServiceWorkerContext::IsExcludedHeaderNameForFetchEvent( | 98 bool ServiceWorkerContext::IsExcludedHeaderNameForFetchEvent( |
99 const std::string& header_name) { | 99 const std::string& header_name) { |
100 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 100 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
101 return g_excluded_header_name_set.Get().find(header_name) != | 101 return g_excluded_header_name_set.Get().find(header_name) != |
102 g_excluded_header_name_set.Get().end(); | 102 g_excluded_header_name_set.Get().end(); |
103 } | 103 } |
104 | 104 |
105 ServiceWorkerContextWrapper::ServiceWorkerContextWrapper( | 105 ServiceWorkerContextWrapper::ServiceWorkerContextWrapper( |
106 BrowserContext* browser_context) | 106 BrowserContext* browser_context) |
107 : observer_list_( | 107 : core_observer_list_( |
108 new base::ObserverListThreadSafe<ServiceWorkerContextCoreObserver>()), | 108 new base::ObserverListThreadSafe<ServiceWorkerContextCoreObserver>()), |
109 process_manager_(new ServiceWorkerProcessManager(browser_context)), | 109 process_manager_(new ServiceWorkerProcessManager(browser_context)), |
110 is_incognito_(false), | 110 is_incognito_(false), |
111 storage_partition_(nullptr), | 111 storage_partition_(nullptr), |
112 resource_context_(nullptr) { | 112 resource_context_(nullptr) { |
113 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 113 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
114 } | 114 } |
115 | 115 |
116 ServiceWorkerContextWrapper::~ServiceWorkerContextWrapper() { | 116 ServiceWorkerContextWrapper::~ServiceWorkerContextWrapper() { |
117 DCHECK(!resource_context_); | 117 DCHECK(!resource_context_); |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 RunSoon(base::Bind(callback, std::vector<std::pair<int64_t, std::string>>(), | 733 RunSoon(base::Bind(callback, std::vector<std::pair<int64_t, std::string>>(), |
734 SERVICE_WORKER_ERROR_ABORT)); | 734 SERVICE_WORKER_ERROR_ABORT)); |
735 return; | 735 return; |
736 } | 736 } |
737 context_core_->storage()->GetUserDataForAllRegistrationsByKeyPrefix( | 737 context_core_->storage()->GetUserDataForAllRegistrationsByKeyPrefix( |
738 key_prefix, callback); | 738 key_prefix, callback); |
739 } | 739 } |
740 | 740 |
741 void ServiceWorkerContextWrapper::AddObserver( | 741 void ServiceWorkerContextWrapper::AddObserver( |
742 ServiceWorkerContextCoreObserver* observer) { | 742 ServiceWorkerContextCoreObserver* observer) { |
743 observer_list_->AddObserver(observer); | 743 core_observer_list_->AddObserver(observer); |
744 } | 744 } |
745 | 745 |
746 void ServiceWorkerContextWrapper::RemoveObserver( | 746 void ServiceWorkerContextWrapper::RemoveObserver( |
747 ServiceWorkerContextCoreObserver* observer) { | 747 ServiceWorkerContextCoreObserver* observer) { |
748 observer_list_->RemoveObserver(observer); | 748 core_observer_list_->RemoveObserver(observer); |
749 } | 749 } |
750 | 750 |
751 bool ServiceWorkerContextWrapper::OriginHasForeignFetchRegistrations( | 751 bool ServiceWorkerContextWrapper::OriginHasForeignFetchRegistrations( |
752 const GURL& origin) { | 752 const GURL& origin) { |
753 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 753 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
754 if (!context_core_) | 754 if (!context_core_) |
755 return false; | 755 return false; |
756 return context_core_->storage()->OriginHasForeignFetchRegistrations(origin); | 756 return context_core_->storage()->OriginHasForeignFetchRegistrations(origin); |
757 } | 757 } |
758 | 758 |
(...skipping 15 matching lines...) Expand all Loading... |
774 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed. | 774 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed. |
775 tracked_objects::ScopedTracker tracking_profile( | 775 tracked_objects::ScopedTracker tracking_profile( |
776 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 776 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
777 "477117 ServiceWorkerContextWrapper::InitInternal")); | 777 "477117 ServiceWorkerContextWrapper::InitInternal")); |
778 DCHECK(!context_core_); | 778 DCHECK(!context_core_); |
779 if (quota_manager_proxy) { | 779 if (quota_manager_proxy) { |
780 quota_manager_proxy->RegisterClient(new ServiceWorkerQuotaClient(this)); | 780 quota_manager_proxy->RegisterClient(new ServiceWorkerQuotaClient(this)); |
781 } | 781 } |
782 context_core_.reset(new ServiceWorkerContextCore( | 782 context_core_.reset(new ServiceWorkerContextCore( |
783 user_data_directory, std::move(database_task_manager), disk_cache_thread, | 783 user_data_directory, std::move(database_task_manager), disk_cache_thread, |
784 quota_manager_proxy, special_storage_policy, observer_list_.get(), this)); | 784 quota_manager_proxy, special_storage_policy, core_observer_list_.get(), |
| 785 this)); |
785 } | 786 } |
786 | 787 |
787 void ServiceWorkerContextWrapper::ShutdownOnIO() { | 788 void ServiceWorkerContextWrapper::ShutdownOnIO() { |
788 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 789 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
789 resource_context_ = nullptr; | 790 resource_context_ = nullptr; |
790 context_core_.reset(); | 791 context_core_.reset(); |
791 } | 792 } |
792 | 793 |
793 bool ServiceWorkerContextWrapper::StartingExternalRequest( | 794 bool ServiceWorkerContextWrapper::StartingExternalRequest( |
794 int64_t service_worker_version_id, | 795 int64_t service_worker_version_id, |
(...skipping 19 matching lines...) Expand all Loading... |
814 | 815 |
815 void ServiceWorkerContextWrapper::DidDeleteAndStartOver( | 816 void ServiceWorkerContextWrapper::DidDeleteAndStartOver( |
816 ServiceWorkerStatusCode status) { | 817 ServiceWorkerStatusCode status) { |
817 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 818 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
818 if (status != SERVICE_WORKER_OK) { | 819 if (status != SERVICE_WORKER_OK) { |
819 context_core_.reset(); | 820 context_core_.reset(); |
820 return; | 821 return; |
821 } | 822 } |
822 context_core_.reset(new ServiceWorkerContextCore(context_core_.get(), this)); | 823 context_core_.reset(new ServiceWorkerContextCore(context_core_.get(), this)); |
823 DVLOG(1) << "Restarted ServiceWorkerContextCore successfully."; | 824 DVLOG(1) << "Restarted ServiceWorkerContextCore successfully."; |
824 | 825 context_core_->OnStorageWiped(); |
825 observer_list_->Notify(FROM_HERE, | |
826 &ServiceWorkerContextCoreObserver::OnStorageWiped); | |
827 } | 826 } |
828 | 827 |
829 void ServiceWorkerContextWrapper::BindWorkerFetchContext( | 828 void ServiceWorkerContextWrapper::BindWorkerFetchContext( |
830 int render_process_id, | 829 int render_process_id, |
831 int service_worker_provider_id, | 830 int service_worker_provider_id, |
832 mojom::ServiceWorkerWorkerClientAssociatedPtrInfo client_ptr_info) { | 831 mojom::ServiceWorkerWorkerClientAssociatedPtrInfo client_ptr_info) { |
833 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 832 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
834 context()->BindWorkerFetchContext(render_process_id, | 833 context()->BindWorkerFetchContext(render_process_id, |
835 service_worker_provider_id, | 834 service_worker_provider_id, |
836 std::move(client_ptr_info)); | 835 std::move(client_ptr_info)); |
837 } | 836 } |
838 | 837 |
839 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { | 838 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { |
840 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 839 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
841 return context_core_.get(); | 840 return context_core_.get(); |
842 } | 841 } |
843 | 842 |
844 } // namespace content | 843 } // namespace content |
OLD | NEW |