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

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: rebase, add error console Created 6 years, 8 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 | chrome/browser/extensions/api/media_galleries_private/gallery_watch_state_tracker.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/scoped_observer.h
===================================================================
--- base/scoped_observer.h (revision 260931)
+++ 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,15 @@
source->RemoveObserver(observer_);
}
+ void RemoveAll() {
+ for (size_t i = 0; i < sources_.size(); ++i)
+ sources_[i]->RemoveObserver(observer_);
+ sources_.clear();
+ }
+
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:
« no previous file with comments | « no previous file | chrome/browser/extensions/api/media_galleries_private/gallery_watch_state_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698