diff options
Diffstat (limited to 'chrome/browser/profiles/profile_destroyer.cc')
-rw-r--r-- | chrome/browser/profiles/profile_destroyer.cc | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/chrome/browser/profiles/profile_destroyer.cc b/chrome/browser/profiles/profile_destroyer.cc index 3e955c7..a724432 100644 --- a/chrome/browser/profiles/profile_destroyer.cc +++ b/chrome/browser/profiles/profile_destroyer.cc @@ -13,16 +13,22 @@ #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)) { + 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 +47,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, |