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 13 matching lines...) Expand all Loading... |
24 #include "components/history/core/browser/history_service.h" | 24 #include "components/history/core/browser/history_service.h" |
25 #include "components/keyed_service/core/service_access_type.h" | 25 #include "components/keyed_service/core/service_access_type.h" |
26 #include "components/metrics/metrics_service.h" | 26 #include "components/metrics/metrics_service.h" |
27 #include "components/metrics_services_manager/metrics_services_manager.h" | 27 #include "components/metrics_services_manager/metrics_services_manager.h" |
28 #include "components/net_log/chrome_net_log.h" | 28 #include "components/net_log/chrome_net_log.h" |
29 #include "components/network_time/network_time_tracker.h" | 29 #include "components/network_time/network_time_tracker.h" |
30 #include "components/physical_web/data_source/physical_web_data_source.h" | 30 #include "components/physical_web/data_source/physical_web_data_source.h" |
31 #include "components/prefs/pref_registry_simple.h" | 31 #include "components/prefs/pref_registry_simple.h" |
32 #include "components/prefs/pref_service.h" | 32 #include "components/prefs/pref_service.h" |
33 #include "components/translate/core/browser/translate_download_manager.h" | 33 #include "components/translate/core/browser/translate_download_manager.h" |
34 #include "components/ukm/ukm_service.h" | 34 #include "components/ukm/public/ukm_recorder.h" |
35 #include "components/update_client/configurator.h" | 35 #include "components/update_client/configurator.h" |
36 #include "components/update_client/update_query_params.h" | 36 #include "components/update_client/update_query_params.h" |
37 #include "components/variations/service/variations_service.h" | 37 #include "components/variations/service/variations_service.h" |
38 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 38 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
39 #include "ios/chrome/browser/browser_state/chrome_browser_state_manager_impl.h" | 39 #include "ios/chrome/browser/browser_state/chrome_browser_state_manager_impl.h" |
40 #include "ios/chrome/browser/chrome_paths.h" | 40 #include "ios/chrome/browser/chrome_paths.h" |
41 #include "ios/chrome/browser/component_updater/ios_component_updater_configurato
r.h" | 41 #include "ios/chrome/browser/component_updater/ios_component_updater_configurato
r.h" |
42 #include "ios/chrome/browser/history/history_service_factory.h" | 42 #include "ios/chrome/browser/history/history_service_factory.h" |
43 #include "ios/chrome/browser/ios_chrome_io_thread.h" | 43 #include "ios/chrome/browser/ios_chrome_io_thread.h" |
44 #include "ios/chrome/browser/metrics/ios_chrome_metrics_services_manager_client.
h" | 44 #include "ios/chrome/browser/metrics/ios_chrome_metrics_services_manager_client.
h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 134 |
135 // Tell the metrics services that the application resumes. | 135 // Tell the metrics services that the application resumes. |
136 metrics::MetricsService* metrics_service = GetMetricsService(); | 136 metrics::MetricsService* metrics_service = GetMetricsService(); |
137 if (metrics_service && local_state) { | 137 if (metrics_service && local_state) { |
138 metrics_service->OnAppEnterForeground(); | 138 metrics_service->OnAppEnterForeground(); |
139 local_state->CommitPendingWrite(); | 139 local_state->CommitPendingWrite(); |
140 } | 140 } |
141 variations::VariationsService* variations_service = GetVariationsService(); | 141 variations::VariationsService* variations_service = GetVariationsService(); |
142 if (variations_service) | 142 if (variations_service) |
143 variations_service->OnAppEnterForeground(); | 143 variations_service->OnAppEnterForeground(); |
144 ukm::UkmService* ukm_service = GetUkmService(); | 144 ukm::UkmService* ukm_service = GetMetricsServicesManager()->GetUkmService(); |
145 if (ukm_service) | 145 if (ukm_service) |
146 ukm_service->OnAppEnterForeground(); | 146 ukm_service->OnAppEnterForeground(); |
147 } | 147 } |
148 | 148 |
149 void ApplicationContextImpl::OnAppEnterBackground() { | 149 void ApplicationContextImpl::OnAppEnterBackground() { |
150 DCHECK(thread_checker_.CalledOnValidThread()); | 150 DCHECK(thread_checker_.CalledOnValidThread()); |
151 // Mark all the ChromeBrowserStates as clean and persist history. | 151 // Mark all the ChromeBrowserStates as clean and persist history. |
152 std::vector<ios::ChromeBrowserState*> loaded_browser_state = | 152 std::vector<ios::ChromeBrowserState*> loaded_browser_state = |
153 GetChromeBrowserStateManager()->GetLoadedBrowserStates(); | 153 GetChromeBrowserStateManager()->GetLoadedBrowserStates(); |
154 for (ios::ChromeBrowserState* browser_state : loaded_browser_state) { | 154 for (ios::ChromeBrowserState* browser_state : loaded_browser_state) { |
155 if (history::HistoryService* history_service = | 155 if (history::HistoryService* history_service = |
156 ios::HistoryServiceFactory::GetForBrowserStateIfExists( | 156 ios::HistoryServiceFactory::GetForBrowserStateIfExists( |
157 browser_state, ServiceAccessType::EXPLICIT_ACCESS)) { | 157 browser_state, ServiceAccessType::EXPLICIT_ACCESS)) { |
158 history_service->HandleBackgrounding(); | 158 history_service->HandleBackgrounding(); |
159 } | 159 } |
160 | 160 |
161 PrefService* browser_state_prefs = browser_state->GetPrefs(); | 161 PrefService* browser_state_prefs = browser_state->GetPrefs(); |
162 if (browser_state_prefs) | 162 if (browser_state_prefs) |
163 browser_state_prefs->CommitPendingWrite(); | 163 browser_state_prefs->CommitPendingWrite(); |
164 } | 164 } |
165 | 165 |
166 PrefService* local_state = GetLocalState(); | 166 PrefService* local_state = GetLocalState(); |
167 local_state->SetBoolean(prefs::kLastSessionExitedCleanly, true); | 167 local_state->SetBoolean(prefs::kLastSessionExitedCleanly, true); |
168 | 168 |
169 // Tell the metrics services they were cleanly shutdown. | 169 // Tell the metrics services they were cleanly shutdown. |
170 metrics::MetricsService* metrics_service = GetMetricsService(); | 170 metrics::MetricsService* metrics_service = GetMetricsService(); |
171 if (metrics_service && local_state) | 171 if (metrics_service && local_state) |
172 metrics_service->OnAppEnterBackground(); | 172 metrics_service->OnAppEnterBackground(); |
173 ukm::UkmService* ukm_service = GetUkmService(); | 173 ukm::UkmService* ukm_service = GetMetricsServicesManager()->GetUkmService(); |
174 if (ukm_service) | 174 if (ukm_service) |
175 ukm_service->OnAppEnterBackground(); | 175 ukm_service->OnAppEnterBackground(); |
176 | 176 |
177 // Persisting to disk is protected by a critical task, so no other special | 177 // Persisting to disk is protected by a critical task, so no other special |
178 // handling is necessary on iOS. | 178 // handling is necessary on iOS. |
179 } | 179 } |
180 | 180 |
181 bool ApplicationContextImpl::WasLastShutdownClean() { | 181 bool ApplicationContextImpl::WasLastShutdownClean() { |
182 DCHECK(thread_checker_.CalledOnValidThread()); | 182 DCHECK(thread_checker_.CalledOnValidThread()); |
183 // Make sure the locale state is created as the file is initialized there. | 183 // Make sure the locale state is created as the file is initialized there. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 GetLocalState()))); | 222 GetLocalState()))); |
223 } | 223 } |
224 return metrics_services_manager_.get(); | 224 return metrics_services_manager_.get(); |
225 } | 225 } |
226 | 226 |
227 metrics::MetricsService* ApplicationContextImpl::GetMetricsService() { | 227 metrics::MetricsService* ApplicationContextImpl::GetMetricsService() { |
228 DCHECK(thread_checker_.CalledOnValidThread()); | 228 DCHECK(thread_checker_.CalledOnValidThread()); |
229 return GetMetricsServicesManager()->GetMetricsService(); | 229 return GetMetricsServicesManager()->GetMetricsService(); |
230 } | 230 } |
231 | 231 |
232 ukm::UkmService* ApplicationContextImpl::GetUkmService() { | 232 ukm::UkmRecorder* ApplicationContextImpl::GetUkmRecorder() { |
233 DCHECK(thread_checker_.CalledOnValidThread()); | 233 DCHECK(thread_checker_.CalledOnValidThread()); |
234 return GetMetricsServicesManager()->GetUkmService(); | 234 return GetMetricsServicesManager()->GetUkmRecorder(); |
235 } | 235 } |
236 | 236 |
237 variations::VariationsService* ApplicationContextImpl::GetVariationsService() { | 237 variations::VariationsService* ApplicationContextImpl::GetVariationsService() { |
238 DCHECK(thread_checker_.CalledOnValidThread()); | 238 DCHECK(thread_checker_.CalledOnValidThread()); |
239 return GetMetricsServicesManager()->GetVariationsService(); | 239 return GetMetricsServicesManager()->GetVariationsService(); |
240 } | 240 } |
241 | 241 |
242 rappor::RapporServiceImpl* ApplicationContextImpl::GetRapporServiceImpl() { | 242 rappor::RapporServiceImpl* ApplicationContextImpl::GetRapporServiceImpl() { |
243 DCHECK(thread_checker_.CalledOnValidThread()); | 243 DCHECK(thread_checker_.CalledOnValidThread()); |
244 return GetMetricsServicesManager()->GetRapporServiceImpl(); | 244 return GetMetricsServicesManager()->GetRapporServiceImpl(); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); | 357 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); |
358 | 358 |
359 gcm_driver_ = gcm::CreateGCMDriverDesktop( | 359 gcm_driver_ = gcm::CreateGCMDriverDesktop( |
360 base::WrapUnique(new gcm::GCMClientFactory), GetLocalState(), store_path, | 360 base::WrapUnique(new gcm::GCMClientFactory), GetLocalState(), store_path, |
361 GetSystemURLRequestContext(), ::GetChannel(), | 361 GetSystemURLRequestContext(), ::GetChannel(), |
362 IOSChromeGCMProfileServiceFactory::GetProductCategoryForSubtypes(), | 362 IOSChromeGCMProfileServiceFactory::GetProductCategoryForSubtypes(), |
363 web::WebThread::GetTaskRunnerForThread(web::WebThread::UI), | 363 web::WebThread::GetTaskRunnerForThread(web::WebThread::UI), |
364 web::WebThread::GetTaskRunnerForThread(web::WebThread::IO), | 364 web::WebThread::GetTaskRunnerForThread(web::WebThread::IO), |
365 blocking_task_runner); | 365 blocking_task_runner); |
366 } | 366 } |
OLD | NEW |