From fd6521901cb7eb76cdd05d330ea6b70dbdcdf7da Mon Sep 17 00:00:00 2001 From: "erikkay@google.com" Date: Fri, 12 Jun 2009 18:39:25 +0000 Subject: Fix object ownership and cleanup issues between ExtensionHost and ExtensionView. This was leading to crashes at shutdown as well as shutdown code not cleaning up properly. BUG=13974 TEST=none Review URL: http://codereview.chromium.org/126064 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18296 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/extensions/extension_host.cc | 3 +++ chrome/browser/extensions/extension_process_manager.cc | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'chrome/browser/extensions') diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index 8ccc9c7..d78d8bc 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -48,6 +48,9 @@ ExtensionHost::~ExtensionHost() { void ExtensionHost::CreateView(Browser* browser) { #if defined(TOOLKIT_VIEWS) view_.reset(new ExtensionView(this, browser)); + // We own |view_|, so don't auto delete when it's removed from the view + // hierarchy. + view_->SetParentOwned(false); #else // TODO(port) NOTREACHED(); diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc index 5f1eada..a511920 100644 --- a/chrome/browser/extensions/extension_process_manager.cc +++ b/chrome/browser/extensions/extension_process_manager.cc @@ -34,9 +34,9 @@ ExtensionProcessManager::ExtensionProcessManager(Profile* profile) } ExtensionProcessManager::~ExtensionProcessManager() { - // Copy background_hosts_ to avoid iterator invalidation issues. - ExtensionHostSet to_delete(background_hosts_.begin(), - background_hosts_.end()); + // Copy all_hosts_ to avoid iterator invalidation issues. + ExtensionHostSet to_delete(all_hosts_.begin(), + all_hosts_.end()); ExtensionHostSet::iterator iter; for (iter = to_delete.begin(); iter != to_delete.end(); ++iter) delete *iter; @@ -45,9 +45,12 @@ ExtensionProcessManager::~ExtensionProcessManager() { ExtensionHost* ExtensionProcessManager::CreateView(Extension* extension, const GURL& url, Browser* browser) { + DCHECK(extension); + DCHECK(browser); ExtensionHost* host = new ExtensionHost(extension, GetSiteInstanceForURL(url), url, this); host->CreateView(browser); + all_hosts_.insert(host); return host; } -- cgit v1.1