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

Unified Diff: chrome/browser/profiles/profile_destroyer.cc

Issue 9420036: Also delay regular profile destruction... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Merge Goof fix... Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/profiles/profile_destroyer.h ('k') | chrome/browser/profiles/profile_destroyer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profiles/profile_destroyer.cc
diff --git a/chrome/browser/profiles/profile_destroyer.cc b/chrome/browser/profiles/profile_destroyer.cc
index 3e955c7c00f699d45f7050534ee146fb6f88de65..243740543b3e29ab6f2e73b99e1d527506412ca6 100644
--- a/chrome/browser/profiles/profile_destroyer.cc
+++ b/chrome/browser/profiles/profile_destroyer.cc
@@ -13,16 +13,26 @@
#include "content/public/browser/render_process_host.h"
// static
-void ProfileDestroyer::DestroyOffTheRecordProfile(Profile* const profile) {
+void ProfileDestroyer::DestroyProfileWhenAppropriate(Profile* const profile) {
std::vector<content::RenderProcessHost*> hosts;
- if (GetHostsForProfile(profile, &hosts)) {
+ // Testing profiles can simply be deleted directly. Some tests don't setup
+ // RenderProcessHost correctly and don't necessary run on the UI thread
+ // anyway, so we can't use the AllHostIterator.
+ if (profile->AsTestingProfile() == NULL) {
+ GetHostsForProfile(profile, &hosts);
+ if (!profile->IsOffTheRecord() && profile->HasOffTheRecordProfile())
+ GetHostsForProfile(profile->GetOffTheRecordProfile(), &hosts);
+ }
+ if (hosts.empty()) {
+ if (profile->IsOffTheRecord())
+ profile->GetOriginalProfile()->DestroyOffTheRecordProfile();
+ else
+ delete profile;
+ } else {
// The instance will destroy itself once all render process hosts referring
- // to it are properly terminated.
+ // to it and/or it's off the record profile are properly terminated.
scoped_refptr<ProfileDestroyer> profile_destroyer(
new ProfileDestroyer(profile, hosts));
- } else {
- // Safe to destroy now... We're done...
- profile->GetOriginalProfile()->DestroyOffTheRecordProfile();
}
}
@@ -41,7 +51,7 @@ ProfileDestroyer::ProfileDestroyer(
ProfileDestroyer::~ProfileDestroyer() {
// Check again, in case other render hosts were added while we were
// waiting for the previous ones to go away...
- DestroyOffTheRecordProfile(profile_);
+ DestroyProfileWhenAppropriate(profile_);
}
void ProfileDestroyer::Observe(int type,
« no previous file with comments | « chrome/browser/profiles/profile_destroyer.h ('k') | chrome/browser/profiles/profile_destroyer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698