diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-19 21:49:04 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-19 21:49:04 +0000 |
commit | a6caf0407dc4873362b81a0b58b72558e5e597aa (patch) | |
tree | 13f7d5c203ef71cb680251ef2aaaf27787593d3b /chrome/browser/external_tab_container.cc | |
parent | 84e5cdd9131a484d650b43f23d915bc72f881003 (diff) | |
download | chromium_src-a6caf0407dc4873362b81a0b58b72558e5e597aa.zip chromium_src-a6caf0407dc4873362b81a0b58b72558e5e597aa.tar.gz chromium_src-a6caf0407dc4873362b81a0b58b72558e5e597aa.tar.bz2 |
The ExternalTabContainer should only invoke unload handlers on the page in its OnDestroy handler. Doing it
in the destructor as well causes DCHECKs to fire in the code path which checks if it is the innermost ExternalTab
for which we received a CloseContents notification and if not post the task back to be handled later. Posting
a task from the destructor causes the DCHECK as it tries to grab a ref on the object.
Part of the fix for http://code.google.com/p/chromium/issues/detail?id=35729
Bug=35279
Review URL: http://codereview.chromium.org/651051
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39498 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/external_tab_container.cc')
-rw-r--r-- | chrome/browser/external_tab_container.cc | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc index 837d006..0abba3b 100644 --- a/chrome/browser/external_tab_container.cc +++ b/chrome/browser/external_tab_container.cc @@ -162,21 +162,6 @@ void ExternalTabContainer::Uninitialize() { registrar_.RemoveAll(); if (tab_contents_) { - waiting_for_unload_event_ = true; - if (Browser::RunUnloadEventsHelper(tab_contents_)) { - // Maintain a local global stack of Externa;TabCotainers waiting for the - // unload event listeners to finish. We need this as we only want to - // handle the CloseContents call from the TabContents when the current - // ExternalTabContainers message loop is active. This ensures that nested - // ExternalTabContainer message loops terminate correctly. - ExternalTabContainer* current_tab = innermost_tab_for_unload_event_; - innermost_tab_for_unload_event_ = this; - MessageLoop::current()->Run(); - innermost_tab_for_unload_event_ = current_tab; - } - - waiting_for_unload_event_ = false; - RenderViewHost* rvh = tab_contents_->render_view_host(); if (rvh && DevToolsManager::GetInstance()) { DevToolsManager::GetInstance()->UnregisterDevToolsClientHostFor(rvh); @@ -662,6 +647,22 @@ LRESULT ExternalTabContainer::OnCreate(LPCREATESTRUCT create_struct) { } void ExternalTabContainer::OnDestroy() { + if (tab_contents_) { + waiting_for_unload_event_ = true; + if (Browser::RunUnloadEventsHelper(tab_contents_)) { + // Maintain a local global stack of Externa;TabCotainers waiting for the + // unload event listeners to finish. We need this as we only want to + // handle the CloseContents call from the TabContents when the current + // ExternalTabContainers message loop is active. This ensures that nested + // ExternalTabContainer message loops terminate correctly. + ExternalTabContainer* current_tab = innermost_tab_for_unload_event_; + innermost_tab_for_unload_event_ = this; + MessageLoop::current()->Run(); + innermost_tab_for_unload_event_ = current_tab; + } + waiting_for_unload_event_ = false; + } + Uninitialize(); WidgetWin::OnDestroy(); if (browser_.get()) { |