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

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

Issue 7234014: Move code to clear web databases on shutdown to the database tracker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 9 years, 5 months 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 #include "content/browser/child_process_security_policy.h" 74 #include "content/browser/child_process_security_policy.h"
75 #include "content/browser/gpu/gpu_process_host_ui_shim.h" 75 #include "content/browser/gpu/gpu_process_host_ui_shim.h"
76 #include "content/browser/plugin_service.h" 76 #include "content/browser/plugin_service.h"
77 #include "content/browser/renderer_host/render_process_host.h" 77 #include "content/browser/renderer_host/render_process_host.h"
78 #include "content/browser/renderer_host/resource_dispatcher_host.h" 78 #include "content/browser/renderer_host/resource_dispatcher_host.h"
79 #include "content/common/notification_service.h" 79 #include "content/common/notification_service.h"
80 #include "ipc/ipc_logging.h" 80 #include "ipc/ipc_logging.h"
81 #include "net/url_request/url_request_context_getter.h" 81 #include "net/url_request/url_request_context_getter.h"
82 #include "ui/base/clipboard/clipboard.h" 82 #include "ui/base/clipboard/clipboard.h"
83 #include "ui/base/l10n/l10n_util.h" 83 #include "ui/base/l10n/l10n_util.h"
84 #include "webkit/database/database_tracker.h"
85 #include "webkit/plugins/npapi/plugin_list.h" 84 #include "webkit/plugins/npapi/plugin_list.h"
86 85
87 #if defined(OS_WIN) 86 #if defined(OS_WIN)
88 #include "views/focus/view_storage.h" 87 #include "views/focus/view_storage.h"
89 #endif 88 #endif
90 89
91 #if defined(IPC_MESSAGE_LOG_ENABLED) 90 #if defined(IPC_MESSAGE_LOG_ENABLED)
92 #include "content/common/child_process_messages.h" 91 #include "content/common/child_process_messages.h"
93 #endif 92 #endif
94 93
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 print_job_manager_.reset(new printing::PrintJobManager); 146 print_job_manager_.reset(new printing::PrintJobManager);
148 147
149 net_log_.reset(new ChromeNetLog); 148 net_log_.reset(new ChromeNetLog);
150 149
151 extension_event_router_forwarder_ = new ExtensionEventRouterForwarder; 150 extension_event_router_forwarder_ = new ExtensionEventRouterForwarder;
152 151
153 ExtensionTabIdMap::GetInstance()->Init(); 152 ExtensionTabIdMap::GetInstance()->Init();
154 } 153 }
155 154
156 BrowserProcessImpl::~BrowserProcessImpl() { 155 BrowserProcessImpl::~BrowserProcessImpl() {
157 FilePath profile_path;
158 bool clear_local_state_on_exit;
159
160 // Store the profile path for clearing local state data on exit.
161 clear_local_state_on_exit = ShouldClearLocalState(&profile_path);
162
163 #if defined(OS_CHROMEOS) 156 #if defined(OS_CHROMEOS)
164 if (web_socket_proxy_thread_.get()) 157 if (web_socket_proxy_thread_.get())
165 chromeos::WebSocketProxyController::Shutdown(); 158 chromeos::WebSocketProxyController::Shutdown();
166 web_socket_proxy_thread_.reset(); 159 web_socket_proxy_thread_.reset();
167 #endif 160 #endif
168 161
169 // Delete the AutomationProviderList before NotificationService, 162 // Delete the AutomationProviderList before NotificationService,
170 // since it may try to unregister notifications 163 // since it may try to unregister notifications
171 // Both NotificationService and AutomationProvider are singleton instances in 164 // Both NotificationService and AutomationProvider are singleton instances in
172 // the BrowserProcess. Since AutomationProvider may have some active 165 // the BrowserProcess. Since AutomationProvider may have some active
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 print_job_manager_->OnQuit(); 261 print_job_manager_->OnQuit();
269 print_job_manager_.reset(); 262 print_job_manager_.reset();
270 263
271 // Destroy TabCloseableStateWatcher before NotificationService since the 264 // Destroy TabCloseableStateWatcher before NotificationService since the
272 // former registers for notifications. 265 // former registers for notifications.
273 tab_closeable_state_watcher_.reset(); 266 tab_closeable_state_watcher_.reset();
274 267
275 // Now OK to destroy NotificationService. 268 // Now OK to destroy NotificationService.
276 main_notification_service_.reset(); 269 main_notification_service_.reset();
277 270
278 // Prior to clearing local state, we want to complete tasks pending
279 // on the db thread too.
280 db_thread_.reset();
281
282 // Stop the watchdog thread after stopping other threads. 271 // Stop the watchdog thread after stopping other threads.
283 watchdog_thread_.reset(); 272 watchdog_thread_.reset();
284 273
285 // At this point, no render process exist and the file, io, db, and
286 // webkit threads in this process have all terminated, so it's safe
287 // to access local state data such as cookies, database, or local storage.
288 if (clear_local_state_on_exit)
289 ClearLocalState(profile_path);
290
291 g_browser_process = NULL; 274 g_browser_process = NULL;
292 } 275 }
293 276
294 #if defined(OS_WIN) 277 #if defined(OS_WIN)
295 // Send a QuitTask to the given MessageLoop. 278 // Send a QuitTask to the given MessageLoop.
296 static void PostQuit(MessageLoop* message_loop) { 279 static void PostQuit(MessageLoop* message_loop) {
297 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 280 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask());
298 } 281 }
299 #elif defined(USE_X11) 282 #elif defined(USE_X11)
300 static void Signal(base::WaitableEvent* event) { 283 static void Signal(base::WaitableEvent* event) {
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 return prerender_tracker_.get(); 674 return prerender_tracker_.get();
692 } 675 }
693 676
694 MHTMLGenerationManager* BrowserProcessImpl::mhtml_generation_manager() { 677 MHTMLGenerationManager* BrowserProcessImpl::mhtml_generation_manager() {
695 if (!mhtml_generation_manager_.get()) 678 if (!mhtml_generation_manager_.get())
696 mhtml_generation_manager_ = new MHTMLGenerationManager(); 679 mhtml_generation_manager_ = new MHTMLGenerationManager();
697 680
698 return mhtml_generation_manager_.get(); 681 return mhtml_generation_manager_.get();
699 } 682 }
700 683
701 void BrowserProcessImpl::ClearLocalState(const FilePath& profile_path) {
702 webkit_database::DatabaseTracker::ClearLocalState(profile_path);
703 }
704
705 bool BrowserProcessImpl::ShouldClearLocalState(FilePath* profile_path) {
706 FilePath user_data_dir;
707 Profile* profile;
708
709 // Check for the existence of a profile manager. When quitting early,
710 // e.g. because another chrome instance is running, or when invoked with
711 // options such as --uninstall or --try-chrome-again=0, the profile manager
712 // does not exist yet.
713 if (!profile_manager_.get())
714 return false;
715
716 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
717 profile = profile_manager_->GetDefaultProfile(user_data_dir);
718 if (!profile)
719 return false;
720 *profile_path = profile->GetPath();
721 return profile->GetPrefs()->GetBoolean(prefs::kClearSiteDataOnExit);
722 }
723
724 void BrowserProcessImpl::CreateResourceDispatcherHost() { 684 void BrowserProcessImpl::CreateResourceDispatcherHost() {
725 DCHECK(!created_resource_dispatcher_host_ && 685 DCHECK(!created_resource_dispatcher_host_ &&
726 resource_dispatcher_host_.get() == NULL); 686 resource_dispatcher_host_.get() == NULL);
727 created_resource_dispatcher_host_ = true; 687 created_resource_dispatcher_host_ = true;
728 688
729 // UserScriptListener will delete itself. 689 // UserScriptListener will delete itself.
730 ResourceQueue::DelegateSet resource_queue_delegates; 690 ResourceQueue::DelegateSet resource_queue_delegates;
731 resource_queue_delegates.insert(new UserScriptListener()); 691 resource_queue_delegates.insert(new UserScriptListener());
732 692
733 resource_dispatcher_host_.reset( 693 resource_dispatcher_host_.reset(
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1133 } 1093 }
1134 1094
1135 void BrowserProcessImpl::OnAutoupdateTimer() { 1095 void BrowserProcessImpl::OnAutoupdateTimer() {
1136 if (CanAutorestartForUpdate()) { 1096 if (CanAutorestartForUpdate()) {
1137 DLOG(WARNING) << "Detected update. Restarting browser."; 1097 DLOG(WARNING) << "Detected update. Restarting browser.";
1138 RestartPersistentInstance(); 1098 RestartPersistentInstance();
1139 } 1099 }
1140 } 1100 }
1141 1101
1142 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) 1102 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698