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

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

Issue 355032: Fix a bug where we'd leak ResourceMessageFilters and BrowserRenderProcessHosts (Closed)
Patch Set: revert accidental change Created 11 years, 1 month 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/extension_process_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_process_manager.cc
diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc
index 671869142d423e17ffe3ac1b4b1db6131497dce4..06f3d5894c1c5b2e213c7b0633f1c5d7c6dce4cd 100644
--- a/chrome/browser/extensions/extension_process_manager.cc
+++ b/chrome/browser/extensions/extension_process_manager.cc
@@ -44,15 +44,12 @@ ExtensionProcessManager::ExtensionProcessManager(Profile* profile)
NotificationService::AllSources());
registrar_.Add(this, NotificationType::RENDERER_PROCESS_CLOSED,
NotificationService::AllSources());
+ registrar_.Add(this, NotificationType::BROWSER_CLOSED,
+ NotificationService::AllSources());
}
ExtensionProcessManager::~ExtensionProcessManager() {
- // Copy all_hosts_ to avoid iterator invalidation issues.
- ExtensionHostSet to_delete(background_hosts_.begin(),
- background_hosts_.end());
- ExtensionHostSet::iterator iter;
- for (iter = to_delete.begin(); iter != to_delete.end(); ++iter)
- delete *iter;
+ DCHECK(background_hosts_.empty());
}
ExtensionHost* ExtensionProcessManager::CreateView(Extension* extension,
@@ -217,6 +214,16 @@ void ExtensionProcessManager::Observe(NotificationType type,
break;
}
+ case NotificationType::BROWSER_CLOSED: {
+ // Close background hosts when the last browser is closed so that they
+ // have time to shutdown various objects on different threads. Our
+ // destructor is called too late in the shutdown sequence.
+ bool app_closing = *Details<bool>(details).ptr();
+ if (app_closing)
+ CloseBackgroundHosts();
+ break;
+ }
+
default:
NOTREACHED();
}
@@ -232,3 +239,11 @@ void ExtensionProcessManager::OnExtensionHostCreated(ExtensionHost* host,
Source<ExtensionProcessManager>(this),
Details<ExtensionHost>(host));
}
+
+void ExtensionProcessManager::CloseBackgroundHosts() {
+ for (ExtensionHostSet::iterator iter = background_hosts_.begin();
+ iter != background_hosts_.end(); ) {
+ ExtensionHostSet::iterator current = iter++;
+ delete *current;
+ }
+}
« no previous file with comments | « chrome/browser/extensions/extension_process_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698