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

Unified Diff: base/scoped_observer.h

Issue 676083003: Listen to Off The Record profiles in ContentSettingsHandler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Improved patch to fix crash from previous patch. 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
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());
Lei Zhang 2014/10/24 19:57:29 Looking at base/observer_list_unittest.cc, it shou
scheib 2014/10/24 21:46:19 True, but I think errors such as the previous one
+ sources_.erase(it);
source->RemoveObserver(observer_);
}

Powered by Google App Engine
This is Rietveld 408576698