Make sure locally stored site data is deleted after DB and WebKit threads are gone.
BUG=32719
TEST=none
Review URL: http://codereview.chromium.org/564050
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38048 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index f58357b..f96fd10 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -164,16 +164,12 @@
// SaveFileManager and SessionService.
file_thread_.reset();
- // At this point, no render process exist, so it's safe to access local
- // state data such as cookies, database, or local storage.
- if (clear_local_state_on_exit)
- ClearLocalState(profile_path);
-
// With the file_thread_ flushed, we can release any icon resources.
icon_manager_.reset();
// Need to destroy ResourceDispatcherHost before PluginService and
- // SafeBrowsingService, since it caches a pointer to it.
+ // SafeBrowsingService, since it caches a pointer to it. This also
+ // causes the webkit thread to terminate.
resource_dispatcher_host_.reset();
// Wait for the pending print jobs to finish.
@@ -183,6 +179,16 @@
// Now OK to destroy NotificationService.
main_notification_service_.reset();
+ // Prior to clearing local state, we want to complete tasks pending
+ // on the db thread too.
+ db_thread_.reset();
+
+ // At this point, no render process exist and the file, io, db, and
+ // webkit threads in this process have all terminated, so it's safe
+ // to access local state data such as cookies, database, or local storage.
+ if (clear_local_state_on_exit)
+ ClearLocalState(profile_path);
+
g_browser_process = NULL;
}