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