Index: base/observer_list_threadsafe.h |
diff --git a/base/observer_list_threadsafe.h b/base/observer_list_threadsafe.h |
index 1a6633372b8da5ac8589eef0f4dfe79f2ebaef7b..c0e18facbbf83e7b8fb0d936490b26632952512f 100644 |
--- a/base/observer_list_threadsafe.h |
+++ b/base/observer_list_threadsafe.h |
@@ -156,6 +156,19 @@ class ObserverListThreadSafe |
delete context; |
} |
+ // Returns true if the observer is in the list for the current thread. |
+ // Otherwise returns false. |
+ bool HasObserver(ObserverType* obs) { |
+ base::PlatformThreadId thread_id = base::PlatformThread::CurrentId(); |
+ base::AutoLock lock(list_lock_); |
+ typename ObserversListMap::iterator it = observer_lists_.find(thread_id); |
+ if (it == observer_lists_.end()) |
+ return false; |
+ |
+ ObserverListContext* context = it->second; |
+ return context->list.HasObserver(obs); |
+ } |
+ |
// Verifies that the list is currently empty (i.e. there are no observers). |
void AssertEmpty() const { |
base::AutoLock lock(list_lock_); |