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

Unified Diff: base/scoped_observer.h

Issue 207613002: Cleanup: Remove NOTIFICATION_EXTENSION_UNLOADED usage in MediaScanManager. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 9 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
===================================================================
--- base/scoped_observer.h (revision 259942)
+++ base/scoped_observer.h (working copy)
@@ -19,8 +19,7 @@
explicit ScopedObserver(Observer* observer) : observer_(observer) {}
~ScopedObserver() {
- for (size_t i = 0; i < sources_.size(); ++i)
- sources_[i]->RemoveObserver(observer_);
+ RemoveAll();
}
// Adds the object passed to the constructor as an observer on |source|.
@@ -35,12 +34,14 @@
source->RemoveObserver(observer_);
}
+ void RemoveAll() {
+ for (size_t i = 0; i < sources_.size(); ++i)
+ sources_[i]->RemoveObserver(observer_);
Nico 2014/03/28 03:34:12 and you don't think it's better to do a sources_.c
Lei Zhang 2014/03/28 03:40:55 Good catch. Thanks.
+ }
+
bool IsObserving(Source* source) const {
- for (size_t i = 0; i < sources_.size(); ++i) {
- if (sources_[i] == source)
- return true;
- }
- return false;
+ return std::find(sources_.begin(), sources_.end(), source) !=
+ sources_.end();
}
private:

Powered by Google App Engine
This is Rietveld 408576698