Index: base/scoped_observer.h |
diff --git a/base/scoped_observer.h b/base/scoped_observer.h |
index 3754ed57e1d27c3b98f59b8c41262c7d80de9507..5b0d53353bab913125335acc0d925987c60b7dae 100644 |
--- a/base/scoped_observer.h |
+++ b/base/scoped_observer.h |
@@ -9,6 +9,7 @@ |
#include <vector> |
#include "base/basictypes.h" |
+#include "base/logging.h" |
// ScopedObserver is used to keep track of the set of sources an object has |
// attached itself to as an observer. When ScopedObserver is destroyed it |
@@ -30,7 +31,9 @@ class ScopedObserver { |
// Remove the object passed to the constructor as an observer from |source|. |
void Remove(Source* source) { |
- sources_.erase(std::find(sources_.begin(), sources_.end(), source)); |
+ auto it = std::find(sources_.begin(), sources_.end(), source); |
+ DCHECK(it != sources_.end()); |
+ sources_.erase(it); |
source->RemoveObserver(observer_); |
} |