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_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_child_process_host.h" | 71 #include "content/browser/browser_child_process_host.h" |
72 #include "content/browser/browser_process_sub_thread.h" | |
73 #include "content/browser/child_process_security_policy.h" | 72 #include "content/browser/child_process_security_policy.h" |
74 #include "content/browser/debugger/devtools_manager.h" | 73 #include "content/browser/debugger/devtools_manager.h" |
75 #include "content/browser/download/download_file_manager.h" | 74 #include "content/browser/download/download_file_manager.h" |
76 #include "content/browser/download/download_status_updater.h" | 75 #include "content/browser/download/download_status_updater.h" |
77 #include "content/browser/download/mhtml_generation_manager.h" | 76 #include "content/browser/download/mhtml_generation_manager.h" |
78 #include "content/browser/download/save_file_manager.h" | 77 #include "content/browser/download/save_file_manager.h" |
79 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 78 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
80 #include "content/browser/net/browser_online_state_observer.h" | 79 #include "content/browser/net/browser_online_state_observer.h" |
81 #include "content/browser/plugin_service.h" | 80 #include "content/browser/plugin_service.h" |
82 #include "content/browser/renderer_host/render_process_host.h" | 81 #include "content/browser/renderer_host/render_process_host.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 // Linux. We have a timeout here because we're unable to run the UI messageloop | 123 // Linux. We have a timeout here because we're unable to run the UI messageloop |
125 // and there's some deadlock risk. Our only option is to exit anyway. | 124 // and there's some deadlock risk. Our only option is to exit anyway. |
126 static const int kEndSessionTimeoutSeconds = 10; | 125 static const int kEndSessionTimeoutSeconds = 10; |
127 #endif | 126 #endif |
128 | 127 |
129 using content::BrowserThread; | 128 using content::BrowserThread; |
130 | 129 |
131 BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line) | 130 BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line) |
132 : created_resource_dispatcher_host_(false), | 131 : created_resource_dispatcher_host_(false), |
133 created_metrics_service_(false), | 132 created_metrics_service_(false), |
134 created_io_thread_(false), | |
135 created_file_thread_(false), | |
136 created_db_thread_(false), | |
137 created_process_launcher_thread_(false), | |
138 created_cache_thread_(false), | |
139 created_watchdog_thread_(false), | 133 created_watchdog_thread_(false), |
140 #if defined(OS_CHROMEOS) | |
141 created_web_socket_proxy_thread_(false), | |
142 #endif | |
143 created_profile_manager_(false), | 134 created_profile_manager_(false), |
144 created_local_state_(false), | 135 created_local_state_(false), |
145 created_icon_manager_(false), | 136 created_icon_manager_(false), |
146 created_devtools_manager_(false), | 137 created_devtools_manager_(false), |
147 created_sidebar_manager_(false), | 138 created_sidebar_manager_(false), |
148 created_browser_policy_connector_(false), | 139 created_browser_policy_connector_(false), |
149 created_notification_ui_manager_(false), | 140 created_notification_ui_manager_(false), |
150 created_safe_browsing_service_(false), | 141 created_safe_browsing_service_(false), |
151 module_ref_count_(0), | 142 module_ref_count_(0), |
152 did_start_(false), | 143 did_start_(false), |
(...skipping 13 matching lines...) Expand all Loading... | |
166 chrome::kExtensionScheme); | 157 chrome::kExtensionScheme); |
167 | 158 |
168 extension_event_router_forwarder_ = new ExtensionEventRouterForwarder; | 159 extension_event_router_forwarder_ = new ExtensionEventRouterForwarder; |
169 | 160 |
170 ExtensionTabIdMap::GetInstance()->Init(); | 161 ExtensionTabIdMap::GetInstance()->Init(); |
171 | 162 |
172 online_state_observer_.reset(new BrowserOnlineStateObserver); | 163 online_state_observer_.reset(new BrowserOnlineStateObserver); |
173 } | 164 } |
174 | 165 |
175 BrowserProcessImpl::~BrowserProcessImpl() { | 166 BrowserProcessImpl::~BrowserProcessImpl() { |
176 #if defined(OS_CHROMEOS) | 167 // See StartTearDown and PreStopThread functions below, this is where |
177 if (web_socket_proxy_thread_.get()) | 168 // most destruction happens so that it can be interleaved with threads |
178 chromeos::WebSocketProxyController::Shutdown(); | 169 // going away. |
179 web_socket_proxy_thread_.reset(); | |
180 #endif | |
181 | 170 |
171 // Wait for the pending print jobs to finish. | |
172 print_job_manager_->OnQuit(); | |
173 print_job_manager_.reset(); | |
174 | |
175 g_browser_process = NULL; | |
176 } | |
177 | |
178 void BrowserProcessImpl::StartTearDown() { | |
182 // Delete the AutomationProviderList before NotificationService, | 179 // Delete the AutomationProviderList before NotificationService, |
183 // since it may try to unregister notifications | 180 // since it may try to unregister notifications |
184 // Both NotificationService and AutomationProvider are singleton instances in | 181 // Both NotificationService and AutomationProvider are singleton instances in |
185 // the BrowserProcess. Since AutomationProvider may have some active | 182 // the BrowserProcess. Since AutomationProvider may have some active |
186 // notification observers, it is essential that it gets destroyed before the | 183 // notification observers, it is essential that it gets destroyed before the |
187 // NotificationService. NotificationService won't be destroyed until after | 184 // NotificationService. NotificationService won't be destroyed until after |
188 // this destructor is run. | 185 // this destructor is run. |
189 automation_provider_list_.reset(); | 186 automation_provider_list_.reset(); |
190 | 187 |
191 // We need to shutdown the SdchDictionaryFetcher as it regularly holds | 188 // We need to shutdown the SdchDictionaryFetcher as it regularly holds |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
245 browser_policy_connector_.reset(); | 242 browser_policy_connector_.reset(); |
246 | 243 |
247 // Destroying the GpuProcessHostUIShims on the UI thread posts a task to | 244 // Destroying the GpuProcessHostUIShims on the UI thread posts a task to |
248 // delete related objects on the GPU thread. This must be done before | 245 // delete related objects on the GPU thread. This must be done before |
249 // stopping the GPU thread. The GPU thread will close IPC channels to renderer | 246 // stopping the GPU thread. The GPU thread will close IPC channels to renderer |
250 // processes so this has to happen before stopping the IO thread. | 247 // processes so this has to happen before stopping the IO thread. |
251 GpuProcessHostUIShim::DestroyAll(); | 248 GpuProcessHostUIShim::DestroyAll(); |
252 | 249 |
253 // Stop the watchdog thread before stopping other threads. | 250 // Stop the watchdog thread before stopping other threads. |
254 watchdog_thread_.reset(); | 251 watchdog_thread_.reset(); |
252 } | |
255 | 253 |
256 // Need to stop io_thread_ before resource_dispatcher_host_, since | 254 void BrowserProcessImpl::PreStopThread(BrowserThread::ID thread_id) { |
robertshield
2011/11/14 04:15:55
What is the criteria for choosing to do some thing
| |
257 // io_thread_ may still deref ResourceDispatcherHost and handle resource | 255 switch (thread_id) { |
258 // request before going away. | 256 #if defined(OS_CHROMEOS) |
259 io_thread_.reset(); | 257 case BrowserThread::WEB_SOCKET_PROXY: |
258 chromeos::WebSocketProxyController::Shutdown(); | |
259 break; | |
260 #endif | |
261 case BrowserThread::FILE: | |
262 // Clean up state that lives on or uses the file_thread_ before | |
263 // it goes away. | |
264 if (resource_dispatcher_host_.get()) { | |
265 resource_dispatcher_host()->download_file_manager()->Shutdown(); | |
266 resource_dispatcher_host()->save_file_manager()->Shutdown(); | |
267 } | |
268 break; | |
269 case BrowserThread::WEBKIT: | |
270 // Need to destroy ResourceDispatcherHost before PluginService | |
271 // and SafeBrowsingService, since it caches a pointer to | |
272 // it. This also causes the webkit thread to terminate (which is | |
273 // still the responsibility of the embedder, not of the content | |
274 // framework). | |
275 resource_dispatcher_host_.reset(); | |
276 break; | |
277 default: | |
278 break; | |
279 } | |
280 } | |
260 | 281 |
261 // The IO thread was the only user of this thread. | 282 void BrowserProcessImpl::PostStopThread(BrowserThread::ID thread_id) { |
262 cache_thread_.reset(); | 283 switch (thread_id) { |
263 | 284 case BrowserThread::FILE: |
264 // Stop the process launcher thread after the IO thread, in case the IO thread | 285 // With the file_thread_ flushed, we can release any icon resources. |
265 // posted a task to terminate a process on the process launcher thread. | 286 icon_manager_.reset(); |
266 process_launcher_thread_.reset(); | 287 break; |
267 | 288 case BrowserThread::IO: |
268 // Clean up state that lives on the file_thread_ before it goes away. | 289 // Reset associated state right after actual thread is stopped, |
269 if (resource_dispatcher_host_.get()) { | 290 // as io_thread_.global_ cleanup happens in CleanUp on the IO |
270 resource_dispatcher_host()->download_file_manager()->Shutdown(); | 291 // thread, i.e. as the thread exits its message loop. |
271 resource_dispatcher_host()->save_file_manager()->Shutdown(); | 292 io_thread_.reset(); |
293 break; | |
294 default: | |
295 break; | |
272 } | 296 } |
273 | |
274 // Need to stop the file_thread_ here to force it to process messages in its | |
275 // message loop from the previous call to shutdown the DownloadFileManager, | |
276 // SaveFileManager and SessionService. | |
277 file_thread_.reset(); | |
278 | |
279 // With the file_thread_ flushed, we can release any icon resources. | |
280 icon_manager_.reset(); | |
281 | |
282 // Need to destroy ResourceDispatcherHost before PluginService and | |
283 // SafeBrowsingService, since it caches a pointer to it. This also | |
284 // causes the webkit thread to terminate. | |
285 resource_dispatcher_host_.reset(); | |
286 | |
287 // Wait for the pending print jobs to finish. | |
288 print_job_manager_->OnQuit(); | |
289 print_job_manager_.reset(); | |
290 | |
291 // Destroy TabCloseableStateWatcher before NotificationService since the | |
292 // former registers for notifications. | |
293 tab_closeable_state_watcher_.reset(); | |
294 | |
295 g_browser_process = NULL; | |
296 } | 297 } |
297 | 298 |
298 #if defined(OS_WIN) | 299 #if defined(OS_WIN) |
299 // Send a QuitTask to the given MessageLoop when the (file) thread has processed | 300 // Send a QuitTask to the given MessageLoop when the (file) thread has processed |
300 // our (other) recent requests (to save preferences). | 301 // our (other) recent requests (to save preferences). |
301 // Change the boolean so that the receiving thread will know that we did indeed | 302 // Change the boolean so that the receiving thread will know that we did indeed |
302 // send the QuitTask that terminated the message loop. | 303 // send the QuitTask that terminated the message loop. |
303 static void PostQuit(MessageLoop* message_loop) { | 304 static void PostQuit(MessageLoop* message_loop) { |
304 g_end_session_file_thread_has_completed = true; | 305 g_end_session_file_thread_has_completed = true; |
305 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask()); | 306 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask()); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
398 | 399 |
399 MetricsService* BrowserProcessImpl::metrics_service() { | 400 MetricsService* BrowserProcessImpl::metrics_service() { |
400 DCHECK(CalledOnValidThread()); | 401 DCHECK(CalledOnValidThread()); |
401 if (!created_metrics_service_) | 402 if (!created_metrics_service_) |
402 CreateMetricsService(); | 403 CreateMetricsService(); |
403 return metrics_service_.get(); | 404 return metrics_service_.get(); |
404 } | 405 } |
405 | 406 |
406 IOThread* BrowserProcessImpl::io_thread() { | 407 IOThread* BrowserProcessImpl::io_thread() { |
407 DCHECK(CalledOnValidThread()); | 408 DCHECK(CalledOnValidThread()); |
408 if (!created_io_thread_) | 409 DCHECK(io_thread_.get()); |
409 CreateIOThread(); | |
410 return io_thread_.get(); | 410 return io_thread_.get(); |
411 } | 411 } |
412 | 412 |
413 base::Thread* BrowserProcessImpl::file_thread() { | 413 base::Thread* BrowserProcessImpl::file_thread() { |
414 DCHECK(CalledOnValidThread()); | 414 DCHECK(CalledOnValidThread()); |
415 if (!created_file_thread_) | 415 return BrowserThread::UnsafeGetBrowserThread(BrowserThread::FILE); |
416 CreateFileThread(); | |
417 return file_thread_.get(); | |
418 } | 416 } |
419 | 417 |
420 base::Thread* BrowserProcessImpl::db_thread() { | 418 base::Thread* BrowserProcessImpl::db_thread() { |
421 DCHECK(CalledOnValidThread()); | 419 DCHECK(CalledOnValidThread()); |
422 if (!created_db_thread_) | 420 return BrowserThread::UnsafeGetBrowserThread(BrowserThread::DB); |
423 CreateDBThread(); | |
424 return db_thread_.get(); | |
425 } | 421 } |
426 | 422 |
427 base::Thread* BrowserProcessImpl::process_launcher_thread() { | 423 base::Thread* BrowserProcessImpl::process_launcher_thread() { |
428 DCHECK(CalledOnValidThread()); | 424 DCHECK(CalledOnValidThread()); |
429 if (!created_process_launcher_thread_) | 425 return BrowserThread::UnsafeGetBrowserThread(BrowserThread::PROCESS_LAUNCHER); |
430 CreateProcessLauncherThread(); | |
431 return process_launcher_thread_.get(); | |
432 } | 426 } |
433 | 427 |
434 base::Thread* BrowserProcessImpl::cache_thread() { | 428 base::Thread* BrowserProcessImpl::cache_thread() { |
435 DCHECK(CalledOnValidThread()); | 429 DCHECK(CalledOnValidThread()); |
436 if (!created_cache_thread_) | 430 return BrowserThread::UnsafeGetBrowserThread(BrowserThread::CACHE); |
437 CreateCacheThread(); | |
438 return cache_thread_.get(); | |
439 } | 431 } |
440 | 432 |
441 WatchDogThread* BrowserProcessImpl::watchdog_thread() { | 433 WatchDogThread* BrowserProcessImpl::watchdog_thread() { |
442 DCHECK(CalledOnValidThread()); | 434 DCHECK(CalledOnValidThread()); |
443 if (!created_watchdog_thread_) | 435 if (!created_watchdog_thread_) |
444 CreateWatchdogThread(); | 436 CreateWatchdogThread(); |
445 DCHECK(watchdog_thread_.get() != NULL); | 437 DCHECK(watchdog_thread_.get() != NULL); |
446 return watchdog_thread_.get(); | 438 return watchdog_thread_.get(); |
447 } | 439 } |
448 | 440 |
449 #if defined(OS_CHROMEOS) | 441 #if defined(OS_CHROMEOS) |
450 base::Thread* BrowserProcessImpl::web_socket_proxy_thread() { | 442 base::Thread* BrowserProcessImpl::web_socket_proxy_thread() { |
451 DCHECK(CalledOnValidThread()); | 443 DCHECK(CalledOnValidThread()); |
452 if (!created_web_socket_proxy_thread_) | 444 return BrowserThread::UnsafeGetBrowserThread(BrowserThread::WEB_SOCKET_PROXY); |
453 CreateWebSocketProxyThread(); | |
454 DCHECK(web_socket_proxy_thread_.get() != NULL); | |
455 return web_socket_proxy_thread_.get(); | |
456 } | 445 } |
457 #endif | 446 #endif |
458 | 447 |
459 ProfileManager* BrowserProcessImpl::profile_manager() { | 448 ProfileManager* BrowserProcessImpl::profile_manager() { |
460 DCHECK(CalledOnValidThread()); | 449 DCHECK(CalledOnValidThread()); |
461 if (!created_profile_manager_) | 450 if (!created_profile_manager_) |
462 CreateProfileManager(); | 451 CreateProfileManager(); |
463 return profile_manager_.get(); | 452 return profile_manager_.get(); |
464 } | 453 } |
465 | 454 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
656 | 645 |
657 safe_browsing::ClientSideDetectionService* | 646 safe_browsing::ClientSideDetectionService* |
658 BrowserProcessImpl::safe_browsing_detection_service() { | 647 BrowserProcessImpl::safe_browsing_detection_service() { |
659 DCHECK(CalledOnValidThread()); | 648 DCHECK(CalledOnValidThread()); |
660 if (safe_browsing_service()) | 649 if (safe_browsing_service()) |
661 return safe_browsing_service()->safe_browsing_detection_service(); | 650 return safe_browsing_service()->safe_browsing_detection_service(); |
662 return NULL; | 651 return NULL; |
663 } | 652 } |
664 | 653 |
665 bool BrowserProcessImpl::plugin_finder_disabled() const { | 654 bool BrowserProcessImpl::plugin_finder_disabled() const { |
666 return *plugin_finder_disabled_pref_; | 655 if (plugin_finder_disabled_pref_.get()) |
656 return plugin_finder_disabled_pref_->GetValue(); | |
657 else | |
658 return false; | |
667 } | 659 } |
668 | 660 |
669 void BrowserProcessImpl::Observe(int type, | 661 void BrowserProcessImpl::Observe(int type, |
670 const content::NotificationSource& source, | 662 const content::NotificationSource& source, |
671 const content::NotificationDetails& details) { | 663 const content::NotificationDetails& details) { |
672 if (type == chrome::NOTIFICATION_PREF_CHANGED) { | 664 if (type == chrome::NOTIFICATION_PREF_CHANGED) { |
673 std::string* pref = content::Details<std::string>(details).ptr(); | 665 std::string* pref = content::Details<std::string>(details).ptr(); |
674 if (*pref == prefs::kDefaultBrowserSettingEnabled) { | 666 if (*pref == prefs::kDefaultBrowserSettingEnabled) { |
675 ApplyDefaultBrowserPolicy(); | 667 ApplyDefaultBrowserPolicy(); |
676 } else if (*pref == prefs::kDisabledSchemes) { | 668 } else if (*pref == prefs::kDisabledSchemes) { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
771 ApplyAllowCrossOriginAuthPromptPolicy(); | 763 ApplyAllowCrossOriginAuthPromptPolicy(); |
772 } | 764 } |
773 | 765 |
774 void BrowserProcessImpl::CreateMetricsService() { | 766 void BrowserProcessImpl::CreateMetricsService() { |
775 DCHECK(!created_metrics_service_ && metrics_service_.get() == NULL); | 767 DCHECK(!created_metrics_service_ && metrics_service_.get() == NULL); |
776 created_metrics_service_ = true; | 768 created_metrics_service_ = true; |
777 | 769 |
778 metrics_service_.reset(new MetricsService); | 770 metrics_service_.reset(new MetricsService); |
779 } | 771 } |
780 | 772 |
781 void BrowserProcessImpl::CreateIOThread() { | 773 void BrowserProcessImpl::CreateIOThreadState() { |
782 DCHECK(!created_io_thread_ && io_thread_.get() == NULL); | 774 DCHECK(!io_thread_.get()); |
783 created_io_thread_ = true; | |
784 | 775 |
785 // Prior to starting the io thread, we create the plugin service as | 776 // Prior to starting the io thread, we create the plugin service as |
786 // it is predominantly used from the io thread, but must be created | 777 // it is predominantly used from the io thread, but must be created |
787 // on the main thread. The service ctor is inexpensive and does not | 778 // on the main thread. The service ctor is inexpensive and does not |
788 // invoke the io_thread() accessor. | 779 // invoke the io_thread() accessor. |
789 PluginService* plugin_service = PluginService::GetInstance(); | 780 PluginService* plugin_service = PluginService::GetInstance(); |
790 plugin_service->Init(); | 781 plugin_service->Init(); |
791 plugin_service->set_filter(ChromePluginServiceFilter::GetInstance()); | 782 plugin_service->set_filter(ChromePluginServiceFilter::GetInstance()); |
792 plugin_service->StartWatchingPlugins(); | 783 plugin_service->StartWatchingPlugins(); |
793 | 784 |
794 // Register the internal Flash if available. | 785 // Register the internal Flash if available. |
795 FilePath path; | 786 FilePath path; |
796 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 787 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
797 switches::kDisableInternalFlash) && | 788 switches::kDisableInternalFlash) && |
798 PathService::Get(chrome::FILE_FLASH_PLUGIN, &path)) { | 789 PathService::Get(chrome::FILE_FLASH_PLUGIN, &path)) { |
799 plugin_service->AddExtraPluginPath(path); | 790 plugin_service->AddExtraPluginPath(path); |
800 } | 791 } |
801 | 792 |
802 #if defined(OS_POSIX) | 793 #if defined(OS_POSIX) |
803 // Also find plugins in a user-specific plugins dir, | 794 // Also find plugins in a user-specific plugins dir, |
804 // e.g. ~/.config/chromium/Plugins. | 795 // e.g. ~/.config/chromium/Plugins. |
805 FilePath user_data_dir; | 796 FilePath user_data_dir; |
806 if (PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { | 797 if (PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { |
807 plugin_service->AddExtraPluginPath(user_data_dir.Append("Plugins")); | 798 plugin_service->AddExtraPluginPath(user_data_dir.Append("Plugins")); |
808 } | 799 } |
809 #endif | 800 #endif |
810 | 801 |
811 scoped_ptr<IOThread> thread(new IOThread( | 802 scoped_ptr<IOThread> thread(new IOThread( |
812 local_state(), net_log_.get(), extension_event_router_forwarder_.get())); | 803 local_state(), net_log_.get(), extension_event_router_forwarder_.get())); |
813 base::Thread::Options options; | |
814 options.message_loop_type = MessageLoop::TYPE_IO; | |
815 if (!thread->StartWithOptions(options)) | |
816 return; | |
817 io_thread_.swap(thread); | 804 io_thread_.swap(thread); |
818 } | 805 } |
819 | 806 |
820 void BrowserProcessImpl::CreateFileThread() { | |
821 DCHECK(!created_file_thread_ && file_thread_.get() == NULL); | |
822 created_file_thread_ = true; | |
823 | |
824 scoped_ptr<base::Thread> thread( | |
825 new content::BrowserProcessSubThread(BrowserThread::FILE)); | |
826 base::Thread::Options options; | |
827 #if defined(OS_WIN) | |
828 // On Windows, the FILE thread needs to be have a UI message loop which pumps | |
829 // messages in such a way that Google Update can communicate back to us. | |
830 options.message_loop_type = MessageLoop::TYPE_UI; | |
831 #else | |
832 options.message_loop_type = MessageLoop::TYPE_IO; | |
833 #endif | |
834 if (!thread->StartWithOptions(options)) | |
835 return; | |
836 file_thread_.swap(thread); | |
837 } | |
838 | |
839 #if defined(OS_CHROMEOS) | |
840 void BrowserProcessImpl::CreateWebSocketProxyThread() { | |
841 DCHECK(!created_web_socket_proxy_thread_); | |
842 DCHECK(web_socket_proxy_thread_.get() == NULL); | |
843 created_web_socket_proxy_thread_ = true; | |
844 | |
845 scoped_ptr<base::Thread> thread( | |
846 new content::BrowserProcessSubThread(BrowserThread::WEB_SOCKET_PROXY)); | |
847 base::Thread::Options options; | |
848 options.message_loop_type = MessageLoop::TYPE_IO; | |
849 if (!thread->StartWithOptions(options)) | |
850 return; | |
851 web_socket_proxy_thread_.swap(thread); | |
852 } | |
853 #endif | |
854 | |
855 void BrowserProcessImpl::CreateDBThread() { | |
856 DCHECK(!created_db_thread_ && db_thread_.get() == NULL); | |
857 created_db_thread_ = true; | |
858 | |
859 scoped_ptr<base::Thread> thread( | |
860 new content::BrowserProcessSubThread(BrowserThread::DB)); | |
861 if (!thread->Start()) | |
862 return; | |
863 db_thread_.swap(thread); | |
864 } | |
865 | |
866 void BrowserProcessImpl::CreateProcessLauncherThread() { | |
867 DCHECK(!created_process_launcher_thread_ && !process_launcher_thread_.get()); | |
868 created_process_launcher_thread_ = true; | |
869 | |
870 scoped_ptr<base::Thread> thread( | |
871 new content::BrowserProcessSubThread(BrowserThread::PROCESS_LAUNCHER)); | |
872 if (!thread->Start()) | |
873 return; | |
874 process_launcher_thread_.swap(thread); | |
875 } | |
876 | |
877 void BrowserProcessImpl::CreateCacheThread() { | |
878 DCHECK(!created_cache_thread_ && !cache_thread_.get()); | |
879 created_cache_thread_ = true; | |
880 | |
881 scoped_ptr<base::Thread> thread( | |
882 new content::DeprecatedBrowserThread(BrowserThread::CACHE)); | |
883 base::Thread::Options options; | |
884 options.message_loop_type = MessageLoop::TYPE_IO; | |
885 if (!thread->StartWithOptions(options)) | |
886 return; | |
887 cache_thread_.swap(thread); | |
888 } | |
889 | |
890 void BrowserProcessImpl::CreateWatchdogThread() { | 807 void BrowserProcessImpl::CreateWatchdogThread() { |
891 DCHECK(!created_watchdog_thread_ && watchdog_thread_.get() == NULL); | 808 DCHECK(!created_watchdog_thread_ && watchdog_thread_.get() == NULL); |
892 created_watchdog_thread_ = true; | 809 created_watchdog_thread_ = true; |
893 | 810 |
894 scoped_ptr<WatchDogThread> thread(new WatchDogThread()); | 811 scoped_ptr<WatchDogThread> thread(new WatchDogThread()); |
895 if (!thread->Start()) | 812 if (!thread->Start()) |
896 return; | 813 return; |
897 watchdog_thread_.swap(thread); | 814 watchdog_thread_.swap(thread); |
898 } | 815 } |
899 | 816 |
(...skipping 25 matching lines...) Expand all Loading... | |
925 // Initialize the notification for the default browser setting policy. | 842 // Initialize the notification for the default browser setting policy. |
926 local_state_->RegisterBooleanPref(prefs::kDefaultBrowserSettingEnabled, | 843 local_state_->RegisterBooleanPref(prefs::kDefaultBrowserSettingEnabled, |
927 false); | 844 false); |
928 if (local_state_->IsManagedPreference(prefs::kDefaultBrowserSettingEnabled)) | 845 if (local_state_->IsManagedPreference(prefs::kDefaultBrowserSettingEnabled)) |
929 ApplyDefaultBrowserPolicy(); | 846 ApplyDefaultBrowserPolicy(); |
930 pref_change_registrar_.Add(prefs::kDefaultBrowserSettingEnabled, this); | 847 pref_change_registrar_.Add(prefs::kDefaultBrowserSettingEnabled, this); |
931 | 848 |
932 // Initialize the preference for the plugin finder policy. | 849 // Initialize the preference for the plugin finder policy. |
933 // This preference is only needed on the IO thread so make it available there. | 850 // This preference is only needed on the IO thread so make it available there. |
934 local_state_->RegisterBooleanPref(prefs::kDisablePluginFinder, false); | 851 local_state_->RegisterBooleanPref(prefs::kDisablePluginFinder, false); |
935 plugin_finder_disabled_pref_.Init(prefs::kDisablePluginFinder, | 852 plugin_finder_disabled_pref_.reset(new BooleanPrefMember); |
853 plugin_finder_disabled_pref_->Init(prefs::kDisablePluginFinder, | |
936 local_state_.get(), NULL); | 854 local_state_.get(), NULL); |
937 plugin_finder_disabled_pref_.MoveToThread(BrowserThread::IO); | 855 plugin_finder_disabled_pref_->MoveToThread(BrowserThread::IO); |
938 | 856 |
939 // Initialize the disk cache location policy. This policy is not hot update- | 857 // Initialize the disk cache location policy. This policy is not hot update- |
940 // able so we need to have it when initializing the profiles. | 858 // able so we need to have it when initializing the profiles. |
941 local_state_->RegisterFilePathPref(prefs::kDiskCacheDir, FilePath()); | 859 local_state_->RegisterFilePathPref(prefs::kDiskCacheDir, FilePath()); |
942 | 860 |
943 // Another policy that needs to be defined before the net subsystem is | 861 // Another policy that needs to be defined before the net subsystem is |
944 // initialized is MaxConnectionsPerProxy so we do it here. | 862 // initialized is MaxConnectionsPerProxy so we do it here. |
945 local_state_->RegisterIntegerPref(prefs::kMaxConnectionsPerProxy, | 863 local_state_->RegisterIntegerPref(prefs::kMaxConnectionsPerProxy, |
946 net::kDefaultMaxSocketsPerProxyServer); | 864 net::kDefaultMaxSocketsPerProxyServer); |
947 int max_per_proxy = local_state_->GetInteger(prefs::kMaxConnectionsPerProxy); | 865 int max_per_proxy = local_state_->GetInteger(prefs::kMaxConnectionsPerProxy); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1150 } | 1068 } |
1151 | 1069 |
1152 void BrowserProcessImpl::OnAutoupdateTimer() { | 1070 void BrowserProcessImpl::OnAutoupdateTimer() { |
1153 if (CanAutorestartForUpdate()) { | 1071 if (CanAutorestartForUpdate()) { |
1154 DLOG(WARNING) << "Detected update. Restarting browser."; | 1072 DLOG(WARNING) << "Detected update. Restarting browser."; |
1155 RestartBackgroundInstance(); | 1073 RestartBackgroundInstance(); |
1156 } | 1074 } |
1157 } | 1075 } |
1158 | 1076 |
1159 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 1077 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
OLD | NEW |