Index: base/observer_list_threadsafe.h |
diff --git a/base/observer_list_threadsafe.h b/base/observer_list_threadsafe.h |
index 1a6633372b8da5ac8589eef0f4dfe79f2ebaef7b..ac531208c0cb8784480ddeb995226a85d45a7d77 100644 |
--- a/base/observer_list_threadsafe.h |
+++ b/base/observer_list_threadsafe.h |
@@ -156,6 +156,21 @@ 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; |
+ ObserverList<ObserverType>* list = &context->list; |
flackr
2015/02/25 23:15:16
nit: should be able to return context->list.HasObs
jonross
2015/03/02 15:18:10
Done.
|
+ |
+ return list->HasObserver(obs); |
+ } |
+ |
// Verifies that the list is currently empty (i.e. there are no observers). |
void AssertEmpty() const { |
base::AutoLock lock(list_lock_); |