Index: base/observer_list.h |
diff --git a/base/observer_list.h b/base/observer_list.h |
index ca4b3fdb3fc90266be58a3aafa9a4eacd2b306ad..0ce750519ae52ddcd2b1592dd50c86ab8f4d65bb 100644 |
--- a/base/observer_list.h |
+++ b/base/observer_list.h |
@@ -111,14 +111,18 @@ class ObserverListBase { |
explicit ObserverListBase(NotificationType type) |
: notify_depth_(0), type_(type) {} |
- // Add an observer to the list. |
+ // Add an observer to the list. An observer should not be added to |
+ // the same list more than once. |
void AddObserver(ObserverType* obs) { |
- DCHECK(find(observers_.begin(), observers_.end(), obs) == observers_.end()) |
- << "Observers can only be added once!"; |
+ if (std::find(observers_.begin(), observers_.end(), obs) |
+ != observers_.end()) { |
+ NOTREACHED() << "Observers can only be added once!"; |
+ return; |
+ } |
observers_.push_back(obs); |
} |
- // Remove an observer from the list. |
+ // Remove an observer from the list if it is in the list. |
void RemoveObserver(ObserverType* obs) { |
typename ListType::iterator it = |
std::find(observers_.begin(), observers_.end(), obs); |