diff options
Diffstat (limited to 'base/scoped_observer.h')
-rw-r--r-- | base/scoped_observer.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/base/scoped_observer.h b/base/scoped_observer.h index fdc9de3..eae63672 100644 --- a/base/scoped_observer.h +++ b/base/scoped_observer.h @@ -29,12 +29,20 @@ class ScopedObserver { source->AddObserver(observer_); } - // Removse the object passed to the constructor as an observer from |source|. + // 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)); source->RemoveObserver(observer_); } + bool IsObserving(Source* source) const { + for (size_t i = 0; i < sources_.size(); ++i) { + if (sources_[i] == source) + return true; + } + return false; + } + private: Observer* observer_; |