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 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
14 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
15 #include "base/task.h" | 15 #include "base/task.h" |
16 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
17 #include "base/threading/thread_restrictions.h" | 17 #include "base/threading/thread_restrictions.h" |
18 #include "chrome/browser/automation/automation_provider_list.h" | 18 #include "chrome/browser/automation/automation_provider_list.h" |
19 #include "chrome/browser/background/background_mode_manager.h" | 19 #include "chrome/browser/background/background_mode_manager.h" |
20 #include "chrome/browser/chrome_browser_main.h" | 20 #include "chrome/browser/chrome_browser_main.h" |
21 #include "chrome/browser/browser_process_sub_thread.h" | |
22 #include "chrome/browser/browser_trial.h" | 21 #include "chrome/browser/browser_trial.h" |
23 #include "chrome/browser/chrome_plugin_service_filter.h" | 22 #include "chrome/browser/chrome_plugin_service_filter.h" |
24 #include "chrome/browser/component_updater/component_updater_configurator.h" | 23 #include "chrome/browser/component_updater/component_updater_configurator.h" |
25 #include "chrome/browser/component_updater/component_updater_service.h" | 24 #include "chrome/browser/component_updater/component_updater_service.h" |
26 #include "chrome/browser/debugger/devtools_protocol_handler.h" | 25 #include "chrome/browser/debugger/devtools_protocol_handler.h" |
27 #include "chrome/browser/debugger/remote_debugging_server.h" | 26 #include "chrome/browser/debugger/remote_debugging_server.h" |
28 #include "chrome/browser/download/download_request_limiter.h" | 27 #include "chrome/browser/download/download_request_limiter.h" |
29 #include "chrome/browser/extensions/extension_event_router_forwarder.h" | 28 #include "chrome/browser/extensions/extension_event_router_forwarder.h" |
30 #include "chrome/browser/extensions/extension_tab_id_map.h" | 29 #include "chrome/browser/extensions/extension_tab_id_map.h" |
31 #include "chrome/browser/extensions/user_script_listener.h" | 30 #include "chrome/browser/extensions/user_script_listener.h" |
(...skipping 29 matching lines...) Expand all Loading... |
61 #include "chrome/common/chrome_switches.h" | 60 #include "chrome/common/chrome_switches.h" |
62 #include "chrome/common/default_plugin.h" | 61 #include "chrome/common/default_plugin.h" |
63 #include "chrome/common/extensions/extension_l10n_util.h" | 62 #include "chrome/common/extensions/extension_l10n_util.h" |
64 #include "chrome/common/extensions/extension_resource.h" | 63 #include "chrome/common/extensions/extension_resource.h" |
65 #include "chrome/common/json_pref_store.h" | 64 #include "chrome/common/json_pref_store.h" |
66 #include "chrome/common/pref_names.h" | 65 #include "chrome/common/pref_names.h" |
67 #include "chrome/common/switch_utils.h" | 66 #include "chrome/common/switch_utils.h" |
68 #include "chrome/common/url_constants.h" | 67 #include "chrome/common/url_constants.h" |
69 #include "chrome/installer/util/google_update_constants.h" | 68 #include "chrome/installer/util/google_update_constants.h" |
70 #include "content/browser/browser_child_process_host.h" | 69 #include "content/browser/browser_child_process_host.h" |
| 70 #include "content/browser/browser_process_sub_thread.h" |
71 #include "content/browser/browser_thread.h" | 71 #include "content/browser/browser_thread.h" |
72 #include "content/browser/child_process_security_policy.h" | 72 #include "content/browser/child_process_security_policy.h" |
73 #include "content/browser/debugger/devtools_manager.h" | 73 #include "content/browser/debugger/devtools_manager.h" |
74 #include "content/browser/download/download_file_manager.h" | 74 #include "content/browser/download/download_file_manager.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/render_process_host.h" | 80 #include "content/browser/renderer_host/render_process_host.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 created_sidebar_manager_(false), | 133 created_sidebar_manager_(false), |
134 created_browser_policy_connector_(false), | 134 created_browser_policy_connector_(false), |
135 created_notification_ui_manager_(false), | 135 created_notification_ui_manager_(false), |
136 created_safe_browsing_service_(false), | 136 created_safe_browsing_service_(false), |
137 module_ref_count_(0), | 137 module_ref_count_(0), |
138 did_start_(false), | 138 did_start_(false), |
139 checked_for_new_frames_(false), | 139 checked_for_new_frames_(false), |
140 using_new_frames_(false) { | 140 using_new_frames_(false) { |
141 g_browser_process = this; | 141 g_browser_process = this; |
142 clipboard_.reset(new ui::Clipboard); | 142 clipboard_.reset(new ui::Clipboard); |
143 main_notification_service_.reset(new NotificationService); | |
144 | 143 |
145 // Must be created after the NotificationService. | 144 // Must be created after the NotificationService. |
146 print_job_manager_.reset(new printing::PrintJobManager); | 145 print_job_manager_.reset(new printing::PrintJobManager); |
147 | 146 |
148 net_log_.reset(new ChromeNetLog); | 147 net_log_.reset(new ChromeNetLog); |
149 | 148 |
150 extension_event_router_forwarder_ = new ExtensionEventRouterForwarder; | 149 extension_event_router_forwarder_ = new ExtensionEventRouterForwarder; |
151 | 150 |
152 ExtensionTabIdMap::GetInstance()->Init(); | 151 ExtensionTabIdMap::GetInstance()->Init(); |
153 | 152 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 resource_dispatcher_host_.reset(); | 266 resource_dispatcher_host_.reset(); |
268 | 267 |
269 // Wait for the pending print jobs to finish. | 268 // Wait for the pending print jobs to finish. |
270 print_job_manager_->OnQuit(); | 269 print_job_manager_->OnQuit(); |
271 print_job_manager_.reset(); | 270 print_job_manager_.reset(); |
272 | 271 |
273 // Destroy TabCloseableStateWatcher before NotificationService since the | 272 // Destroy TabCloseableStateWatcher before NotificationService since the |
274 // former registers for notifications. | 273 // former registers for notifications. |
275 tab_closeable_state_watcher_.reset(); | 274 tab_closeable_state_watcher_.reset(); |
276 | 275 |
277 // Now OK to destroy NotificationService. | |
278 main_notification_service_.reset(); | |
279 | |
280 g_browser_process = NULL; | 276 g_browser_process = NULL; |
281 } | 277 } |
282 | 278 |
283 #if defined(OS_WIN) | 279 #if defined(OS_WIN) |
284 // Send a QuitTask to the given MessageLoop. | 280 // Send a QuitTask to the given MessageLoop. |
285 static void PostQuit(MessageLoop* message_loop) { | 281 static void PostQuit(MessageLoop* message_loop) { |
286 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask()); | 282 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask()); |
287 } | 283 } |
288 #elif defined(USE_X11) | 284 #elif defined(USE_X11) |
289 static void Signal(base::WaitableEvent* event) { | 285 static void Signal(base::WaitableEvent* event) { |
(...skipping 12 matching lines...) Expand all Loading... |
302 DCHECK(CalledOnValidThread()); | 298 DCHECK(CalledOnValidThread()); |
303 DCHECK_NE(0u, module_ref_count_); | 299 DCHECK_NE(0u, module_ref_count_); |
304 module_ref_count_--; | 300 module_ref_count_--; |
305 if (0 == module_ref_count_) { | 301 if (0 == module_ref_count_) { |
306 // Allow UI and IO threads to do blocking IO on shutdown, since we do a lot | 302 // Allow UI and IO threads to do blocking IO on shutdown, since we do a lot |
307 // of it on shutdown for valid reasons. | 303 // of it on shutdown for valid reasons. |
308 base::ThreadRestrictions::SetIOAllowed(true); | 304 base::ThreadRestrictions::SetIOAllowed(true); |
309 io_thread()->message_loop()->PostTask( | 305 io_thread()->message_loop()->PostTask( |
310 FROM_HERE, | 306 FROM_HERE, |
311 NewRunnableFunction(&base::ThreadRestrictions::SetIOAllowed, true)); | 307 NewRunnableFunction(&base::ThreadRestrictions::SetIOAllowed, true)); |
312 MessageLoop::current()->PostTask( | |
313 FROM_HERE, NewRunnableFunction(content::DidEndMainMessageLoop)); | |
314 MessageLoop::current()->Quit(); | 308 MessageLoop::current()->Quit(); |
315 } | 309 } |
316 return module_ref_count_; | 310 return module_ref_count_; |
317 } | 311 } |
318 | 312 |
319 void BrowserProcessImpl::EndSession() { | 313 void BrowserProcessImpl::EndSession() { |
320 // Mark all the profiles as clean. | 314 // Mark all the profiles as clean. |
321 ProfileManager* pm = profile_manager(); | 315 ProfileManager* pm = profile_manager(); |
322 std::vector<Profile*> profiles(pm->GetLoadedProfiles()); | 316 std::vector<Profile*> profiles(pm->GetLoadedProfiles()); |
323 for (size_t i = 0; i < profiles.size(); ++i) | 317 for (size_t i = 0; i < profiles.size(); ++i) |
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1098 } | 1092 } |
1099 | 1093 |
1100 void BrowserProcessImpl::OnAutoupdateTimer() { | 1094 void BrowserProcessImpl::OnAutoupdateTimer() { |
1101 if (CanAutorestartForUpdate()) { | 1095 if (CanAutorestartForUpdate()) { |
1102 DLOG(WARNING) << "Detected update. Restarting browser."; | 1096 DLOG(WARNING) << "Detected update. Restarting browser."; |
1103 RestartPersistentInstance(); | 1097 RestartPersistentInstance(); |
1104 } | 1098 } |
1105 } | 1099 } |
1106 | 1100 |
1107 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 1101 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
OLD | NEW |