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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 #if defined(OS_WIN) | 81 #if defined(OS_WIN) |
82 #include "views/focus/view_storage.h" | 82 #include "views/focus/view_storage.h" |
83 #endif | 83 #endif |
84 | 84 |
85 #if defined(IPC_MESSAGE_LOG_ENABLED) | 85 #if defined(IPC_MESSAGE_LOG_ENABLED) |
86 #include "content/common/child_process_messages.h" | 86 #include "content/common/child_process_messages.h" |
87 #endif | 87 #endif |
88 | 88 |
89 #if defined(OS_CHROMEOS) | 89 #if defined(OS_CHROMEOS) |
90 #include "chrome/browser/chromeos/proxy_config_service_impl.h" | 90 #include "chrome/browser/chromeos/proxy_config_service_impl.h" |
| 91 #include "chrome/browser/chromeos/web_socket_proxy_controller.h" |
91 #endif // defined(OS_CHROMEOS) | 92 #endif // defined(OS_CHROMEOS) |
92 | 93 |
93 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 94 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
94 // How often to check if the persistent instance of Chrome needs to restart | 95 // How often to check if the persistent instance of Chrome needs to restart |
95 // to install an update. | 96 // to install an update. |
96 static const int kUpdateCheckIntervalHours = 6; | 97 static const int kUpdateCheckIntervalHours = 6; |
97 #endif | 98 #endif |
98 | 99 |
99 #if defined(USE_X11) | 100 #if defined(USE_X11) |
100 // How long to wait for the File thread to complete during EndSession, on | 101 // How long to wait for the File thread to complete during EndSession, on |
101 // Linux. We have a timeout here because we're unable to run the UI messageloop | 102 // Linux. We have a timeout here because we're unable to run the UI messageloop |
102 // and there's some deadlock risk. Our only option is to exit anyway. | 103 // and there's some deadlock risk. Our only option is to exit anyway. |
103 static const int kEndSessionTimeoutSeconds = 10; | 104 static const int kEndSessionTimeoutSeconds = 10; |
104 #endif | 105 #endif |
105 | 106 |
106 BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line) | 107 BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line) |
107 : created_resource_dispatcher_host_(false), | 108 : created_resource_dispatcher_host_(false), |
108 created_metrics_service_(false), | 109 created_metrics_service_(false), |
109 created_io_thread_(false), | 110 created_io_thread_(false), |
110 created_file_thread_(false), | 111 created_file_thread_(false), |
111 created_db_thread_(false), | 112 created_db_thread_(false), |
112 created_process_launcher_thread_(false), | 113 created_process_launcher_thread_(false), |
113 created_cache_thread_(false), | 114 created_cache_thread_(false), |
114 created_gpu_thread_(false), | 115 created_gpu_thread_(false), |
115 created_watchdog_thread_(false), | 116 created_watchdog_thread_(false), |
| 117 #if defined(OS_CHROMEOS) |
| 118 created_web_socket_proxy_thread_(false), |
| 119 #endif |
116 created_profile_manager_(false), | 120 created_profile_manager_(false), |
117 created_local_state_(false), | 121 created_local_state_(false), |
118 created_icon_manager_(false), | 122 created_icon_manager_(false), |
119 created_devtools_manager_(false), | 123 created_devtools_manager_(false), |
120 created_sidebar_manager_(false), | 124 created_sidebar_manager_(false), |
121 created_browser_policy_connector_(false), | 125 created_browser_policy_connector_(false), |
122 created_notification_ui_manager_(false), | 126 created_notification_ui_manager_(false), |
123 created_safe_browsing_detection_service_(false), | 127 created_safe_browsing_detection_service_(false), |
124 module_ref_count_(0), | 128 module_ref_count_(0), |
125 did_start_(false), | 129 did_start_(false), |
(...skipping 19 matching lines...) Expand all Loading... |
145 ExtensionTabIdMap::GetInstance()->Init(); | 149 ExtensionTabIdMap::GetInstance()->Init(); |
146 } | 150 } |
147 | 151 |
148 BrowserProcessImpl::~BrowserProcessImpl() { | 152 BrowserProcessImpl::~BrowserProcessImpl() { |
149 FilePath profile_path; | 153 FilePath profile_path; |
150 bool clear_local_state_on_exit; | 154 bool clear_local_state_on_exit; |
151 | 155 |
152 // Store the profile path for clearing local state data on exit. | 156 // Store the profile path for clearing local state data on exit. |
153 clear_local_state_on_exit = ShouldClearLocalState(&profile_path); | 157 clear_local_state_on_exit = ShouldClearLocalState(&profile_path); |
154 | 158 |
| 159 #if defined(OS_CHROMEOS) |
| 160 if (web_socket_proxy_thread_.get()) |
| 161 chromeos::WebSocketProxyController::Shutdown(); |
| 162 web_socket_proxy_thread_.reset(); |
| 163 #endif |
| 164 |
155 // Delete the AutomationProviderList before NotificationService, | 165 // Delete the AutomationProviderList before NotificationService, |
156 // since it may try to unregister notifications | 166 // since it may try to unregister notifications |
157 // Both NotificationService and AutomationProvider are singleton instances in | 167 // Both NotificationService and AutomationProvider are singleton instances in |
158 // the BrowserProcess. Since AutomationProvider may have some active | 168 // the BrowserProcess. Since AutomationProvider may have some active |
159 // notification observers, it is essential that it gets destroyed before the | 169 // notification observers, it is essential that it gets destroyed before the |
160 // NotificationService. NotificationService won't be destroyed until after | 170 // NotificationService. NotificationService won't be destroyed until after |
161 // this destructor is run. | 171 // this destructor is run. |
162 automation_provider_list_.reset(); | 172 automation_provider_list_.reset(); |
163 | 173 |
164 // We need to shutdown the SdchDictionaryFetcher as it regularly holds | 174 // We need to shutdown the SdchDictionaryFetcher as it regularly holds |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 #endif | 438 #endif |
429 | 439 |
430 WatchDogThread* BrowserProcessImpl::watchdog_thread() { | 440 WatchDogThread* BrowserProcessImpl::watchdog_thread() { |
431 DCHECK(CalledOnValidThread()); | 441 DCHECK(CalledOnValidThread()); |
432 if (!created_watchdog_thread_) | 442 if (!created_watchdog_thread_) |
433 CreateWatchdogThread(); | 443 CreateWatchdogThread(); |
434 DCHECK(watchdog_thread_.get() != NULL); | 444 DCHECK(watchdog_thread_.get() != NULL); |
435 return watchdog_thread_.get(); | 445 return watchdog_thread_.get(); |
436 } | 446 } |
437 | 447 |
| 448 #if defined(OS_CHROMEOS) |
| 449 base::Thread* BrowserProcessImpl::web_socket_proxy_thread() { |
| 450 DCHECK(CalledOnValidThread()); |
| 451 if (!created_web_socket_proxy_thread_) |
| 452 CreateWebSocketProxyThread(); |
| 453 DCHECK(web_socket_proxy_thread_.get() != NULL); |
| 454 return web_socket_proxy_thread_.get(); |
| 455 } |
| 456 #endif |
| 457 |
438 ProfileManager* BrowserProcessImpl::profile_manager() { | 458 ProfileManager* BrowserProcessImpl::profile_manager() { |
439 DCHECK(CalledOnValidThread()); | 459 DCHECK(CalledOnValidThread()); |
440 if (!created_profile_manager_) | 460 if (!created_profile_manager_) |
441 CreateProfileManager(); | 461 CreateProfileManager(); |
442 return profile_manager_.get(); | 462 return profile_manager_.get(); |
443 } | 463 } |
444 | 464 |
445 PrefService* BrowserProcessImpl::local_state() { | 465 PrefService* BrowserProcessImpl::local_state() { |
446 DCHECK(CalledOnValidThread()); | 466 DCHECK(CalledOnValidThread()); |
447 if (!created_local_state_) | 467 if (!created_local_state_) |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 // messages in such a way that Google Update can communicate back to us. | 776 // messages in such a way that Google Update can communicate back to us. |
757 options.message_loop_type = MessageLoop::TYPE_UI; | 777 options.message_loop_type = MessageLoop::TYPE_UI; |
758 #else | 778 #else |
759 options.message_loop_type = MessageLoop::TYPE_IO; | 779 options.message_loop_type = MessageLoop::TYPE_IO; |
760 #endif | 780 #endif |
761 if (!thread->StartWithOptions(options)) | 781 if (!thread->StartWithOptions(options)) |
762 return; | 782 return; |
763 file_thread_.swap(thread); | 783 file_thread_.swap(thread); |
764 } | 784 } |
765 | 785 |
| 786 #if defined(OS_CHROMEOS) |
| 787 void BrowserProcessImpl::CreateWebSocketProxyThread() { |
| 788 DCHECK(!created_web_socket_proxy_thread_); |
| 789 DCHECK(web_socket_proxy_thread_.get() == NULL); |
| 790 created_web_socket_proxy_thread_ = true; |
| 791 |
| 792 scoped_ptr<base::Thread> thread( |
| 793 new BrowserProcessSubThread(BrowserThread::WEB_SOCKET_PROXY)); |
| 794 base::Thread::Options options; |
| 795 options.message_loop_type = MessageLoop::TYPE_IO; |
| 796 if (!thread->StartWithOptions(options)) |
| 797 return; |
| 798 web_socket_proxy_thread_.swap(thread); |
| 799 } |
| 800 #endif |
| 801 |
766 void BrowserProcessImpl::CreateDBThread() { | 802 void BrowserProcessImpl::CreateDBThread() { |
767 DCHECK(!created_db_thread_ && db_thread_.get() == NULL); | 803 DCHECK(!created_db_thread_ && db_thread_.get() == NULL); |
768 created_db_thread_ = true; | 804 created_db_thread_ = true; |
769 | 805 |
770 scoped_ptr<base::Thread> thread( | 806 scoped_ptr<base::Thread> thread( |
771 new BrowserProcessSubThread(BrowserThread::DB)); | 807 new BrowserProcessSubThread(BrowserThread::DB)); |
772 if (!thread->Start()) | 808 if (!thread->Start()) |
773 return; | 809 return; |
774 db_thread_.swap(thread); | 810 db_thread_.swap(thread); |
775 } | 811 } |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1070 } | 1106 } |
1071 | 1107 |
1072 void BrowserProcessImpl::OnAutoupdateTimer() { | 1108 void BrowserProcessImpl::OnAutoupdateTimer() { |
1073 if (CanAutorestartForUpdate()) { | 1109 if (CanAutorestartForUpdate()) { |
1074 DLOG(WARNING) << "Detected update. Restarting browser."; | 1110 DLOG(WARNING) << "Detected update. Restarting browser."; |
1075 RestartPersistentInstance(); | 1111 RestartPersistentInstance(); |
1076 } | 1112 } |
1077 } | 1113 } |
1078 | 1114 |
1079 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 1115 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
OLD | NEW |