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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 #include "content/browser/debugger/devtools_protocol_handler.h" | 73 #include "content/browser/debugger/devtools_protocol_handler.h" |
74 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 74 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
75 #include "content/browser/plugin_service.h" | 75 #include "content/browser/plugin_service.h" |
76 #include "content/browser/renderer_host/render_process_host.h" | 76 #include "content/browser/renderer_host/render_process_host.h" |
77 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 77 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
78 #include "content/common/notification_service.h" | 78 #include "content/common/notification_service.h" |
79 #include "ipc/ipc_logging.h" | 79 #include "ipc/ipc_logging.h" |
80 #include "net/url_request/url_request_context_getter.h" | 80 #include "net/url_request/url_request_context_getter.h" |
81 #include "ui/base/clipboard/clipboard.h" | 81 #include "ui/base/clipboard/clipboard.h" |
82 #include "ui/base/l10n/l10n_util.h" | 82 #include "ui/base/l10n/l10n_util.h" |
83 #include "webkit/database/database_tracker.h" | |
84 #include "webkit/plugins/npapi/plugin_list.h" | 83 #include "webkit/plugins/npapi/plugin_list.h" |
85 | 84 |
86 #if defined(OS_WIN) | 85 #if defined(OS_WIN) |
87 #include "views/focus/view_storage.h" | 86 #include "views/focus/view_storage.h" |
88 #endif | 87 #endif |
89 | 88 |
90 #if defined(IPC_MESSAGE_LOG_ENABLED) | 89 #if defined(IPC_MESSAGE_LOG_ENABLED) |
91 #include "content/common/child_process_messages.h" | 90 #include "content/common/child_process_messages.h" |
92 #endif | 91 #endif |
93 | 92 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 print_job_manager_.reset(new printing::PrintJobManager); | 141 print_job_manager_.reset(new printing::PrintJobManager); |
143 | 142 |
144 net_log_.reset(new ChromeNetLog); | 143 net_log_.reset(new ChromeNetLog); |
145 | 144 |
146 extension_event_router_forwarder_ = new ExtensionEventRouterForwarder; | 145 extension_event_router_forwarder_ = new ExtensionEventRouterForwarder; |
147 | 146 |
148 ExtensionTabIdMap::GetInstance()->Init(); | 147 ExtensionTabIdMap::GetInstance()->Init(); |
149 } | 148 } |
150 | 149 |
151 BrowserProcessImpl::~BrowserProcessImpl() { | 150 BrowserProcessImpl::~BrowserProcessImpl() { |
152 FilePath profile_path; | |
153 bool clear_local_state_on_exit; | |
154 | |
155 // Store the profile path for clearing local state data on exit. | |
156 clear_local_state_on_exit = ShouldClearLocalState(&profile_path); | |
157 | |
158 #if defined(OS_CHROMEOS) | 151 #if defined(OS_CHROMEOS) |
159 if (web_socket_proxy_thread_.get()) | 152 if (web_socket_proxy_thread_.get()) |
160 chromeos::WebSocketProxyController::Shutdown(); | 153 chromeos::WebSocketProxyController::Shutdown(); |
161 web_socket_proxy_thread_.reset(); | 154 web_socket_proxy_thread_.reset(); |
162 #endif | 155 #endif |
163 | 156 |
164 // Delete the AutomationProviderList before NotificationService, | 157 // Delete the AutomationProviderList before NotificationService, |
165 // since it may try to unregister notifications | 158 // since it may try to unregister notifications |
166 // Both NotificationService and AutomationProvider are singleton instances in | 159 // Both NotificationService and AutomationProvider are singleton instances in |
167 // the BrowserProcess. Since AutomationProvider may have some active | 160 // the BrowserProcess. Since AutomationProvider may have some active |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 print_job_manager_->OnQuit(); | 253 print_job_manager_->OnQuit(); |
261 print_job_manager_.reset(); | 254 print_job_manager_.reset(); |
262 | 255 |
263 // Destroy TabCloseableStateWatcher before NotificationService since the | 256 // Destroy TabCloseableStateWatcher before NotificationService since the |
264 // former registers for notifications. | 257 // former registers for notifications. |
265 tab_closeable_state_watcher_.reset(); | 258 tab_closeable_state_watcher_.reset(); |
266 | 259 |
267 // Now OK to destroy NotificationService. | 260 // Now OK to destroy NotificationService. |
268 main_notification_service_.reset(); | 261 main_notification_service_.reset(); |
269 | 262 |
270 // Prior to clearing local state, we want to complete tasks pending | |
271 // on the db thread too. | |
272 db_thread_.reset(); | |
273 | |
274 // Stop the watchdog thread after stopping other threads. | 263 // Stop the watchdog thread after stopping other threads. |
275 watchdog_thread_.reset(); | 264 watchdog_thread_.reset(); |
276 | 265 |
277 // At this point, no render process exist and the file, io, db, and | |
278 // webkit threads in this process have all terminated, so it's safe | |
279 // to access local state data such as cookies, database, or local storage. | |
280 if (clear_local_state_on_exit) | |
281 ClearLocalState(profile_path); | |
282 | |
283 g_browser_process = NULL; | 266 g_browser_process = NULL; |
284 } | 267 } |
285 | 268 |
286 #if defined(OS_WIN) | 269 #if defined(OS_WIN) |
287 // Send a QuitTask to the given MessageLoop. | 270 // Send a QuitTask to the given MessageLoop. |
288 static void PostQuit(MessageLoop* message_loop) { | 271 static void PostQuit(MessageLoop* message_loop) { |
289 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask()); | 272 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask()); |
290 } | 273 } |
291 #elif defined(USE_X11) | 274 #elif defined(USE_X11) |
292 static void Signal(base::WaitableEvent* event) { | 275 static void Signal(base::WaitableEvent* event) { |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 return prerender_tracker_.get(); | 649 return prerender_tracker_.get(); |
667 } | 650 } |
668 | 651 |
669 MHTMLGenerationManager* BrowserProcessImpl::mhtml_generation_manager() { | 652 MHTMLGenerationManager* BrowserProcessImpl::mhtml_generation_manager() { |
670 if (!mhtml_generation_manager_.get()) | 653 if (!mhtml_generation_manager_.get()) |
671 mhtml_generation_manager_ = new MHTMLGenerationManager(); | 654 mhtml_generation_manager_ = new MHTMLGenerationManager(); |
672 | 655 |
673 return mhtml_generation_manager_.get(); | 656 return mhtml_generation_manager_.get(); |
674 } | 657 } |
675 | 658 |
676 void BrowserProcessImpl::ClearLocalState(const FilePath& profile_path) { | |
677 webkit_database::DatabaseTracker::ClearLocalState(profile_path); | |
678 } | |
679 | |
680 bool BrowserProcessImpl::ShouldClearLocalState(FilePath* profile_path) { | |
681 FilePath user_data_dir; | |
682 Profile* profile; | |
683 | |
684 // Check for the existence of a profile manager. When quitting early, | |
685 // e.g. because another chrome instance is running, or when invoked with | |
686 // options such as --uninstall or --try-chrome-again=0, the profile manager | |
687 // does not exist yet. | |
688 if (!profile_manager_.get()) | |
689 return false; | |
690 | |
691 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | |
692 profile = profile_manager_->GetDefaultProfile(user_data_dir); | |
693 if (!profile) | |
694 return false; | |
695 *profile_path = profile->GetPath(); | |
696 return profile->GetPrefs()->GetBoolean(prefs::kClearSiteDataOnExit); | |
697 } | |
698 | |
699 void BrowserProcessImpl::CreateResourceDispatcherHost() { | 659 void BrowserProcessImpl::CreateResourceDispatcherHost() { |
700 DCHECK(!created_resource_dispatcher_host_ && | 660 DCHECK(!created_resource_dispatcher_host_ && |
701 resource_dispatcher_host_.get() == NULL); | 661 resource_dispatcher_host_.get() == NULL); |
702 created_resource_dispatcher_host_ = true; | 662 created_resource_dispatcher_host_ = true; |
703 | 663 |
704 // UserScriptListener will delete itself. | 664 // UserScriptListener will delete itself. |
705 ResourceQueue::DelegateSet resource_queue_delegates; | 665 ResourceQueue::DelegateSet resource_queue_delegates; |
706 resource_queue_delegates.insert(new UserScriptListener()); | 666 resource_queue_delegates.insert(new UserScriptListener()); |
707 | 667 |
708 resource_dispatcher_host_.reset( | 668 resource_dispatcher_host_.reset( |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1108 } | 1068 } |
1109 | 1069 |
1110 void BrowserProcessImpl::OnAutoupdateTimer() { | 1070 void BrowserProcessImpl::OnAutoupdateTimer() { |
1111 if (CanAutorestartForUpdate()) { | 1071 if (CanAutorestartForUpdate()) { |
1112 DLOG(WARNING) << "Detected update. Restarting browser."; | 1072 DLOG(WARNING) << "Detected update. Restarting browser."; |
1113 RestartPersistentInstance(); | 1073 RestartPersistentInstance(); |
1114 } | 1074 } |
1115 } | 1075 } |
1116 | 1076 |
1117 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 1077 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
OLD | NEW |