OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/browser_process_impl.h" | 5 #include "chrome/browser/browser_process_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <map> | 10 #include <map> |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 #endif | 193 #endif |
194 | 194 |
195 using content::BrowserThread; | 195 using content::BrowserThread; |
196 using content::ChildProcessSecurityPolicy; | 196 using content::ChildProcessSecurityPolicy; |
197 using content::PluginService; | 197 using content::PluginService; |
198 using content::ResourceDispatcherHost; | 198 using content::ResourceDispatcherHost; |
199 | 199 |
200 BrowserProcessImpl::BrowserProcessImpl( | 200 BrowserProcessImpl::BrowserProcessImpl( |
201 base::SequencedTaskRunner* local_state_task_runner, | 201 base::SequencedTaskRunner* local_state_task_runner, |
202 const base::CommandLine& command_line) | 202 const base::CommandLine& command_line) |
| 203 : BrowserProcessImpl::BrowserProcessImpl( |
| 204 local_state_task_runner, |
| 205 command_line, |
| 206 true /* initialize_message_center */) {} |
| 207 |
| 208 BrowserProcessImpl::BrowserProcessImpl( |
| 209 base::SequencedTaskRunner* local_state_task_runner, |
| 210 const base::CommandLine& command_line, |
| 211 bool initialize_message_center) |
203 : created_watchdog_thread_(false), | 212 : created_watchdog_thread_(false), |
204 created_browser_policy_connector_(false), | 213 created_browser_policy_connector_(false), |
205 created_profile_manager_(false), | 214 created_profile_manager_(false), |
206 created_local_state_(false), | 215 created_local_state_(false), |
207 created_icon_manager_(false), | 216 created_icon_manager_(false), |
208 created_notification_ui_manager_(false), | 217 created_notification_ui_manager_(false), |
209 created_notification_bridge_(false), | 218 created_notification_bridge_(false), |
210 created_safe_browsing_service_(false), | 219 created_safe_browsing_service_(false), |
211 created_subresource_filter_ruleset_service_(false), | 220 created_subresource_filter_ruleset_service_(false), |
212 shutting_down_(false), | 221 shutting_down_(false), |
213 tearing_down_(false), | 222 tearing_down_(false), |
214 download_status_updater_(new DownloadStatusUpdater), | 223 download_status_updater_(new DownloadStatusUpdater), |
215 local_state_task_runner_(local_state_task_runner), | 224 local_state_task_runner_(local_state_task_runner), |
216 cached_default_web_client_state_(shell_integration::UNKNOWN_DEFAULT) { | 225 cached_default_web_client_state_(shell_integration::UNKNOWN_DEFAULT), |
| 226 initialize_message_center_(initialize_message_center) { |
217 g_browser_process = this; | 227 g_browser_process = this; |
218 platform_part_.reset(new BrowserProcessPlatformPart()); | 228 platform_part_.reset(new BrowserProcessPlatformPart()); |
219 | 229 |
220 #if BUILDFLAG(ENABLE_PRINTING) | 230 #if BUILDFLAG(ENABLE_PRINTING) |
221 // Must be created after the NotificationService. | 231 // Must be created after the NotificationService. |
222 print_job_manager_.reset(new printing::PrintJobManager); | 232 print_job_manager_.reset(new printing::PrintJobManager); |
223 #endif | 233 #endif |
224 | 234 |
225 base::FilePath net_log_path; | 235 base::FilePath net_log_path; |
226 if (command_line.HasSwitch(switches::kLogNetLog)) | 236 if (command_line.HasSwitch(switches::kLogNetLog)) |
(...skipping 17 matching lines...) Expand all Loading... |
244 | 254 |
245 extension_event_router_forwarder_ = new extensions::EventRouterForwarder; | 255 extension_event_router_forwarder_ = new extensions::EventRouterForwarder; |
246 | 256 |
247 extensions::ExtensionsClient::Set( | 257 extensions::ExtensionsClient::Set( |
248 extensions::ChromeExtensionsClient::GetInstance()); | 258 extensions::ChromeExtensionsClient::GetInstance()); |
249 | 259 |
250 extensions_browser_client_.reset( | 260 extensions_browser_client_.reset( |
251 new extensions::ChromeExtensionsBrowserClient); | 261 new extensions::ChromeExtensionsBrowserClient); |
252 extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get()); | 262 extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get()); |
253 #endif | 263 #endif |
254 | 264 if (initialize_message_center_) |
255 message_center::MessageCenter::Initialize(); | 265 message_center::MessageCenter::Initialize(); |
256 | 266 |
257 update_client::UpdateQueryParams::SetDelegate( | 267 update_client::UpdateQueryParams::SetDelegate( |
258 ChromeUpdateQueryParamsDelegate::GetInstance()); | 268 ChromeUpdateQueryParamsDelegate::GetInstance()); |
259 | 269 |
260 #if !defined(OS_ANDROID) | 270 #if !defined(OS_ANDROID) |
261 KeepAliveRegistry::GetInstance()->AddObserver(this); | 271 KeepAliveRegistry::GetInstance()->AddObserver(this); |
262 #endif // !defined(OS_ANDROID) | 272 #endif // !defined(OS_ANDROID) |
263 } | 273 } |
264 | 274 |
265 BrowserProcessImpl::~BrowserProcessImpl() { | 275 BrowserProcessImpl::~BrowserProcessImpl() { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 | 338 |
329 #if BUILDFLAG(ENABLE_EXTENSIONS) | 339 #if BUILDFLAG(ENABLE_EXTENSIONS) |
330 media_file_system_registry_.reset(); | 340 media_file_system_registry_.reset(); |
331 // Remove the global instance of the Storage Monitor now. Otherwise the | 341 // Remove the global instance of the Storage Monitor now. Otherwise the |
332 // FILE thread would be gone when we try to release it in the dtor and | 342 // FILE thread would be gone when we try to release it in the dtor and |
333 // Valgrind would report a leak on almost every single browser_test. | 343 // Valgrind would report a leak on almost every single browser_test. |
334 // TODO(gbillock): Make this unnecessary. | 344 // TODO(gbillock): Make this unnecessary. |
335 storage_monitor::StorageMonitor::Destroy(); | 345 storage_monitor::StorageMonitor::Destroy(); |
336 #endif | 346 #endif |
337 | 347 |
338 message_center::MessageCenter::Shutdown(); | 348 if (initialize_message_center_) |
| 349 message_center::MessageCenter::Shutdown(); |
339 | 350 |
340 // The policy providers managed by |browser_policy_connector_| need to shut | 351 // The policy providers managed by |browser_policy_connector_| need to shut |
341 // down while the IO and FILE threads are still alive. The monitoring | 352 // down while the IO and FILE threads are still alive. The monitoring |
342 // framework owned by |browser_policy_connector_| relies on |gcm_driver_|, so | 353 // framework owned by |browser_policy_connector_| relies on |gcm_driver_|, so |
343 // this must be shutdown before |gcm_driver_| below. | 354 // this must be shutdown before |gcm_driver_| below. |
344 if (browser_policy_connector_) | 355 if (browser_policy_connector_) |
345 browser_policy_connector_->Shutdown(); | 356 browser_policy_connector_->Shutdown(); |
346 | 357 |
347 // The |gcm_driver_| must shut down while the IO thread is still alive. | 358 // The |gcm_driver_| must shut down while the IO thread is still alive. |
348 if (gcm_driver_) | 359 if (gcm_driver_) |
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1401 } | 1412 } |
1402 | 1413 |
1403 void BrowserProcessImpl::OnAutoupdateTimer() { | 1414 void BrowserProcessImpl::OnAutoupdateTimer() { |
1404 if (CanAutorestartForUpdate()) { | 1415 if (CanAutorestartForUpdate()) { |
1405 DLOG(WARNING) << "Detected update. Restarting browser."; | 1416 DLOG(WARNING) << "Detected update. Restarting browser."; |
1406 RestartBackgroundInstance(); | 1417 RestartBackgroundInstance(); |
1407 } | 1418 } |
1408 } | 1419 } |
1409 | 1420 |
1410 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 1421 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
OLD | NEW |