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

Unified Diff: base/observer_list_threadsafe.h

Issue 934843002: Implement DeviceMotionEvent API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
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_);

Powered by Google App Engine
This is Rietveld 408576698