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

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: Created 8 years, 10 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
===================================================================
--- chrome/browser/profiles/profile_destroyer.cc (revision 122340)
+++ chrome/browser/profiles/profile_destroyer.cc (working copy)
@@ -8,21 +8,33 @@
#include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"
#include "chrome/browser/profiles/profile.h"
+#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h"
#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)) {
+ // Some tests try to destroy their profile on other threads than the UI.
sky 2012/02/17 16:53:09 I hate to have to change around code like this for
MAD 2012/02/17 17:06:09 Yeah, I agree with you... I was lazy... I was scar
+ // Ignore those, since we can't enumerate the hosts unless we're on the UI
+ // thread.
+ if (content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
+ 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 +53,7 @@
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