Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: chrome/browser/browser_process_impl.cc

Issue 8477004: Have content/ create and destroy its own threads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Introduce and use BrowserThreadDelegate, BMP::Pre/PostStartThread, to make this a safe refactoring. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
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
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::PreStartThread(BrowserThread::ID thread_id) {
250 // io_thread_ may still deref ResourceDispatcherHost and handle resource 249 switch (thread_id) {
251 // request before going away. 250 case BrowserThread::IO:
252 io_thread_.reset(); 251 CreateIOThreadState();
252 break;
253 253
254 // The IO thread was the only user of this thread. 254 default:
255 cache_thread_.reset(); 255 break;
256 }
257 }
256 258
257 // Stop the process launcher thread after the IO thread, in case the IO thread 259 void BrowserProcessImpl::PostStartThread(BrowserThread::ID thread_id) {
258 // posted a task to terminate a process on the process launcher thread. 260 }
259 process_launcher_thread_.reset();
260 261
261 // Clean up state that lives on the file_thread_ before it goes away. 262 void BrowserProcessImpl::PreStopThread(BrowserThread::ID thread_id) {
262 if (resource_dispatcher_host_.get()) { 263 switch (thread_id) {
263 resource_dispatcher_host()->download_file_manager()->Shutdown(); 264 #if defined(OS_CHROMEOS)
264 resource_dispatcher_host()->save_file_manager()->Shutdown(); 265 case BrowserThread::WEB_SOCKET_PROXY:
266 chromeos::WebSocketProxyController::Shutdown();
267 break;
268 #endif
269 case BrowserThread::FILE:
270 // Clean up state that lives on or uses the file_thread_ before
271 // it goes away.
272 if (resource_dispatcher_host_.get()) {
273 resource_dispatcher_host()->download_file_manager()->Shutdown();
274 resource_dispatcher_host()->save_file_manager()->Shutdown();
275 }
276 break;
277 case BrowserThread::WEBKIT:
278 // Need to destroy ResourceDispatcherHost before PluginService
279 // and SafeBrowsingService, since it caches a pointer to
280 // it. This also causes the webkit thread to terminate (which is
281 // still the responsibility of the embedder, not of the content
282 // framework).
283 resource_dispatcher_host_.reset();
284 break;
285 default:
286 break;
265 } 287 }
288 }
266 289
267 // Need to stop the file_thread_ here to force it to process messages in its 290 void BrowserProcessImpl::PostStopThread(BrowserThread::ID thread_id) {
268 // message loop from the previous call to shutdown the DownloadFileManager, 291 switch (thread_id) {
269 // SaveFileManager and SessionService. 292 case BrowserThread::FILE:
270 file_thread_.reset(); 293 // With the file_thread_ flushed, we can release any icon resources.
271 294 icon_manager_.reset();
272 // With the file_thread_ flushed, we can release any icon resources. 295 break;
273 icon_manager_.reset(); 296 case BrowserThread::IO:
274 297 // Reset associated state right after actual thread is stopped,
275 // Need to destroy ResourceDispatcherHost before PluginService and 298 // as io_thread_.global_ cleanup happens in CleanUp on the IO
276 // SafeBrowsingService, since it caches a pointer to it. This also 299 // thread, i.e. as the thread exits its message loop.
277 // causes the webkit thread to terminate. 300 io_thread_.reset();
278 resource_dispatcher_host_.reset(); 301 break;
279 302 default:
280 // Wait for the pending print jobs to finish. 303 break;
281 print_job_manager_->OnQuit(); 304 }
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 } 305 }
290 306
291 #if defined(OS_WIN) 307 #if defined(OS_WIN)
292 // Send a QuitTask to the given MessageLoop when the (file) thread has processed 308 // Send a QuitTask to the given MessageLoop when the (file) thread has processed
293 // our (other) recent requests (to save preferences). 309 // our (other) recent requests (to save preferences).
294 // Change the boolean so that the receiving thread will know that we did indeed 310 // Change the boolean so that the receiving thread will know that we did indeed
295 // send the QuitTask that terminated the message loop. 311 // send the QuitTask that terminated the message loop.
296 static void PostQuit(MessageLoop* message_loop) { 312 static void PostQuit(MessageLoop* message_loop) {
297 g_end_session_file_thread_has_completed = true; 313 g_end_session_file_thread_has_completed = true;
298 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 314 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask());
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 408
393 MetricsService* BrowserProcessImpl::metrics_service() { 409 MetricsService* BrowserProcessImpl::metrics_service() {
394 DCHECK(CalledOnValidThread()); 410 DCHECK(CalledOnValidThread());
395 if (!created_metrics_service_) 411 if (!created_metrics_service_)
396 CreateMetricsService(); 412 CreateMetricsService();
397 return metrics_service_.get(); 413 return metrics_service_.get();
398 } 414 }
399 415
400 IOThread* BrowserProcessImpl::io_thread() { 416 IOThread* BrowserProcessImpl::io_thread() {
401 DCHECK(CalledOnValidThread()); 417 DCHECK(CalledOnValidThread());
402 if (!created_io_thread_) 418 DCHECK(io_thread_.get());
403 CreateIOThread();
404 return io_thread_.get(); 419 return io_thread_.get();
405 } 420 }
406 421
407 base::Thread* BrowserProcessImpl::file_thread() { 422 base::Thread* BrowserProcessImpl::file_thread() {
408 DCHECK(CalledOnValidThread()); 423 DCHECK(CalledOnValidThread());
409 if (!created_file_thread_) 424 return BrowserThread::UnsafeGetBrowserThread(BrowserThread::FILE);
410 CreateFileThread();
411 return file_thread_.get();
412 } 425 }
413 426
414 base::Thread* BrowserProcessImpl::db_thread() { 427 base::Thread* BrowserProcessImpl::db_thread() {
415 DCHECK(CalledOnValidThread()); 428 DCHECK(CalledOnValidThread());
416 if (!created_db_thread_) 429 return BrowserThread::UnsafeGetBrowserThread(BrowserThread::DB);
417 CreateDBThread();
418 return db_thread_.get();
419 } 430 }
420 431
421 base::Thread* BrowserProcessImpl::process_launcher_thread() { 432 base::Thread* BrowserProcessImpl::process_launcher_thread() {
422 DCHECK(CalledOnValidThread()); 433 DCHECK(CalledOnValidThread());
423 if (!created_process_launcher_thread_) 434 return BrowserThread::UnsafeGetBrowserThread(BrowserThread::PROCESS_LAUNCHER);
424 CreateProcessLauncherThread();
425 return process_launcher_thread_.get();
426 } 435 }
427 436
428 base::Thread* BrowserProcessImpl::cache_thread() { 437 base::Thread* BrowserProcessImpl::cache_thread() {
429 DCHECK(CalledOnValidThread()); 438 DCHECK(CalledOnValidThread());
430 if (!created_cache_thread_) 439 return BrowserThread::UnsafeGetBrowserThread(BrowserThread::CACHE);
431 CreateCacheThread();
432 return cache_thread_.get();
433 } 440 }
434 441
435 WatchDogThread* BrowserProcessImpl::watchdog_thread() { 442 WatchDogThread* BrowserProcessImpl::watchdog_thread() {
436 DCHECK(CalledOnValidThread()); 443 DCHECK(CalledOnValidThread());
437 if (!created_watchdog_thread_) 444 if (!created_watchdog_thread_)
438 CreateWatchdogThread(); 445 CreateWatchdogThread();
439 DCHECK(watchdog_thread_.get() != NULL); 446 DCHECK(watchdog_thread_.get() != NULL);
440 return watchdog_thread_.get(); 447 return watchdog_thread_.get();
441 } 448 }
442 449
443 #if defined(OS_CHROMEOS) 450 #if defined(OS_CHROMEOS)
444 base::Thread* BrowserProcessImpl::web_socket_proxy_thread() { 451 base::Thread* BrowserProcessImpl::web_socket_proxy_thread() {
445 DCHECK(CalledOnValidThread()); 452 DCHECK(CalledOnValidThread());
446 if (!created_web_socket_proxy_thread_) 453 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 } 454 }
451 #endif 455 #endif
452 456
453 ProfileManager* BrowserProcessImpl::profile_manager() { 457 ProfileManager* BrowserProcessImpl::profile_manager() {
454 DCHECK(CalledOnValidThread()); 458 DCHECK(CalledOnValidThread());
455 if (!created_profile_manager_) 459 if (!created_profile_manager_)
456 CreateProfileManager(); 460 CreateProfileManager();
457 return profile_manager_.get(); 461 return profile_manager_.get();
458 } 462 }
459 463
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 648
645 safe_browsing::ClientSideDetectionService* 649 safe_browsing::ClientSideDetectionService*
646 BrowserProcessImpl::safe_browsing_detection_service() { 650 BrowserProcessImpl::safe_browsing_detection_service() {
647 DCHECK(CalledOnValidThread()); 651 DCHECK(CalledOnValidThread());
648 if (safe_browsing_service()) 652 if (safe_browsing_service())
649 return safe_browsing_service()->safe_browsing_detection_service(); 653 return safe_browsing_service()->safe_browsing_detection_service();
650 return NULL; 654 return NULL;
651 } 655 }
652 656
653 bool BrowserProcessImpl::plugin_finder_disabled() const { 657 bool BrowserProcessImpl::plugin_finder_disabled() const {
654 return *plugin_finder_disabled_pref_; 658 if (plugin_finder_disabled_pref_.get())
659 return plugin_finder_disabled_pref_->GetValue();
660 else
661 return false;
655 } 662 }
656 663
657 void BrowserProcessImpl::Observe(int type, 664 void BrowserProcessImpl::Observe(int type,
658 const content::NotificationSource& source, 665 const content::NotificationSource& source,
659 const content::NotificationDetails& details) { 666 const content::NotificationDetails& details) {
660 if (type == chrome::NOTIFICATION_PREF_CHANGED) { 667 if (type == chrome::NOTIFICATION_PREF_CHANGED) {
661 std::string* pref = content::Details<std::string>(details).ptr(); 668 std::string* pref = content::Details<std::string>(details).ptr();
662 if (*pref == prefs::kDefaultBrowserSettingEnabled) { 669 if (*pref == prefs::kDefaultBrowserSettingEnabled) {
663 ApplyDefaultBrowserPolicy(); 670 ApplyDefaultBrowserPolicy();
664 } else if (*pref == prefs::kDisabledSchemes) { 671 } else if (*pref == prefs::kDisabledSchemes) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 ApplyAllowCrossOriginAuthPromptPolicy(); 766 ApplyAllowCrossOriginAuthPromptPolicy();
760 } 767 }
761 768
762 void BrowserProcessImpl::CreateMetricsService() { 769 void BrowserProcessImpl::CreateMetricsService() {
763 DCHECK(!created_metrics_service_ && metrics_service_.get() == NULL); 770 DCHECK(!created_metrics_service_ && metrics_service_.get() == NULL);
764 created_metrics_service_ = true; 771 created_metrics_service_ = true;
765 772
766 metrics_service_.reset(new MetricsService); 773 metrics_service_.reset(new MetricsService);
767 } 774 }
768 775
769 void BrowserProcessImpl::CreateIOThread() { 776 void BrowserProcessImpl::CreateIOThreadState() {
770 DCHECK(!created_io_thread_ && io_thread_.get() == NULL); 777 // Prior to any processing happening on the io thread, we create the
771 created_io_thread_ = true; 778 // plugin service as it is predominantly used from the io thread,
772 779 // but must be created on the main thread. The service ctor is
773 // Prior to starting the io thread, we create the plugin service as 780 // inexpensive and does not invoke the io_thread() accessor.
774 // it is predominantly used from the io thread, but must be created
775 // on the main thread. The service ctor is inexpensive and does not
776 // invoke the io_thread() accessor.
777 PluginService* plugin_service = PluginService::GetInstance(); 781 PluginService* plugin_service = PluginService::GetInstance();
778 plugin_service->Init(); 782 plugin_service->Init();
779 plugin_service->set_filter(ChromePluginServiceFilter::GetInstance()); 783 plugin_service->set_filter(ChromePluginServiceFilter::GetInstance());
780 plugin_service->StartWatchingPlugins(); 784 plugin_service->StartWatchingPlugins();
781 785
782 // Register the internal Flash if available. 786 // Register the internal Flash if available.
783 FilePath path; 787 FilePath path;
784 if (!CommandLine::ForCurrentProcess()->HasSwitch( 788 if (!CommandLine::ForCurrentProcess()->HasSwitch(
785 switches::kDisableInternalFlash) && 789 switches::kDisableInternalFlash) &&
786 PathService::Get(chrome::FILE_FLASH_PLUGIN, &path)) { 790 PathService::Get(chrome::FILE_FLASH_PLUGIN, &path)) {
787 plugin_service->AddExtraPluginPath(path); 791 plugin_service->AddExtraPluginPath(path);
788 } 792 }
789 793
790 #if defined(OS_POSIX) 794 #if defined(OS_POSIX)
791 // Also find plugins in a user-specific plugins dir, 795 // Also find plugins in a user-specific plugins dir,
792 // e.g. ~/.config/chromium/Plugins. 796 // e.g. ~/.config/chromium/Plugins.
793 FilePath user_data_dir; 797 FilePath user_data_dir;
794 if (PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { 798 if (PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) {
795 plugin_service->AddExtraPluginPath(user_data_dir.Append("Plugins")); 799 plugin_service->AddExtraPluginPath(user_data_dir.Append("Plugins"));
796 } 800 }
797 #endif 801 #endif
798 802
799 scoped_ptr<IOThread> thread(new IOThread( 803 scoped_ptr<IOThread> thread(new IOThread(
800 local_state(), net_log_.get(), extension_event_router_forwarder_.get())); 804 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); 805 io_thread_.swap(thread);
806 } 806 }
807 807
808 void BrowserProcessImpl::CreateFileThread() {
809 DCHECK(!created_file_thread_ && file_thread_.get() == NULL);
810 created_file_thread_ = true;
811
812 scoped_ptr<base::Thread> thread(
813 new content::BrowserProcessSubThread(BrowserThread::FILE));
814 base::Thread::Options options;
815 #if defined(OS_WIN)
816 // On Windows, the FILE thread needs to be have a UI message loop which pumps
817 // messages in such a way that Google Update can communicate back to us.
818 options.message_loop_type = MessageLoop::TYPE_UI;
819 #else
820 options.message_loop_type = MessageLoop::TYPE_IO;
821 #endif
822 if (!thread->StartWithOptions(options))
823 return;
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 }
877
878 void BrowserProcessImpl::CreateWatchdogThread() { 808 void BrowserProcessImpl::CreateWatchdogThread() {
879 DCHECK(!created_watchdog_thread_ && watchdog_thread_.get() == NULL); 809 DCHECK(!created_watchdog_thread_ && watchdog_thread_.get() == NULL);
880 created_watchdog_thread_ = true; 810 created_watchdog_thread_ = true;
881 811
882 scoped_ptr<WatchDogThread> thread(new WatchDogThread()); 812 scoped_ptr<WatchDogThread> thread(new WatchDogThread());
883 if (!thread->Start()) 813 if (!thread->Start())
884 return; 814 return;
885 watchdog_thread_.swap(thread); 815 watchdog_thread_.swap(thread);
886 } 816 }
887 817
(...skipping 25 matching lines...) Expand all
913 // Initialize the notification for the default browser setting policy. 843 // Initialize the notification for the default browser setting policy.
914 local_state_->RegisterBooleanPref(prefs::kDefaultBrowserSettingEnabled, 844 local_state_->RegisterBooleanPref(prefs::kDefaultBrowserSettingEnabled,
915 false); 845 false);
916 if (local_state_->IsManagedPreference(prefs::kDefaultBrowserSettingEnabled)) 846 if (local_state_->IsManagedPreference(prefs::kDefaultBrowserSettingEnabled))
917 ApplyDefaultBrowserPolicy(); 847 ApplyDefaultBrowserPolicy();
918 pref_change_registrar_.Add(prefs::kDefaultBrowserSettingEnabled, this); 848 pref_change_registrar_.Add(prefs::kDefaultBrowserSettingEnabled, this);
919 849
920 // Initialize the preference for the plugin finder policy. 850 // Initialize the preference for the plugin finder policy.
921 // This preference is only needed on the IO thread so make it available there. 851 // This preference is only needed on the IO thread so make it available there.
922 local_state_->RegisterBooleanPref(prefs::kDisablePluginFinder, false); 852 local_state_->RegisterBooleanPref(prefs::kDisablePluginFinder, false);
923 plugin_finder_disabled_pref_.Init(prefs::kDisablePluginFinder, 853 plugin_finder_disabled_pref_.reset(new BooleanPrefMember);
854 plugin_finder_disabled_pref_->Init(prefs::kDisablePluginFinder,
924 local_state_.get(), NULL); 855 local_state_.get(), NULL);
925 plugin_finder_disabled_pref_.MoveToThread(BrowserThread::IO); 856 plugin_finder_disabled_pref_->MoveToThread(BrowserThread::IO);
926 857
927 // Another policy that needs to be defined before the net subsystem is 858 // Another policy that needs to be defined before the net subsystem is
928 // initialized is MaxConnectionsPerProxy so we do it here. 859 // initialized is MaxConnectionsPerProxy so we do it here.
929 local_state_->RegisterIntegerPref(prefs::kMaxConnectionsPerProxy, 860 local_state_->RegisterIntegerPref(prefs::kMaxConnectionsPerProxy,
930 net::kDefaultMaxSocketsPerProxyServer); 861 net::kDefaultMaxSocketsPerProxyServer);
931 int max_per_proxy = local_state_->GetInteger(prefs::kMaxConnectionsPerProxy); 862 int max_per_proxy = local_state_->GetInteger(prefs::kMaxConnectionsPerProxy);
932 net::ClientSocketPoolManager::set_max_sockets_per_proxy_server( 863 net::ClientSocketPoolManager::set_max_sockets_per_proxy_server(
933 std::max(std::min(max_per_proxy, 99), 864 std::max(std::min(max_per_proxy, 99),
934 net::ClientSocketPoolManager::max_sockets_per_group())); 865 net::ClientSocketPoolManager::max_sockets_per_group()));
935 866
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 } 1017 }
1087 1018
1088 void BrowserProcessImpl::OnAutoupdateTimer() { 1019 void BrowserProcessImpl::OnAutoupdateTimer() {
1089 if (CanAutorestartForUpdate()) { 1020 if (CanAutorestartForUpdate()) {
1090 DLOG(WARNING) << "Detected update. Restarting browser."; 1021 DLOG(WARNING) << "Detected update. Restarting browser.";
1091 RestartBackgroundInstance(); 1022 RestartBackgroundInstance();
1092 } 1023 }
1093 } 1024 }
1094 1025
1095 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) 1026 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698