Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1721)

Unified Diff: base/observer_list.h

Issue 7024037: Fix bug in ObserverListThreadsafe::RemoveObserver (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/observer_list_threadsafe.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « no previous file | base/observer_list_threadsafe.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698