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 <vector> | 11 #include <vector> |
11 | 12 |
12 #include "base/barrier_closure.h" | 13 #include "base/barrier_closure.h" |
13 #include "base/bind.h" | 14 #include "base/bind.h" |
14 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
15 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
16 #include "base/location.h" | 17 #include "base/location.h" |
17 #include "base/logging.h" | 18 #include "base/logging.h" |
18 #include "base/profiler/scoped_tracker.h" | 19 #include "base/profiler/scoped_tracker.h" |
19 #include "base/single_thread_task_runner.h" | 20 #include "base/single_thread_task_runner.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 storage::QuotaManagerProxy* quota_manager_proxy, | 108 storage::QuotaManagerProxy* quota_manager_proxy, |
108 storage::SpecialStoragePolicy* special_storage_policy) { | 109 storage::SpecialStoragePolicy* special_storage_policy) { |
109 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 110 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
110 | 111 |
111 is_incognito_ = user_data_directory.empty(); | 112 is_incognito_ = user_data_directory.empty(); |
112 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); | 113 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); |
113 scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager( | 114 scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager( |
114 new ServiceWorkerDatabaseTaskManagerImpl(pool)); | 115 new ServiceWorkerDatabaseTaskManagerImpl(pool)); |
115 scoped_refptr<base::SingleThreadTaskRunner> disk_cache_thread = | 116 scoped_refptr<base::SingleThreadTaskRunner> disk_cache_thread = |
116 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE); | 117 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE); |
117 InitInternal(user_data_directory, | 118 InitInternal(user_data_directory, std::move(database_task_manager), |
118 database_task_manager.Pass(), | 119 disk_cache_thread, quota_manager_proxy, special_storage_policy); |
119 disk_cache_thread, | |
120 quota_manager_proxy, | |
121 special_storage_policy); | |
122 } | 120 } |
123 | 121 |
124 void ServiceWorkerContextWrapper::Shutdown() { | 122 void ServiceWorkerContextWrapper::Shutdown() { |
125 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 123 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
126 | 124 |
127 storage_partition_ = nullptr; | 125 storage_partition_ = nullptr; |
128 process_manager_->Shutdown(); | 126 process_manager_->Shutdown(); |
129 BrowserThread::PostTask( | 127 BrowserThread::PostTask( |
130 BrowserThread::IO, | 128 BrowserThread::IO, |
131 FROM_HERE, | 129 FROM_HERE, |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 return; | 669 return; |
672 } | 670 } |
673 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed. | 671 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed. |
674 tracked_objects::ScopedTracker tracking_profile( | 672 tracked_objects::ScopedTracker tracking_profile( |
675 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 673 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
676 "477117 ServiceWorkerContextWrapper::InitInternal")); | 674 "477117 ServiceWorkerContextWrapper::InitInternal")); |
677 DCHECK(!context_core_); | 675 DCHECK(!context_core_); |
678 if (quota_manager_proxy) { | 676 if (quota_manager_proxy) { |
679 quota_manager_proxy->RegisterClient(new ServiceWorkerQuotaClient(this)); | 677 quota_manager_proxy->RegisterClient(new ServiceWorkerQuotaClient(this)); |
680 } | 678 } |
681 context_core_.reset(new ServiceWorkerContextCore(user_data_directory, | 679 context_core_.reset(new ServiceWorkerContextCore( |
682 database_task_manager.Pass(), | 680 user_data_directory, std::move(database_task_manager), disk_cache_thread, |
683 disk_cache_thread, | 681 quota_manager_proxy, special_storage_policy, observer_list_.get(), this)); |
684 quota_manager_proxy, | |
685 special_storage_policy, | |
686 observer_list_.get(), | |
687 this)); | |
688 } | 682 } |
689 | 683 |
690 void ServiceWorkerContextWrapper::ShutdownOnIO() { | 684 void ServiceWorkerContextWrapper::ShutdownOnIO() { |
691 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 685 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
692 resource_context_ = nullptr; | 686 resource_context_ = nullptr; |
693 context_core_.reset(); | 687 context_core_.reset(); |
694 } | 688 } |
695 | 689 |
696 void ServiceWorkerContextWrapper::DidDeleteAndStartOver( | 690 void ServiceWorkerContextWrapper::DidDeleteAndStartOver( |
697 ServiceWorkerStatusCode status) { | 691 ServiceWorkerStatusCode status) { |
698 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 692 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
699 if (status != SERVICE_WORKER_OK) { | 693 if (status != SERVICE_WORKER_OK) { |
700 context_core_.reset(); | 694 context_core_.reset(); |
701 return; | 695 return; |
702 } | 696 } |
703 context_core_.reset(new ServiceWorkerContextCore(context_core_.get(), this)); | 697 context_core_.reset(new ServiceWorkerContextCore(context_core_.get(), this)); |
704 DVLOG(1) << "Restarted ServiceWorkerContextCore successfully."; | 698 DVLOG(1) << "Restarted ServiceWorkerContextCore successfully."; |
705 | 699 |
706 observer_list_->Notify(FROM_HERE, | 700 observer_list_->Notify(FROM_HERE, |
707 &ServiceWorkerContextObserver::OnStorageWiped); | 701 &ServiceWorkerContextObserver::OnStorageWiped); |
708 } | 702 } |
709 | 703 |
710 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { | 704 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { |
711 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 705 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
712 return context_core_.get(); | 706 return context_core_.get(); |
713 } | 707 } |
714 | 708 |
715 } // namespace content | 709 } // namespace content |
OLD | NEW |