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

Unified Diff: base/scoped_observer.h

Issue 669813003: Update from chromium https://crrev.com/301725/ (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 2 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 | « base/run_loop.cc ('k') | base/test/trace_to_file.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_);
}
« no previous file with comments | « base/run_loop.cc ('k') | base/test/trace_to_file.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698