| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 #include "chrome/common/chrome_notification_types.h" | 62 #include "chrome/common/chrome_notification_types.h" |
| 63 #include "chrome/common/chrome_paths.h" | 63 #include "chrome/common/chrome_paths.h" |
| 64 #include "chrome/common/chrome_switches.h" | 64 #include "chrome/common/chrome_switches.h" |
| 65 #include "chrome/common/extensions/extension_l10n_util.h" | 65 #include "chrome/common/extensions/extension_l10n_util.h" |
| 66 #include "chrome/common/extensions/extension_resource.h" | 66 #include "chrome/common/extensions/extension_resource.h" |
| 67 #include "chrome/common/json_pref_store.h" | 67 #include "chrome/common/json_pref_store.h" |
| 68 #include "chrome/common/pref_names.h" | 68 #include "chrome/common/pref_names.h" |
| 69 #include "chrome/common/switch_utils.h" | 69 #include "chrome/common/switch_utils.h" |
| 70 #include "chrome/common/url_constants.h" | 70 #include "chrome/common/url_constants.h" |
| 71 #include "chrome/installer/util/google_update_constants.h" | 71 #include "chrome/installer/util/google_update_constants.h" |
| 72 #include "content/browser/browser_process_sub_thread.h" | 72 #include "content/browser/browser_child_process_host.h" |
| 73 #include "content/browser/child_process_security_policy.h" | 73 #include "content/browser/child_process_security_policy.h" |
| 74 #include "content/browser/download/download_file_manager.h" | 74 #include "content/browser/download/download_file_manager.h" |
| 75 #include "content/browser/download/download_status_updater.h" | 75 #include "content/browser/download/download_status_updater.h" |
| 76 #include "content/browser/download/mhtml_generation_manager.h" | 76 #include "content/browser/download/mhtml_generation_manager.h" |
| 77 #include "content/browser/download/save_file_manager.h" | 77 #include "content/browser/download/save_file_manager.h" |
| 78 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 78 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
| 79 #include "content/browser/net/browser_online_state_observer.h" | 79 #include "content/browser/net/browser_online_state_observer.h" |
| 80 #include "content/browser/plugin_service.h" | 80 #include "content/browser/plugin_service.h" |
| 81 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 81 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 82 #include "content/public/browser/browser_thread.h" | 82 #include "content/public/browser/browser_thread.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // Linux. We have a timeout here because we're unable to run the UI messageloop | 118 // Linux. We have a timeout here because we're unable to run the UI messageloop |
| 119 // and there's some deadlock risk. Our only option is to exit anyway. | 119 // and there's some deadlock risk. Our only option is to exit anyway. |
| 120 static const int kEndSessionTimeoutSeconds = 10; | 120 static const int kEndSessionTimeoutSeconds = 10; |
| 121 #endif | 121 #endif |
| 122 | 122 |
| 123 using content::BrowserThread; | 123 using content::BrowserThread; |
| 124 | 124 |
| 125 BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line) | 125 BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line) |
| 126 : created_resource_dispatcher_host_(false), | 126 : created_resource_dispatcher_host_(false), |
| 127 created_metrics_service_(false), | 127 created_metrics_service_(false), |
| 128 created_io_thread_(false), | |
| 129 created_file_thread_(false), | |
| 130 created_db_thread_(false), | |
| 131 created_process_launcher_thread_(false), | |
| 132 created_cache_thread_(false), | |
| 133 created_watchdog_thread_(false), | 128 created_watchdog_thread_(false), |
| 134 #if defined(OS_CHROMEOS) | |
| 135 created_web_socket_proxy_thread_(false), | |
| 136 #endif | |
| 137 created_profile_manager_(false), | 129 created_profile_manager_(false), |
| 138 created_local_state_(false), | 130 created_local_state_(false), |
| 139 created_icon_manager_(false), | 131 created_icon_manager_(false), |
| 140 created_sidebar_manager_(false), | 132 created_sidebar_manager_(false), |
| 141 created_browser_policy_connector_(false), | 133 created_browser_policy_connector_(false), |
| 142 created_notification_ui_manager_(false), | 134 created_notification_ui_manager_(false), |
| 143 created_safe_browsing_service_(false), | 135 created_safe_browsing_service_(false), |
| 144 module_ref_count_(0), | 136 module_ref_count_(0), |
| 145 did_start_(false), | 137 did_start_(false), |
| 146 checked_for_new_frames_(false), | 138 checked_for_new_frames_(false), |
| (...skipping 12 matching lines...) Expand all Loading... |
| 159 chrome::kExtensionScheme); | 151 chrome::kExtensionScheme); |
| 160 | 152 |
| 161 extension_event_router_forwarder_ = new ExtensionEventRouterForwarder; | 153 extension_event_router_forwarder_ = new ExtensionEventRouterForwarder; |
| 162 | 154 |
| 163 ExtensionTabIdMap::GetInstance()->Init(); | 155 ExtensionTabIdMap::GetInstance()->Init(); |
| 164 | 156 |
| 165 online_state_observer_.reset(new BrowserOnlineStateObserver); | 157 online_state_observer_.reset(new BrowserOnlineStateObserver); |
| 166 } | 158 } |
| 167 | 159 |
| 168 BrowserProcessImpl::~BrowserProcessImpl() { | 160 BrowserProcessImpl::~BrowserProcessImpl() { |
| 169 #if defined(OS_CHROMEOS) | 161 // See StartTearDown and PreStopThread functions below, this is where |
| 170 if (web_socket_proxy_thread_.get()) | 162 // most destruction happens so that it can be interleaved with threads |
| 171 chromeos::WebSocketProxyController::Shutdown(); | 163 // going away. |
| 172 web_socket_proxy_thread_.reset(); | |
| 173 #endif | |
| 174 | 164 |
| 165 // Wait for the pending print jobs to finish. |
| 166 print_job_manager_->OnQuit(); |
| 167 print_job_manager_.reset(); |
| 168 |
| 169 g_browser_process = NULL; |
| 170 } |
| 171 |
| 172 void BrowserProcessImpl::StartTearDown() { |
| 175 // Delete the AutomationProviderList before NotificationService, | 173 // Delete the AutomationProviderList before NotificationService, |
| 176 // since it may try to unregister notifications | 174 // since it may try to unregister notifications |
| 177 // Both NotificationService and AutomationProvider are singleton instances in | 175 // Both NotificationService and AutomationProvider are singleton instances in |
| 178 // the BrowserProcess. Since AutomationProvider may have some active | 176 // the BrowserProcess. Since AutomationProvider may have some active |
| 179 // notification observers, it is essential that it gets destroyed before the | 177 // notification observers, it is essential that it gets destroyed before the |
| 180 // NotificationService. NotificationService won't be destroyed until after | 178 // NotificationService. NotificationService won't be destroyed until after |
| 181 // this destructor is run. | 179 // this destructor is run. |
| 182 automation_provider_list_.reset(); | 180 automation_provider_list_.reset(); |
| 183 | 181 |
| 184 // We need to shutdown the SdchDictionaryFetcher as it regularly holds | 182 // We need to shutdown the SdchDictionaryFetcher as it regularly holds |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 browser_policy_connector_.reset(); | 236 browser_policy_connector_.reset(); |
| 239 | 237 |
| 240 // Destroying the GpuProcessHostUIShims on the UI thread posts a task to | 238 // Destroying the GpuProcessHostUIShims on the UI thread posts a task to |
| 241 // delete related objects on the GPU thread. This must be done before | 239 // delete related objects on the GPU thread. This must be done before |
| 242 // stopping the GPU thread. The GPU thread will close IPC channels to renderer | 240 // stopping the GPU thread. The GPU thread will close IPC channels to renderer |
| 243 // processes so this has to happen before stopping the IO thread. | 241 // processes so this has to happen before stopping the IO thread. |
| 244 GpuProcessHostUIShim::DestroyAll(); | 242 GpuProcessHostUIShim::DestroyAll(); |
| 245 | 243 |
| 246 // Stop the watchdog thread before stopping other threads. | 244 // Stop the watchdog thread before stopping other threads. |
| 247 watchdog_thread_.reset(); | 245 watchdog_thread_.reset(); |
| 246 } |
| 248 | 247 |
| 249 // Need to stop io_thread_ before resource_dispatcher_host_, since | 248 void BrowserProcessImpl::PreStopThread(BrowserThread::ID thread_id) { |
| 250 // io_thread_ may still deref ResourceDispatcherHost and handle resource | 249 switch (thread_id) { |
| 251 // request before going away. | 250 #if defined(OS_CHROMEOS) |
| 252 io_thread_.reset(); | 251 case BrowserThread::WEB_SOCKET_PROXY: |
| 252 chromeos::WebSocketProxyController::Shutdown(); |
| 253 break; |
| 254 #endif |
| 255 case BrowserThread::IO: |
| 256 BrowserThread::PostTask( |
| 257 BrowserThread::IO, |
| 258 FROM_HERE, |
| 259 base::Bind(&IOThread::WillDestroyCurrentMessageLoop, |
| 260 base::Unretained(io_thread_.get()))); |
| 261 break; |
| 262 case BrowserThread::FILE: |
| 263 // Clean up state that lives on or uses the file_thread_ before |
| 264 // it goes away. |
| 265 if (resource_dispatcher_host_.get()) { |
| 266 resource_dispatcher_host()->download_file_manager()->Shutdown(); |
| 267 resource_dispatcher_host()->save_file_manager()->Shutdown(); |
| 268 } |
| 269 break; |
| 270 case BrowserThread::WEBKIT: |
| 271 // Need to destroy ResourceDispatcherHost before PluginService |
| 272 // and SafeBrowsingService, since it caches a pointer to |
| 273 // it. This also causes the webkit thread to terminate (which is |
| 274 // still the responsibility of the embedder, not of the content |
| 275 // framework). |
| 276 resource_dispatcher_host_.reset(); |
| 277 break; |
| 278 default: |
| 279 break; |
| 280 } |
| 281 } |
| 253 | 282 |
| 254 // The IO thread was the only user of this thread. | 283 void BrowserProcessImpl::PostStopThread(BrowserThread::ID thread_id) { |
| 255 cache_thread_.reset(); | 284 switch (thread_id) { |
| 256 | 285 case BrowserThread::FILE: |
| 257 // Stop the process launcher thread after the IO thread, in case the IO thread | 286 // With the file_thread_ flushed, we can release any icon resources. |
| 258 // posted a task to terminate a process on the process launcher thread. | 287 icon_manager_.reset(); |
| 259 process_launcher_thread_.reset(); | 288 break; |
| 260 | 289 case BrowserThread::IO: |
| 261 // Clean up state that lives on the file_thread_ before it goes away. | 290 // Reset associated state right after actual thread is stopped, |
| 262 if (resource_dispatcher_host_.get()) { | 291 // as io_thread_.global_ cleanup happens in CleanUp on the IO |
| 263 resource_dispatcher_host()->download_file_manager()->Shutdown(); | 292 // thread, i.e. as the thread exits its message loop. |
| 264 resource_dispatcher_host()->save_file_manager()->Shutdown(); | 293 io_thread_.reset(); |
| 294 break; |
| 295 default: |
| 296 break; |
| 265 } | 297 } |
| 266 | |
| 267 // Need to stop the file_thread_ here to force it to process messages in its | |
| 268 // message loop from the previous call to shutdown the DownloadFileManager, | |
| 269 // SaveFileManager and SessionService. | |
| 270 file_thread_.reset(); | |
| 271 | |
| 272 // With the file_thread_ flushed, we can release any icon resources. | |
| 273 icon_manager_.reset(); | |
| 274 | |
| 275 // Need to destroy ResourceDispatcherHost before PluginService and | |
| 276 // SafeBrowsingService, since it caches a pointer to it. This also | |
| 277 // causes the webkit thread to terminate. | |
| 278 resource_dispatcher_host_.reset(); | |
| 279 | |
| 280 // Wait for the pending print jobs to finish. | |
| 281 print_job_manager_->OnQuit(); | |
| 282 print_job_manager_.reset(); | |
| 283 | |
| 284 // Destroy TabCloseableStateWatcher before NotificationService since the | |
| 285 // former registers for notifications. | |
| 286 tab_closeable_state_watcher_.reset(); | |
| 287 | |
| 288 g_browser_process = NULL; | |
| 289 } | 298 } |
| 290 | 299 |
| 291 #if defined(OS_WIN) | 300 #if defined(OS_WIN) |
| 292 // Send a QuitTask to the given MessageLoop when the (file) thread has processed | 301 // Send a QuitTask to the given MessageLoop when the (file) thread has processed |
| 293 // our (other) recent requests (to save preferences). | 302 // our (other) recent requests (to save preferences). |
| 294 // Change the boolean so that the receiving thread will know that we did indeed | 303 // Change the boolean so that the receiving thread will know that we did indeed |
| 295 // send the QuitTask that terminated the message loop. | 304 // send the QuitTask that terminated the message loop. |
| 296 static void PostQuit(MessageLoop* message_loop) { | 305 static void PostQuit(MessageLoop* message_loop) { |
| 297 g_end_session_file_thread_has_completed = true; | 306 g_end_session_file_thread_has_completed = true; |
| 298 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask()); | 307 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask()); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 | 401 |
| 393 MetricsService* BrowserProcessImpl::metrics_service() { | 402 MetricsService* BrowserProcessImpl::metrics_service() { |
| 394 DCHECK(CalledOnValidThread()); | 403 DCHECK(CalledOnValidThread()); |
| 395 if (!created_metrics_service_) | 404 if (!created_metrics_service_) |
| 396 CreateMetricsService(); | 405 CreateMetricsService(); |
| 397 return metrics_service_.get(); | 406 return metrics_service_.get(); |
| 398 } | 407 } |
| 399 | 408 |
| 400 IOThread* BrowserProcessImpl::io_thread() { | 409 IOThread* BrowserProcessImpl::io_thread() { |
| 401 DCHECK(CalledOnValidThread()); | 410 DCHECK(CalledOnValidThread()); |
| 402 if (!created_io_thread_) | 411 DCHECK(io_thread_.get()); |
| 403 CreateIOThread(); | |
| 404 return io_thread_.get(); | 412 return io_thread_.get(); |
| 405 } | 413 } |
| 406 | 414 |
| 407 base::Thread* BrowserProcessImpl::file_thread() { | 415 base::Thread* BrowserProcessImpl::file_thread() { |
| 408 DCHECK(CalledOnValidThread()); | 416 DCHECK(CalledOnValidThread()); |
| 409 if (!created_file_thread_) | 417 return BrowserThread::UnsafeGetBrowserThread(BrowserThread::FILE); |
| 410 CreateFileThread(); | |
| 411 return file_thread_.get(); | |
| 412 } | 418 } |
| 413 | 419 |
| 414 base::Thread* BrowserProcessImpl::db_thread() { | 420 base::Thread* BrowserProcessImpl::db_thread() { |
| 415 DCHECK(CalledOnValidThread()); | 421 DCHECK(CalledOnValidThread()); |
| 416 if (!created_db_thread_) | 422 return BrowserThread::UnsafeGetBrowserThread(BrowserThread::DB); |
| 417 CreateDBThread(); | |
| 418 return db_thread_.get(); | |
| 419 } | 423 } |
| 420 | 424 |
| 421 base::Thread* BrowserProcessImpl::process_launcher_thread() { | 425 base::Thread* BrowserProcessImpl::process_launcher_thread() { |
| 422 DCHECK(CalledOnValidThread()); | 426 DCHECK(CalledOnValidThread()); |
| 423 if (!created_process_launcher_thread_) | 427 return BrowserThread::UnsafeGetBrowserThread(BrowserThread::PROCESS_LAUNCHER); |
| 424 CreateProcessLauncherThread(); | |
| 425 return process_launcher_thread_.get(); | |
| 426 } | 428 } |
| 427 | 429 |
| 428 base::Thread* BrowserProcessImpl::cache_thread() { | 430 base::Thread* BrowserProcessImpl::cache_thread() { |
| 429 DCHECK(CalledOnValidThread()); | 431 DCHECK(CalledOnValidThread()); |
| 430 if (!created_cache_thread_) | 432 return BrowserThread::UnsafeGetBrowserThread(BrowserThread::CACHE); |
| 431 CreateCacheThread(); | |
| 432 return cache_thread_.get(); | |
| 433 } | 433 } |
| 434 | 434 |
| 435 WatchDogThread* BrowserProcessImpl::watchdog_thread() { | 435 WatchDogThread* BrowserProcessImpl::watchdog_thread() { |
| 436 DCHECK(CalledOnValidThread()); | 436 DCHECK(CalledOnValidThread()); |
| 437 if (!created_watchdog_thread_) | 437 if (!created_watchdog_thread_) |
| 438 CreateWatchdogThread(); | 438 CreateWatchdogThread(); |
| 439 DCHECK(watchdog_thread_.get() != NULL); | 439 DCHECK(watchdog_thread_.get() != NULL); |
| 440 return watchdog_thread_.get(); | 440 return watchdog_thread_.get(); |
| 441 } | 441 } |
| 442 | 442 |
| 443 #if defined(OS_CHROMEOS) | 443 #if defined(OS_CHROMEOS) |
| 444 base::Thread* BrowserProcessImpl::web_socket_proxy_thread() { | 444 base::Thread* BrowserProcessImpl::web_socket_proxy_thread() { |
| 445 DCHECK(CalledOnValidThread()); | 445 DCHECK(CalledOnValidThread()); |
| 446 if (!created_web_socket_proxy_thread_) | 446 return BrowserThread::UnsafeGetBrowserThread(BrowserThread::WEB_SOCKET_PROXY); |
| 447 CreateWebSocketProxyThread(); | |
| 448 DCHECK(web_socket_proxy_thread_.get() != NULL); | |
| 449 return web_socket_proxy_thread_.get(); | |
| 450 } | 447 } |
| 451 #endif | 448 #endif |
| 452 | 449 |
| 453 ProfileManager* BrowserProcessImpl::profile_manager() { | 450 ProfileManager* BrowserProcessImpl::profile_manager() { |
| 454 DCHECK(CalledOnValidThread()); | 451 DCHECK(CalledOnValidThread()); |
| 455 if (!created_profile_manager_) | 452 if (!created_profile_manager_) |
| 456 CreateProfileManager(); | 453 CreateProfileManager(); |
| 457 return profile_manager_.get(); | 454 return profile_manager_.get(); |
| 458 } | 455 } |
| 459 | 456 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 | 641 |
| 645 safe_browsing::ClientSideDetectionService* | 642 safe_browsing::ClientSideDetectionService* |
| 646 BrowserProcessImpl::safe_browsing_detection_service() { | 643 BrowserProcessImpl::safe_browsing_detection_service() { |
| 647 DCHECK(CalledOnValidThread()); | 644 DCHECK(CalledOnValidThread()); |
| 648 if (safe_browsing_service()) | 645 if (safe_browsing_service()) |
| 649 return safe_browsing_service()->safe_browsing_detection_service(); | 646 return safe_browsing_service()->safe_browsing_detection_service(); |
| 650 return NULL; | 647 return NULL; |
| 651 } | 648 } |
| 652 | 649 |
| 653 bool BrowserProcessImpl::plugin_finder_disabled() const { | 650 bool BrowserProcessImpl::plugin_finder_disabled() const { |
| 654 return *plugin_finder_disabled_pref_; | 651 if (plugin_finder_disabled_pref_.get()) |
| 652 return plugin_finder_disabled_pref_->GetValue(); |
| 653 else |
| 654 return false; |
| 655 } | 655 } |
| 656 | 656 |
| 657 void BrowserProcessImpl::Observe(int type, | 657 void BrowserProcessImpl::Observe(int type, |
| 658 const content::NotificationSource& source, | 658 const content::NotificationSource& source, |
| 659 const content::NotificationDetails& details) { | 659 const content::NotificationDetails& details) { |
| 660 if (type == chrome::NOTIFICATION_PREF_CHANGED) { | 660 if (type == chrome::NOTIFICATION_PREF_CHANGED) { |
| 661 std::string* pref = content::Details<std::string>(details).ptr(); | 661 std::string* pref = content::Details<std::string>(details).ptr(); |
| 662 if (*pref == prefs::kDefaultBrowserSettingEnabled) { | 662 if (*pref == prefs::kDefaultBrowserSettingEnabled) { |
| 663 ApplyDefaultBrowserPolicy(); | 663 ApplyDefaultBrowserPolicy(); |
| 664 } else if (*pref == prefs::kDisabledSchemes) { | 664 } else if (*pref == prefs::kDisabledSchemes) { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 ApplyAllowCrossOriginAuthPromptPolicy(); | 759 ApplyAllowCrossOriginAuthPromptPolicy(); |
| 760 } | 760 } |
| 761 | 761 |
| 762 void BrowserProcessImpl::CreateMetricsService() { | 762 void BrowserProcessImpl::CreateMetricsService() { |
| 763 DCHECK(!created_metrics_service_ && metrics_service_.get() == NULL); | 763 DCHECK(!created_metrics_service_ && metrics_service_.get() == NULL); |
| 764 created_metrics_service_ = true; | 764 created_metrics_service_ = true; |
| 765 | 765 |
| 766 metrics_service_.reset(new MetricsService); | 766 metrics_service_.reset(new MetricsService); |
| 767 } | 767 } |
| 768 | 768 |
| 769 void BrowserProcessImpl::CreateIOThread() { | 769 void BrowserProcessImpl::CreateIOThreadState() { |
| 770 DCHECK(!created_io_thread_ && io_thread_.get() == NULL); | 770 DCHECK(!io_thread_.get()); |
| 771 created_io_thread_ = true; | |
| 772 | 771 |
| 773 // Prior to starting the io thread, we create the plugin service as | 772 // Prior to allowing any processing on the io thread, we create the |
| 774 // it is predominantly used from the io thread, but must be created | 773 // plugin service as it is predominantly used from the io thread, |
| 775 // on the main thread. The service ctor is inexpensive and does not | 774 // but must be created on the main thread. The service ctor is |
| 776 // invoke the io_thread() accessor. | 775 // inexpensive and does not invoke the io_thread() accessor. |
| 777 PluginService* plugin_service = PluginService::GetInstance(); | 776 PluginService* plugin_service = PluginService::GetInstance(); |
| 778 plugin_service->Init(); | 777 plugin_service->Init(); |
| 779 plugin_service->set_filter(ChromePluginServiceFilter::GetInstance()); | 778 plugin_service->set_filter(ChromePluginServiceFilter::GetInstance()); |
| 780 plugin_service->StartWatchingPlugins(); | 779 plugin_service->StartWatchingPlugins(); |
| 781 | 780 |
| 782 // Register the internal Flash if available. | 781 // Register the internal Flash if available. |
| 783 FilePath path; | 782 FilePath path; |
| 784 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 783 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 785 switches::kDisableInternalFlash) && | 784 switches::kDisableInternalFlash) && |
| 786 PathService::Get(chrome::FILE_FLASH_PLUGIN, &path)) { | 785 PathService::Get(chrome::FILE_FLASH_PLUGIN, &path)) { |
| 787 plugin_service->AddExtraPluginPath(path); | 786 plugin_service->AddExtraPluginPath(path); |
| 788 } | 787 } |
| 789 | 788 |
| 790 #if defined(OS_POSIX) | 789 #if defined(OS_POSIX) |
| 791 // Also find plugins in a user-specific plugins dir, | 790 // Also find plugins in a user-specific plugins dir, |
| 792 // e.g. ~/.config/chromium/Plugins. | 791 // e.g. ~/.config/chromium/Plugins. |
| 793 FilePath user_data_dir; | 792 FilePath user_data_dir; |
| 794 if (PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { | 793 if (PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { |
| 795 plugin_service->AddExtraPluginPath(user_data_dir.Append("Plugins")); | 794 plugin_service->AddExtraPluginPath(user_data_dir.Append("Plugins")); |
| 796 } | 795 } |
| 797 #endif | 796 #endif |
| 798 | 797 |
| 799 scoped_ptr<IOThread> thread(new IOThread( | 798 scoped_ptr<IOThread> thread(new IOThread( |
| 800 local_state(), net_log_.get(), extension_event_router_forwarder_.get())); | 799 local_state(), net_log_.get(), extension_event_router_forwarder_.get())); |
| 801 base::Thread::Options options; | |
| 802 options.message_loop_type = MessageLoop::TYPE_IO; | |
| 803 if (!thread->StartWithOptions(options)) | |
| 804 return; | |
| 805 io_thread_.swap(thread); | 800 io_thread_.swap(thread); |
| 806 } | |
| 807 | 801 |
| 808 void BrowserProcessImpl::CreateFileThread() { | 802 // The very first Chrome-specific task on the IO thread must be to |
| 809 DCHECK(!created_file_thread_ && file_thread_.get() == NULL); | 803 // initialize its global state. Right after that happens, the |
| 810 created_file_thread_ = true; | 804 // SystemRequestContext state must be initialized on the UI thread, |
| 811 | 805 // as that in turn triggers its initialization on the IO thread, |
| 812 scoped_ptr<base::Thread> thread( | 806 // which can't be done until the IO thread's message loop exists. |
| 813 new content::BrowserProcessSubThread(BrowserThread::FILE)); | 807 // |
| 814 base::Thread::Options options; | 808 // The io_thread_ object is guaranteed to outlive the thread, as it |
| 815 #if defined(OS_WIN) | 809 // is destroyed only during the call to PostStopThread(IO), at which |
| 816 // On Windows, the FILE thread needs to be have a UI message loop which pumps | 810 // point the IO thread has stopped. |
| 817 // messages in such a way that Google Update can communicate back to us. | 811 BrowserThread::PostTaskAndReply( |
| 818 options.message_loop_type = MessageLoop::TYPE_UI; | 812 BrowserThread::IO, |
| 819 #else | 813 FROM_HERE, |
| 820 options.message_loop_type = MessageLoop::TYPE_IO; | 814 base::Bind(&IOThread::InitializeGlobalState, |
| 821 #endif | 815 base::Unretained(io_thread_.get())), |
| 822 if (!thread->StartWithOptions(options)) | 816 base::Bind(&IOThread::InitSystemRequestContext, |
| 823 return; | 817 base::Unretained(io_thread_.get()))); |
| 824 file_thread_.swap(thread); | |
| 825 } | |
| 826 | |
| 827 #if defined(OS_CHROMEOS) | |
| 828 void BrowserProcessImpl::CreateWebSocketProxyThread() { | |
| 829 DCHECK(!created_web_socket_proxy_thread_); | |
| 830 DCHECK(web_socket_proxy_thread_.get() == NULL); | |
| 831 created_web_socket_proxy_thread_ = true; | |
| 832 | |
| 833 scoped_ptr<base::Thread> thread( | |
| 834 new content::BrowserProcessSubThread(BrowserThread::WEB_SOCKET_PROXY)); | |
| 835 base::Thread::Options options; | |
| 836 options.message_loop_type = MessageLoop::TYPE_IO; | |
| 837 if (!thread->StartWithOptions(options)) | |
| 838 return; | |
| 839 web_socket_proxy_thread_.swap(thread); | |
| 840 } | |
| 841 #endif | |
| 842 | |
| 843 void BrowserProcessImpl::CreateDBThread() { | |
| 844 DCHECK(!created_db_thread_ && db_thread_.get() == NULL); | |
| 845 created_db_thread_ = true; | |
| 846 | |
| 847 scoped_ptr<base::Thread> thread( | |
| 848 new content::BrowserProcessSubThread(BrowserThread::DB)); | |
| 849 if (!thread->Start()) | |
| 850 return; | |
| 851 db_thread_.swap(thread); | |
| 852 } | |
| 853 | |
| 854 void BrowserProcessImpl::CreateProcessLauncherThread() { | |
| 855 DCHECK(!created_process_launcher_thread_ && !process_launcher_thread_.get()); | |
| 856 created_process_launcher_thread_ = true; | |
| 857 | |
| 858 scoped_ptr<base::Thread> thread( | |
| 859 new content::BrowserProcessSubThread(BrowserThread::PROCESS_LAUNCHER)); | |
| 860 if (!thread->Start()) | |
| 861 return; | |
| 862 process_launcher_thread_.swap(thread); | |
| 863 } | |
| 864 | |
| 865 void BrowserProcessImpl::CreateCacheThread() { | |
| 866 DCHECK(!created_cache_thread_ && !cache_thread_.get()); | |
| 867 created_cache_thread_ = true; | |
| 868 | |
| 869 scoped_ptr<base::Thread> thread( | |
| 870 new content::DeprecatedBrowserThread(BrowserThread::CACHE)); | |
| 871 base::Thread::Options options; | |
| 872 options.message_loop_type = MessageLoop::TYPE_IO; | |
| 873 if (!thread->StartWithOptions(options)) | |
| 874 return; | |
| 875 cache_thread_.swap(thread); | |
| 876 } | 818 } |
| 877 | 819 |
| 878 void BrowserProcessImpl::CreateWatchdogThread() { | 820 void BrowserProcessImpl::CreateWatchdogThread() { |
| 879 DCHECK(!created_watchdog_thread_ && watchdog_thread_.get() == NULL); | 821 DCHECK(!created_watchdog_thread_ && watchdog_thread_.get() == NULL); |
| 880 created_watchdog_thread_ = true; | 822 created_watchdog_thread_ = true; |
| 881 | 823 |
| 882 scoped_ptr<WatchDogThread> thread(new WatchDogThread()); | 824 scoped_ptr<WatchDogThread> thread(new WatchDogThread()); |
| 883 if (!thread->Start()) | 825 if (!thread->Start()) |
| 884 return; | 826 return; |
| 885 watchdog_thread_.swap(thread); | 827 watchdog_thread_.swap(thread); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 913 // Initialize the notification for the default browser setting policy. | 855 // Initialize the notification for the default browser setting policy. |
| 914 local_state_->RegisterBooleanPref(prefs::kDefaultBrowserSettingEnabled, | 856 local_state_->RegisterBooleanPref(prefs::kDefaultBrowserSettingEnabled, |
| 915 false); | 857 false); |
| 916 if (local_state_->IsManagedPreference(prefs::kDefaultBrowserSettingEnabled)) | 858 if (local_state_->IsManagedPreference(prefs::kDefaultBrowserSettingEnabled)) |
| 917 ApplyDefaultBrowserPolicy(); | 859 ApplyDefaultBrowserPolicy(); |
| 918 pref_change_registrar_.Add(prefs::kDefaultBrowserSettingEnabled, this); | 860 pref_change_registrar_.Add(prefs::kDefaultBrowserSettingEnabled, this); |
| 919 | 861 |
| 920 // Initialize the preference for the plugin finder policy. | 862 // Initialize the preference for the plugin finder policy. |
| 921 // This preference is only needed on the IO thread so make it available there. | 863 // This preference is only needed on the IO thread so make it available there. |
| 922 local_state_->RegisterBooleanPref(prefs::kDisablePluginFinder, false); | 864 local_state_->RegisterBooleanPref(prefs::kDisablePluginFinder, false); |
| 923 plugin_finder_disabled_pref_.Init(prefs::kDisablePluginFinder, | 865 plugin_finder_disabled_pref_.reset(new BooleanPrefMember); |
| 866 plugin_finder_disabled_pref_->Init(prefs::kDisablePluginFinder, |
| 924 local_state_.get(), NULL); | 867 local_state_.get(), NULL); |
| 925 plugin_finder_disabled_pref_.MoveToThread(BrowserThread::IO); | 868 plugin_finder_disabled_pref_->MoveToThread(BrowserThread::IO); |
| 926 | 869 |
| 927 // Another policy that needs to be defined before the net subsystem is | 870 // Another policy that needs to be defined before the net subsystem is |
| 928 // initialized is MaxConnectionsPerProxy so we do it here. | 871 // initialized is MaxConnectionsPerProxy so we do it here. |
| 929 local_state_->RegisterIntegerPref(prefs::kMaxConnectionsPerProxy, | 872 local_state_->RegisterIntegerPref(prefs::kMaxConnectionsPerProxy, |
| 930 net::kDefaultMaxSocketsPerProxyServer); | 873 net::kDefaultMaxSocketsPerProxyServer); |
| 931 int max_per_proxy = local_state_->GetInteger(prefs::kMaxConnectionsPerProxy); | 874 int max_per_proxy = local_state_->GetInteger(prefs::kMaxConnectionsPerProxy); |
| 932 net::ClientSocketPoolManager::set_max_sockets_per_proxy_server( | 875 net::ClientSocketPoolManager::set_max_sockets_per_proxy_server( |
| 933 std::max(std::min(max_per_proxy, 99), | 876 std::max(std::min(max_per_proxy, 99), |
| 934 net::ClientSocketPoolManager::max_sockets_per_group())); | 877 net::ClientSocketPoolManager::max_sockets_per_group())); |
| 935 | 878 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 } | 1029 } |
| 1087 | 1030 |
| 1088 void BrowserProcessImpl::OnAutoupdateTimer() { | 1031 void BrowserProcessImpl::OnAutoupdateTimer() { |
| 1089 if (CanAutorestartForUpdate()) { | 1032 if (CanAutorestartForUpdate()) { |
| 1090 DLOG(WARNING) << "Detected update. Restarting browser."; | 1033 DLOG(WARNING) << "Detected update. Restarting browser."; |
| 1091 RestartBackgroundInstance(); | 1034 RestartBackgroundInstance(); |
| 1092 } | 1035 } |
| 1093 } | 1036 } |
| 1094 | 1037 |
| 1095 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 1038 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
| OLD | NEW |