Index: chrome/browser/ui/browser.cc |
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc |
index f438efd2273adeda29b552ea373597101c6020ed..ff3ac9cf1721a0c23b8635252150c4c8866a5453 100644 |
--- a/chrome/browser/ui/browser.cc |
+++ b/chrome/browser/ui/browser.cc |
@@ -65,6 +65,7 @@ |
#include "chrome/browser/prefs/incognito_mode_prefs.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/profiles/profile_destroyer.h" |
+#include "chrome/browser/profiles/profile_manager.h" |
#include "chrome/browser/profiles/profile_metrics.h" |
#include "chrome/browser/repost_form_warning_controller.h" |
#include "chrome/browser/search/search.h" |
@@ -511,9 +512,17 @@ Browser::~Browser() { |
if (profile_->IsOffTheRecord() && |
!BrowserList::IsOffTheRecordSessionActiveForProfile(profile_)) { |
- // An incognito profile is no longer needed, this indirectly frees |
- // its cache and cookies once it gets destroyed at the appropriate time. |
- ProfileDestroyer::DestroyProfileWhenAppropriate(profile_); |
+ if (profile_->IsGuestSession()) { |
+ // The profile's BCKS's need to shutdown after Views shuts down. |
+ base::MessageLoop::current()->PostTask( |
+ FROM_HERE, base::Bind(&ProfileManager::DeleteProfile, |
+ base::Unretained(g_browser_process->profile_manager()), |
+ profile_)); |
+ } else { |
+ // An incognito profile is no longer needed, this indirectly frees |
+ // its cache and cookies once it gets destroyed at the appropriate time. |
+ ProfileDestroyer::DestroyProfileWhenAppropriate(profile_); |
+ } |
} |
// There may be pending file dialogs, we need to tell them that we've gone |