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

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

Issue 8718012: Revert 111695 - Have content/ create and destroy its own threads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years 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
« no previous file with comments | « chrome/browser/browser_process_impl.h ('k') | chrome/browser/browser_shutdown.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_child_process_host.h" 71 #include "content/browser/browser_process_sub_thread.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
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),
127 created_watchdog_thread_(false), 132 created_watchdog_thread_(false),
133 #if defined(OS_CHROMEOS)
134 created_web_socket_proxy_thread_(false),
135 #endif
128 created_profile_manager_(false), 136 created_profile_manager_(false),
129 created_local_state_(false), 137 created_local_state_(false),
130 created_icon_manager_(false), 138 created_icon_manager_(false),
131 created_sidebar_manager_(false), 139 created_sidebar_manager_(false),
132 created_browser_policy_connector_(false), 140 created_browser_policy_connector_(false),
133 created_notification_ui_manager_(false), 141 created_notification_ui_manager_(false),
134 created_safe_browsing_service_(false), 142 created_safe_browsing_service_(false),
135 module_ref_count_(0), 143 module_ref_count_(0),
136 did_start_(false), 144 did_start_(false),
137 checked_for_new_frames_(false), 145 checked_for_new_frames_(false),
(...skipping 12 matching lines...) Expand all
150 chrome::kExtensionScheme); 158 chrome::kExtensionScheme);
151 159
152 extension_event_router_forwarder_ = new ExtensionEventRouterForwarder; 160 extension_event_router_forwarder_ = new ExtensionEventRouterForwarder;
153 161
154 ExtensionTabIdMap::GetInstance()->Init(); 162 ExtensionTabIdMap::GetInstance()->Init();
155 163
156 online_state_observer_.reset(new BrowserOnlineStateObserver); 164 online_state_observer_.reset(new BrowserOnlineStateObserver);
157 } 165 }
158 166
159 BrowserProcessImpl::~BrowserProcessImpl() { 167 BrowserProcessImpl::~BrowserProcessImpl() {
160 // See StartTearDown and PreStopThread functions below, this is where 168 #if defined(OS_CHROMEOS)
161 // most destruction happens so that it can be interleaved with threads 169 if (web_socket_proxy_thread_.get())
162 // going away. 170 chromeos::WebSocketProxyController::Shutdown();
171 web_socket_proxy_thread_.reset();
172 #endif
163 173
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
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 }
243 242
244 void BrowserProcessImpl::PreStartThread(BrowserThread::ID thread_id) { 243 // Need to stop io_thread_ before resource_dispatcher_host_, since
245 switch (thread_id) { 244 // io_thread_ may still deref ResourceDispatcherHost and handle resource
246 case BrowserThread::IO: 245 // request before going away.
247 CreateIOThreadState(); 246 io_thread_.reset();
248 break;
249 247
250 default: 248 // The IO thread was the only user of this thread.
251 break; 249 cache_thread_.reset();
250
251 // Stop the process launcher thread after the IO thread, in case the IO thread
252 // posted a task to terminate a process on the process launcher thread.
253 process_launcher_thread_.reset();
254
255 // Clean up state that lives on the file_thread_ before it goes away.
256 if (resource_dispatcher_host_.get()) {
257 resource_dispatcher_host()->download_file_manager()->Shutdown();
258 resource_dispatcher_host()->save_file_manager()->Shutdown();
252 } 259 }
253 }
254 260
255 void BrowserProcessImpl::PostStartThread(BrowserThread::ID thread_id) { 261 // Need to stop the file_thread_ here to force it to process messages in its
256 } 262 // message loop from the previous call to shutdown the DownloadFileManager,
263 // SaveFileManager and SessionService.
264 file_thread_.reset();
257 265
258 void BrowserProcessImpl::PreStopThread(BrowserThread::ID thread_id) { 266 // With the file_thread_ flushed, we can release any icon resources.
259 switch (thread_id) { 267 icon_manager_.reset();
260 #if defined(OS_CHROMEOS)
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;
283 }
284 }
285 268
286 void BrowserProcessImpl::PostStopThread(BrowserThread::ID thread_id) { 269 // Need to destroy ResourceDispatcherHost before PluginService and
287 switch (thread_id) { 270 // SafeBrowsingService, since it caches a pointer to it. This also
288 case BrowserThread::FILE: 271 // causes the webkit thread to terminate.
289 // With the file_thread_ flushed, we can release any icon resources. 272 resource_dispatcher_host_.reset();
290 icon_manager_.reset(); 273
291 break; 274 // Wait for the pending print jobs to finish.
292 case BrowserThread::IO: 275 print_job_manager_->OnQuit();
293 // Reset associated state right after actual thread is stopped, 276 print_job_manager_.reset();
294 // as io_thread_.global_ cleanup happens in CleanUp on the IO 277
295 // thread, i.e. as the thread exits its message loop. 278 // Destroy TabCloseableStateWatcher before NotificationService since the
296 io_thread_.reset(); 279 // former registers for notifications.
297 break; 280 tab_closeable_state_watcher_.reset();
298 default: 281
299 break; 282 tracked_objects::ThreadData::EnsureCleanupWasCalled(4);
300 } 283
284 g_browser_process = NULL;
301 } 285 }
302 286
303 #if defined(OS_WIN) 287 #if defined(OS_WIN)
304 // Send a QuitTask to the given MessageLoop when the (file) thread has processed 288 // Send a QuitTask to the given MessageLoop when the (file) thread has processed
305 // our (other) recent requests (to save preferences). 289 // our (other) recent requests (to save preferences).
306 // Change the boolean so that the receiving thread will know that we did indeed 290 // Change the boolean so that the receiving thread will know that we did indeed
307 // send the QuitTask that terminated the message loop. 291 // send the QuitTask that terminated the message loop.
308 static void PostQuit(MessageLoop* message_loop) { 292 static void PostQuit(MessageLoop* message_loop) {
309 g_end_session_file_thread_has_completed = true; 293 g_end_session_file_thread_has_completed = true;
310 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 294 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask());
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 388
405 MetricsService* BrowserProcessImpl::metrics_service() { 389 MetricsService* BrowserProcessImpl::metrics_service() {
406 DCHECK(CalledOnValidThread()); 390 DCHECK(CalledOnValidThread());
407 if (!created_metrics_service_) 391 if (!created_metrics_service_)
408 CreateMetricsService(); 392 CreateMetricsService();
409 return metrics_service_.get(); 393 return metrics_service_.get();
410 } 394 }
411 395
412 IOThread* BrowserProcessImpl::io_thread() { 396 IOThread* BrowserProcessImpl::io_thread() {
413 DCHECK(CalledOnValidThread()); 397 DCHECK(CalledOnValidThread());
414 DCHECK(io_thread_.get()); 398 if (!created_io_thread_)
399 CreateIOThread();
415 return io_thread_.get(); 400 return io_thread_.get();
416 } 401 }
417 402
418 base::Thread* BrowserProcessImpl::file_thread() { 403 base::Thread* BrowserProcessImpl::file_thread() {
419 DCHECK(CalledOnValidThread()); 404 DCHECK(CalledOnValidThread());
420 return BrowserThread::UnsafeGetBrowserThread(BrowserThread::FILE); 405 if (!created_file_thread_)
406 CreateFileThread();
407 return file_thread_.get();
421 } 408 }
422 409
423 base::Thread* BrowserProcessImpl::db_thread() { 410 base::Thread* BrowserProcessImpl::db_thread() {
424 DCHECK(CalledOnValidThread()); 411 DCHECK(CalledOnValidThread());
425 return BrowserThread::UnsafeGetBrowserThread(BrowserThread::DB); 412 if (!created_db_thread_)
413 CreateDBThread();
414 return db_thread_.get();
426 } 415 }
427 416
428 base::Thread* BrowserProcessImpl::process_launcher_thread() { 417 base::Thread* BrowserProcessImpl::process_launcher_thread() {
429 DCHECK(CalledOnValidThread()); 418 DCHECK(CalledOnValidThread());
430 return BrowserThread::UnsafeGetBrowserThread(BrowserThread::PROCESS_LAUNCHER); 419 if (!created_process_launcher_thread_)
420 CreateProcessLauncherThread();
421 return process_launcher_thread_.get();
431 } 422 }
432 423
433 base::Thread* BrowserProcessImpl::cache_thread() { 424 base::Thread* BrowserProcessImpl::cache_thread() {
434 DCHECK(CalledOnValidThread()); 425 DCHECK(CalledOnValidThread());
435 return BrowserThread::UnsafeGetBrowserThread(BrowserThread::CACHE); 426 if (!created_cache_thread_)
427 CreateCacheThread();
428 return cache_thread_.get();
436 } 429 }
437 430
438 WatchDogThread* BrowserProcessImpl::watchdog_thread() { 431 WatchDogThread* BrowserProcessImpl::watchdog_thread() {
439 DCHECK(CalledOnValidThread()); 432 DCHECK(CalledOnValidThread());
440 if (!created_watchdog_thread_) 433 if (!created_watchdog_thread_)
441 CreateWatchdogThread(); 434 CreateWatchdogThread();
442 DCHECK(watchdog_thread_.get() != NULL); 435 DCHECK(watchdog_thread_.get() != NULL);
443 return watchdog_thread_.get(); 436 return watchdog_thread_.get();
444 } 437 }
445 438
446 #if defined(OS_CHROMEOS) 439 #if defined(OS_CHROMEOS)
447 base::Thread* BrowserProcessImpl::web_socket_proxy_thread() { 440 base::Thread* BrowserProcessImpl::web_socket_proxy_thread() {
448 DCHECK(CalledOnValidThread()); 441 DCHECK(CalledOnValidThread());
449 return BrowserThread::UnsafeGetBrowserThread(BrowserThread::WEB_SOCKET_PROXY); 442 if (!created_web_socket_proxy_thread_)
443 CreateWebSocketProxyThread();
444 DCHECK(web_socket_proxy_thread_.get() != NULL);
445 return web_socket_proxy_thread_.get();
450 } 446 }
451 #endif 447 #endif
452 448
453 ProfileManager* BrowserProcessImpl::profile_manager() { 449 ProfileManager* BrowserProcessImpl::profile_manager() {
454 DCHECK(CalledOnValidThread()); 450 DCHECK(CalledOnValidThread());
455 if (!created_profile_manager_) 451 if (!created_profile_manager_)
456 CreateProfileManager(); 452 CreateProfileManager();
457 return profile_manager_.get(); 453 return profile_manager_.get();
458 } 454 }
459 455
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 635
640 safe_browsing::ClientSideDetectionService* 636 safe_browsing::ClientSideDetectionService*
641 BrowserProcessImpl::safe_browsing_detection_service() { 637 BrowserProcessImpl::safe_browsing_detection_service() {
642 DCHECK(CalledOnValidThread()); 638 DCHECK(CalledOnValidThread());
643 if (safe_browsing_service()) 639 if (safe_browsing_service())
644 return safe_browsing_service()->safe_browsing_detection_service(); 640 return safe_browsing_service()->safe_browsing_detection_service();
645 return NULL; 641 return NULL;
646 } 642 }
647 643
648 bool BrowserProcessImpl::plugin_finder_disabled() const { 644 bool BrowserProcessImpl::plugin_finder_disabled() const {
649 if (plugin_finder_disabled_pref_.get()) 645 return *plugin_finder_disabled_pref_;
650 return plugin_finder_disabled_pref_->GetValue();
651 else
652 return false;
653 } 646 }
654 647
655 void BrowserProcessImpl::Observe(int type, 648 void BrowserProcessImpl::Observe(int type,
656 const content::NotificationSource& source, 649 const content::NotificationSource& source,
657 const content::NotificationDetails& details) { 650 const content::NotificationDetails& details) {
658 if (type == chrome::NOTIFICATION_PREF_CHANGED) { 651 if (type == chrome::NOTIFICATION_PREF_CHANGED) {
659 std::string* pref = content::Details<std::string>(details).ptr(); 652 std::string* pref = content::Details<std::string>(details).ptr();
660 if (*pref == prefs::kDefaultBrowserSettingEnabled) { 653 if (*pref == prefs::kDefaultBrowserSettingEnabled) {
661 ApplyDefaultBrowserPolicy(); 654 ApplyDefaultBrowserPolicy();
662 } else if (*pref == prefs::kDisabledSchemes) { 655 } else if (*pref == prefs::kDisabledSchemes) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 ApplyAllowCrossOriginAuthPromptPolicy(); 750 ApplyAllowCrossOriginAuthPromptPolicy();
758 } 751 }
759 752
760 void BrowserProcessImpl::CreateMetricsService() { 753 void BrowserProcessImpl::CreateMetricsService() {
761 DCHECK(!created_metrics_service_ && metrics_service_.get() == NULL); 754 DCHECK(!created_metrics_service_ && metrics_service_.get() == NULL);
762 created_metrics_service_ = true; 755 created_metrics_service_ = true;
763 756
764 metrics_service_.reset(new MetricsService); 757 metrics_service_.reset(new MetricsService);
765 } 758 }
766 759
767 void BrowserProcessImpl::CreateIOThreadState() { 760 void BrowserProcessImpl::CreateIOThread() {
768 // Prior to any processing happening on the io thread, we create the 761 DCHECK(!created_io_thread_ && io_thread_.get() == NULL);
769 // plugin service as it is predominantly used from the io thread, 762 created_io_thread_ = true;
770 // but must be created on the main thread. The service ctor is 763
771 // inexpensive and does not invoke the io_thread() accessor. 764 // Prior to starting the io thread, we create the plugin service as
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.
772 PluginService* plugin_service = PluginService::GetInstance(); 768 PluginService* plugin_service = PluginService::GetInstance();
773 plugin_service->Init(); 769 plugin_service->Init();
774 plugin_service->set_filter(ChromePluginServiceFilter::GetInstance()); 770 plugin_service->set_filter(ChromePluginServiceFilter::GetInstance());
775 plugin_service->StartWatchingPlugins(); 771 plugin_service->StartWatchingPlugins();
776 772
777 // Register the internal Flash if available. 773 // Register the internal Flash if available.
778 FilePath path; 774 FilePath path;
779 if (!CommandLine::ForCurrentProcess()->HasSwitch( 775 if (!CommandLine::ForCurrentProcess()->HasSwitch(
780 switches::kDisableInternalFlash) && 776 switches::kDisableInternalFlash) &&
781 PathService::Get(chrome::FILE_FLASH_PLUGIN, &path)) { 777 PathService::Get(chrome::FILE_FLASH_PLUGIN, &path)) {
782 plugin_service->AddExtraPluginPath(path); 778 plugin_service->AddExtraPluginPath(path);
783 } 779 }
784 780
785 #if defined(OS_POSIX) 781 #if defined(OS_POSIX)
786 // Also find plugins in a user-specific plugins dir, 782 // Also find plugins in a user-specific plugins dir,
787 // e.g. ~/.config/chromium/Plugins. 783 // e.g. ~/.config/chromium/Plugins.
788 FilePath user_data_dir; 784 FilePath user_data_dir;
789 if (PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { 785 if (PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) {
790 plugin_service->AddExtraPluginPath(user_data_dir.Append("Plugins")); 786 plugin_service->AddExtraPluginPath(user_data_dir.Append("Plugins"));
791 } 787 }
792 #endif 788 #endif
793 789
794 scoped_ptr<IOThread> thread(new IOThread( 790 scoped_ptr<IOThread> thread(new IOThread(
795 local_state(), net_log_.get(), extension_event_router_forwarder_.get())); 791 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
799 void BrowserProcessImpl::CreateWatchdogThread() { 869 void BrowserProcessImpl::CreateWatchdogThread() {
800 DCHECK(!created_watchdog_thread_ && watchdog_thread_.get() == NULL); 870 DCHECK(!created_watchdog_thread_ && watchdog_thread_.get() == NULL);
801 created_watchdog_thread_ = true; 871 created_watchdog_thread_ = true;
802 872
803 scoped_ptr<WatchDogThread> thread(new WatchDogThread()); 873 scoped_ptr<WatchDogThread> thread(new WatchDogThread());
804 if (!thread->Start()) 874 if (!thread->Start())
805 return; 875 return;
806 watchdog_thread_.swap(thread); 876 watchdog_thread_.swap(thread);
807 } 877 }
808 878
(...skipping 25 matching lines...) Expand all
834 // Initialize the notification for the default browser setting policy. 904 // Initialize the notification for the default browser setting policy.
835 local_state_->RegisterBooleanPref(prefs::kDefaultBrowserSettingEnabled, 905 local_state_->RegisterBooleanPref(prefs::kDefaultBrowserSettingEnabled,
836 false); 906 false);
837 if (local_state_->IsManagedPreference(prefs::kDefaultBrowserSettingEnabled)) 907 if (local_state_->IsManagedPreference(prefs::kDefaultBrowserSettingEnabled))
838 ApplyDefaultBrowserPolicy(); 908 ApplyDefaultBrowserPolicy();
839 pref_change_registrar_.Add(prefs::kDefaultBrowserSettingEnabled, this); 909 pref_change_registrar_.Add(prefs::kDefaultBrowserSettingEnabled, this);
840 910
841 // Initialize the preference for the plugin finder policy. 911 // Initialize the preference for the plugin finder policy.
842 // This preference is only needed on the IO thread so make it available there. 912 // This preference is only needed on the IO thread so make it available there.
843 local_state_->RegisterBooleanPref(prefs::kDisablePluginFinder, false); 913 local_state_->RegisterBooleanPref(prefs::kDisablePluginFinder, false);
844 plugin_finder_disabled_pref_.reset(new BooleanPrefMember); 914 plugin_finder_disabled_pref_.Init(prefs::kDisablePluginFinder,
845 plugin_finder_disabled_pref_->Init(prefs::kDisablePluginFinder,
846 local_state_.get(), NULL); 915 local_state_.get(), NULL);
847 plugin_finder_disabled_pref_->MoveToThread(BrowserThread::IO); 916 plugin_finder_disabled_pref_.MoveToThread(BrowserThread::IO);
848 917
849 // Another policy that needs to be defined before the net subsystem is 918 // Another policy that needs to be defined before the net subsystem is
850 // initialized is MaxConnectionsPerProxy so we do it here. 919 // initialized is MaxConnectionsPerProxy so we do it here.
851 local_state_->RegisterIntegerPref(prefs::kMaxConnectionsPerProxy, 920 local_state_->RegisterIntegerPref(prefs::kMaxConnectionsPerProxy,
852 net::kDefaultMaxSocketsPerProxyServer); 921 net::kDefaultMaxSocketsPerProxyServer);
853 int max_per_proxy = local_state_->GetInteger(prefs::kMaxConnectionsPerProxy); 922 int max_per_proxy = local_state_->GetInteger(prefs::kMaxConnectionsPerProxy);
854 net::ClientSocketPoolManager::set_max_sockets_per_proxy_server( 923 net::ClientSocketPoolManager::set_max_sockets_per_proxy_server(
855 std::max(std::min(max_per_proxy, 99), 924 std::max(std::min(max_per_proxy, 99),
856 net::ClientSocketPoolManager::max_sockets_per_group())); 925 net::ClientSocketPoolManager::max_sockets_per_group()));
857 926
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 } 1077 }
1009 1078
1010 void BrowserProcessImpl::OnAutoupdateTimer() { 1079 void BrowserProcessImpl::OnAutoupdateTimer() {
1011 if (CanAutorestartForUpdate()) { 1080 if (CanAutorestartForUpdate()) {
1012 DLOG(WARNING) << "Detected update. Restarting browser."; 1081 DLOG(WARNING) << "Detected update. Restarting browser.";
1013 RestartBackgroundInstance(); 1082 RestartBackgroundInstance();
1014 } 1083 }
1015 } 1084 }
1016 1085
1017 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) 1086 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
OLDNEW
« no previous file with comments | « chrome/browser/browser_process_impl.h ('k') | chrome/browser/browser_shutdown.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698