diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-31 22:54:21 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-31 22:54:21 +0000 |
commit | f02640dd4aaf6495eb03b77702cbf813df9001f2 (patch) | |
tree | 6d203b2fcb8c9b2edd7ddfb07ef1a3fe03dbf463 /base | |
parent | 1ce00dca724d613cabe9bc5cc2a42946c4b7db07 (diff) | |
download | chromium_src-f02640dd4aaf6495eb03b77702cbf813df9001f2.zip chromium_src-f02640dd4aaf6495eb03b77702cbf813df9001f2.tar.gz chromium_src-f02640dd4aaf6495eb03b77702cbf813df9001f2.tar.bz2 |
Allow NOTIFY_EXISTING_ONLY in ObserverListThreadSafe. Switch NCN to using it.
TEST=none
Review URL: http://codereview.chromium.org/3235013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58089 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/observer_list_threadsafe.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/base/observer_list_threadsafe.h b/base/observer_list_threadsafe.h index f781c03..94c55a6 100644 --- a/base/observer_list_threadsafe.h +++ b/base/observer_list_threadsafe.h @@ -53,7 +53,12 @@ template <class ObserverType> class ObserverListThreadSafe : public base::RefCountedThreadSafe<ObserverListThreadSafe<ObserverType> > { public: - ObserverListThreadSafe() {} + typedef typename ObserverList<ObserverType>::NotificationType + NotificationType; + + ObserverListThreadSafe() + : type_(ObserverListBase<ObserverType>::NOTIFY_ALL) {} + explicit ObserverListThreadSafe(NotificationType type) : type_(type) {} ~ObserverListThreadSafe() { typename ObserversListMap::const_iterator it; @@ -74,7 +79,7 @@ class ObserverListThreadSafe { AutoLock lock(list_lock_); if (observer_lists_.find(loop) == observer_lists_.end()) - observer_lists_[loop] = new ObserverList<ObserverType>(); + observer_lists_[loop] = new ObserverList<ObserverType>(type_); list = observer_lists_[loop]; } list->AddObserver(obs); @@ -195,6 +200,7 @@ class ObserverListThreadSafe // These are marked mutable to facilitate having NotifyAll be const. Lock list_lock_; // Protects the observer_lists_. ObserversListMap observer_lists_; + const NotificationType type_; DISALLOW_COPY_AND_ASSIGN(ObserverListThreadSafe); }; |