summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-10 22:55:50 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-10 22:55:50 +0000
commitc07d895f10758a47d36ba70cbd9f032ad9e34477 (patch)
tree70b6d3d71230d49dfc49de7e6744650b836f5774
parenta72f5f32c228dd262f7c57546b4cc39c95860c03 (diff)
downloadchromium_src-c07d895f10758a47d36ba70cbd9f032ad9e34477.zip
chromium_src-c07d895f10758a47d36ba70cbd9f032ad9e34477.tar.gz
chromium_src-c07d895f10758a47d36ba70cbd9f032ad9e34477.tar.bz2
Attempt at preventing a crasher.
In some cases TaskManagerResource can still be alive and pointing to a deleted WebContents, not sure how it can happen. Now also listening for TabContent destruction notifications in case we are missing the WebContents one for some reason. BUG=7321 Review URL: http://codereview.chromium.org/21233 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9527 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/task_manager_resource_providers.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/chrome/browser/task_manager_resource_providers.cc b/chrome/browser/task_manager_resource_providers.cc
index ceb48cc..d16085e 100644
--- a/chrome/browser/task_manager_resource_providers.cc
+++ b/chrome/browser/task_manager_resource_providers.cc
@@ -146,6 +146,13 @@ void TaskManagerWebContentsResourceProvider::StartUpdating() {
NotificationService::AllSources());
service->AddObserver(this, NotificationType::WEB_CONTENTS_DISCONNECTED,
NotificationService::AllSources());
+ // WEB_CONTENTS_DISCONNECTED should be enough to know when to remove a
+ // resource. This is an attempt at mitigating a crasher that seem to
+ // indicate a resource is still referencing a deleted WebContents
+ // (http://crbug.com/7321).
+ service->AddObserver(this, NotificationType::TAB_CONTENTS_DESTROYED,
+ NotificationService::AllSources());
+
}
void TaskManagerWebContentsResourceProvider::StopUpdating() {
@@ -160,6 +167,8 @@ void TaskManagerWebContentsResourceProvider::StopUpdating() {
NotificationService::AllSources());
service->RemoveObserver(this, NotificationType::WEB_CONTENTS_DISCONNECTED,
NotificationService::AllSources());
+ service->RemoveObserver(this, NotificationType::TAB_CONTENTS_DESTROYED,
+ NotificationService::AllSources());
// Delete all the resources.
STLDeleteContainerPairSecondPointers(resources_.begin(), resources_.end());
@@ -230,6 +239,12 @@ void TaskManagerWebContentsResourceProvider::Observe(NotificationType type,
Remove(Source<WebContents>(source).ptr());
Add(Source<WebContents>(source).ptr());
break;
+ case NotificationType::TAB_CONTENTS_DESTROYED:
+ // If this DCHECK is triggered, it could explain http://crbug.com/7321.
+ DCHECK(resources_.find(Source<WebContents>(source).ptr()) ==
+ resources_.end()) << "TAB_CONTENTS_DESTROYED with no associated "
+ "WEB_CONTENTS_DISCONNECTED";
+ // Fall through.
case NotificationType::WEB_CONTENTS_DISCONNECTED:
Remove(Source<WebContents>(source).ptr());
break;