OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ios/chrome/browser/application_context_impl.h" | 5 #include "ios/chrome/browser/application_context_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 #include "ios/chrome/common/channel_info.h" | 50 #include "ios/chrome/common/channel_info.h" |
51 #include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.
h" | 51 #include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.
h" |
52 #include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state_
manager.h" | 52 #include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state_
manager.h" |
53 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 53 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
54 #include "ios/web/public/web_thread.h" | 54 #include "ios/web/public/web_thread.h" |
55 #include "net/log/net_log_capture_mode.h" | 55 #include "net/log/net_log_capture_mode.h" |
56 #include "net/socket/client_socket_pool_manager.h" | 56 #include "net/socket/client_socket_pool_manager.h" |
57 #include "net/url_request/url_request_context_getter.h" | 57 #include "net/url_request/url_request_context_getter.h" |
58 | 58 |
59 namespace { | 59 namespace { |
60 | |
61 // Dummy flag because iOS does not support disabling background networking. | 60 // Dummy flag because iOS does not support disabling background networking. |
62 extern const char kDummyDisableBackgroundNetworking[] = | 61 extern const char kDummyDisableBackgroundNetworking[] = |
63 "dummy-disable-background-networking"; | 62 "dummy-disable-background-networking"; |
64 | |
65 } | 63 } |
66 | 64 |
67 ApplicationContextImpl::ApplicationContextImpl( | 65 ApplicationContextImpl::ApplicationContextImpl( |
68 base::SequencedTaskRunner* local_state_task_runner, | 66 base::SequencedTaskRunner* local_state_task_runner, |
69 const base::CommandLine& command_line, | 67 const base::CommandLine& command_line, |
70 const std::string& locale) | 68 const std::string& locale) |
71 : local_state_task_runner_(local_state_task_runner), | 69 : local_state_task_runner_(local_state_task_runner), |
72 was_last_shutdown_clean_(false), | 70 was_last_shutdown_clean_(false), |
73 created_local_state_(false) { | 71 created_local_state_(false) { |
74 DCHECK(!GetApplicationContext()); | 72 DCHECK(!GetApplicationContext()); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 // SafeBrowsing before the IO thread gets destroyed, since their destructors | 126 // SafeBrowsing before the IO thread gets destroyed, since their destructors |
129 // can call the URLFetcher destructor, which does a PostDelayedTask operation | 127 // can call the URLFetcher destructor, which does a PostDelayedTask operation |
130 // on the IO thread. (The IO thread will handle that URLFetcher operation | 128 // on the IO thread. (The IO thread will handle that URLFetcher operation |
131 // before going away.) | 129 // before going away.) |
132 if (safe_browsing_service_) | 130 if (safe_browsing_service_) |
133 safe_browsing_service_->ShutDown(); | 131 safe_browsing_service_->ShutDown(); |
134 | 132 |
135 metrics_services_manager_.reset(); | 133 metrics_services_manager_.reset(); |
136 | 134 |
137 // Need to clear browser states before the IO thread. | 135 // Need to clear browser states before the IO thread. |
138 // TODO(crbug.com/560854): the ShutDown() method can be folded into the | 136 if (chrome_browser_state_manager_) { |
139 // destructor once ApplicationContextImpl owns ChromeBrowserStateManager. | 137 // TODO(crbug.com/560854): the ShutDown() method can be folded into the |
140 GetChromeBrowserStateManager()->ShutDown(); | 138 // destructor once ApplicationContextImpl owns ChromeBrowserStateManager. |
| 139 chrome_browser_state_manager_->ShutDown(); |
| 140 chrome_browser_state_manager_.reset(); |
| 141 } |
141 | 142 |
142 // PromoResourceService must be destroyed after the keyed services and before | 143 // PromoResourceService must be destroyed after the keyed services and before |
143 // the IO thread. | 144 // the IO thread. |
144 promo_resource_service_.reset(); | 145 promo_resource_service_.reset(); |
145 | 146 |
146 // The GCMDriver must shut down while the IO thread is still alive. | 147 // The GCMDriver must shut down while the IO thread is still alive. |
147 if (gcm_driver_) | 148 if (gcm_driver_) |
148 gcm_driver_->Shutdown(); | 149 gcm_driver_->Shutdown(); |
149 | 150 |
150 if (local_state_) { | 151 if (local_state_) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 | 234 |
234 const std::string& ApplicationContextImpl::GetApplicationLocale() { | 235 const std::string& ApplicationContextImpl::GetApplicationLocale() { |
235 DCHECK(thread_checker_.CalledOnValidThread()); | 236 DCHECK(thread_checker_.CalledOnValidThread()); |
236 DCHECK(!application_locale_.empty()); | 237 DCHECK(!application_locale_.empty()); |
237 return application_locale_; | 238 return application_locale_; |
238 } | 239 } |
239 | 240 |
240 ios::ChromeBrowserStateManager* | 241 ios::ChromeBrowserStateManager* |
241 ApplicationContextImpl::GetChromeBrowserStateManager() { | 242 ApplicationContextImpl::GetChromeBrowserStateManager() { |
242 DCHECK(thread_checker_.CalledOnValidThread()); | 243 DCHECK(thread_checker_.CalledOnValidThread()); |
243 return ios::GetChromeBrowserProvider()->GetChromeBrowserStateManager(); | 244 if (!chrome_browser_state_manager_) { |
| 245 chrome_browser_state_manager_ = |
| 246 ios::GetChromeBrowserProvider()->CreateChromeBrowserStateManager(); |
| 247 DCHECK(chrome_browser_state_manager_.get()); |
| 248 } |
| 249 return chrome_browser_state_manager_.get(); |
244 } | 250 } |
245 | 251 |
246 metrics_services_manager::MetricsServicesManager* | 252 metrics_services_manager::MetricsServicesManager* |
247 ApplicationContextImpl::GetMetricsServicesManager() { | 253 ApplicationContextImpl::GetMetricsServicesManager() { |
248 DCHECK(thread_checker_.CalledOnValidThread()); | 254 DCHECK(thread_checker_.CalledOnValidThread()); |
249 if (!metrics_services_manager_) { | 255 if (!metrics_services_manager_) { |
250 metrics_services_manager_.reset( | 256 metrics_services_manager_.reset( |
251 new metrics_services_manager::MetricsServicesManager(make_scoped_ptr( | 257 new metrics_services_manager::MetricsServicesManager(make_scoped_ptr( |
252 new IOSChromeMetricsServicesManagerClient(GetLocalState())))); | 258 new IOSChromeMetricsServicesManagerClient(GetLocalState())))); |
253 } | 259 } |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 worker_pool->GetSequenceToken(), | 390 worker_pool->GetSequenceToken(), |
385 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); | 391 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); |
386 | 392 |
387 gcm_driver_ = gcm::CreateGCMDriverDesktop( | 393 gcm_driver_ = gcm::CreateGCMDriverDesktop( |
388 make_scoped_ptr(new gcm::GCMClientFactory), GetLocalState(), store_path, | 394 make_scoped_ptr(new gcm::GCMClientFactory), GetLocalState(), store_path, |
389 GetSystemURLRequestContext(), ::GetChannel(), | 395 GetSystemURLRequestContext(), ::GetChannel(), |
390 web::WebThread::GetTaskRunnerForThread(web::WebThread::UI), | 396 web::WebThread::GetTaskRunnerForThread(web::WebThread::UI), |
391 web::WebThread::GetTaskRunnerForThread(web::WebThread::IO), | 397 web::WebThread::GetTaskRunnerForThread(web::WebThread::IO), |
392 blocking_task_runner); | 398 blocking_task_runner); |
393 } | 399 } |
OLD | NEW |