summaryrefslogtreecommitdiffstats
path: root/base/observer_list.h
diff options
context:
space:
mode:
authoroshima <oshima@chromium.org>2015-04-08 15:57:52 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-08 22:58:18 +0000
commit8750dd91b2d1b9e48db1c97ca6cbb059d005991d (patch)
tree9036a0d4640b886f1569b064e6e1f719f8fb48a5 /base/observer_list.h
parent7f46f7bfba383e2082a947b5cb3e4e5bc736389f (diff)
downloadchromium_src-8750dd91b2d1b9e48db1c97ca6cbb059d005991d.zip
chromium_src-8750dd91b2d1b9e48db1c97ca6cbb059d005991d.tar.gz
chromium_src-8750dd91b2d1b9e48db1c97ca6cbb059d005991d.tar.bz2
Make sure observers are not nullptr
I believe there is no good reason to allow nullptr observer, and the bug seems to be hitting this. This is to catch such bug early. BUG=471649 Review URL: https://codereview.chromium.org/1059383003 Cr-Commit-Position: refs/heads/master@{#324299}
Diffstat (limited to 'base/observer_list.h')
-rw-r--r--base/observer_list.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/base/observer_list.h b/base/observer_list.h
index f7b9267..e473b32 100644
--- a/base/observer_list.h
+++ b/base/observer_list.h
@@ -154,6 +154,7 @@ ObserverType* ObserverListBase<ObserverType>::Iterator::GetNext() {
template <class ObserverType>
void ObserverListBase<ObserverType>::AddObserver(ObserverType* obs) {
+ DCHECK(obs);
if (std::find(observers_.begin(), observers_.end(), obs)
!= observers_.end()) {
NOTREACHED() << "Observers can only be added once!";
@@ -164,6 +165,7 @@ void ObserverListBase<ObserverType>::AddObserver(ObserverType* obs) {
template <class ObserverType>
void ObserverListBase<ObserverType>::RemoveObserver(ObserverType* obs) {
+ DCHECK(obs);
typename ListType::iterator it =
std::find(observers_.begin(), observers_.end(), obs);
if (it != observers_.end()) {