summaryrefslogtreecommitdiffstats
path: root/chrome/common/notification_service.cc
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-03 06:18:54 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-03 06:18:54 +0000
commit019c7acc36b8893d060684fb3b5deb6156c92b9e (patch)
treea6dd25f268eeac1547726c43194bffa743c7f25d /chrome/common/notification_service.cc
parent3d50b474d695c47e6eda673694f65b96ec21db4a (diff)
downloadchromium_src-019c7acc36b8893d060684fb3b5deb6156c92b9e.zip
chromium_src-019c7acc36b8893d060684fb3b5deb6156c92b9e.tar.gz
chromium_src-019c7acc36b8893d060684fb3b5deb6156c92b9e.tar.bz2
Add a CHECK when an object tries to remove itself as an observer from NotificationService but no matching entry is found. This is most likely an object being deleted on the wrong thread, and it'll lead to a crash later.
BUG=25354 Review URL: http://codereview.chromium.org/342091 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30801 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/notification_service.cc')
-rw-r--r--chrome/common/notification_service.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/chrome/common/notification_service.cc b/chrome/common/notification_service.cc
index f066b8e..5d6378f 100644
--- a/chrome/common/notification_service.cc
+++ b/chrome/common/notification_service.cc
@@ -60,7 +60,14 @@ void NotificationService::RemoveObserver(NotificationObserver* observer,
NotificationType type,
const NotificationSource& source) {
DCHECK(type.value < NotificationType::NOTIFICATION_TYPE_COUNT);
- DCHECK(HasKey(observers_[type.value], source));
+
+ // This is a very serious bug. An object is most likely being deleted on
+ // the wrong thread, and as a result another thread's NotificationService
+ // has its deleted pointer in its map. A garbge object will be called in the
+ // future.
+ // NOTE: when this check shows crashes, use ChromeThread::DeleteOnIOThread or
+ // other variants as the trait on the object.
+ CHECK(HasKey(observers_[type.value], source));
NotificationObserverList* observer_list =
observers_[type.value][source.map_key()];