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

Unified Diff: chrome/browser/extensions/chrome_process_manager_delegate.cc

Issue 415933003: Remove chrome::NOTIFICATION_PROFILE_DESTROYED usage from src/extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments Created 6 years, 5 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/extensions/chrome_process_manager_delegate.h ('k') | extensions/browser/process_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/chrome_process_manager_delegate.cc
diff --git a/chrome/browser/extensions/chrome_process_manager_delegate.cc b/chrome/browser/extensions/chrome_process_manager_delegate.cc
index 12e0c161d669aad0f829cb830bcb271590cc6249..511e5cdc82ba26b0b43f0b0d78ea303c0a748541 100644
--- a/chrome/browser/extensions/chrome_process_manager_delegate.cc
+++ b/chrome/browser/extensions/chrome_process_manager_delegate.cc
@@ -30,8 +30,9 @@ ChromeProcessManagerDelegate::ChromeProcessManagerDelegate() {
registrar_.Add(this,
chrome::NOTIFICATION_PROFILE_CREATED,
content::NotificationService::AllSources());
- // TODO(jamescook): Move observation of NOTIFICATION_PROFILE_DESTROYED here.
- // http://crbug.com/392658
+ registrar_.Add(this,
+ chrome::NOTIFICATION_PROFILE_DESTROYED,
+ content::NotificationService::AllSources());
}
ChromeProcessManagerDelegate::~ChromeProcessManagerDelegate() {
@@ -85,7 +86,11 @@ void ChromeProcessManagerDelegate::Observe(
OnProfileCreated(profile);
break;
}
-
+ case chrome::NOTIFICATION_PROFILE_DESTROYED: {
+ Profile* profile = content::Source<Profile>(source).ptr();
+ OnProfileDestroyed(profile);
+ break;
+ }
default:
NOTREACHED();
}
@@ -140,4 +145,25 @@ void ChromeProcessManagerDelegate::OnProfileCreated(Profile* profile) {
manager->MaybeCreateStartupBackgroundHosts();
}
+void ChromeProcessManagerDelegate::OnProfileDestroyed(Profile* profile) {
+ // Close background hosts when the last profile is closed so that they
+ // have time to shutdown various objects on different threads. The
+ // ProfileManager destructor is called too late in the shutdown sequence.
+ // http://crbug.com/15708
+ ProcessManager* manager = ExtensionSystem::Get(profile)->process_manager();
+ if (manager)
+ manager->CloseBackgroundHosts();
+
+ // If this profile owns an incognito profile, but it is destroyed before the
+ // incognito profile is destroyed, then close the incognito background hosts
+ // as well. This happens in a few tests. http://crbug.com/138843
+ if (!profile->IsOffTheRecord() && profile->HasOffTheRecordProfile()) {
+ ProcessManager* incognito_manager =
+ ExtensionSystem::Get(profile->GetOffTheRecordProfile())
+ ->process_manager();
+ if (incognito_manager)
+ incognito_manager->CloseBackgroundHosts();
+ }
+}
+
} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/chrome_process_manager_delegate.h ('k') | extensions/browser/process_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698