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

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: Update Thread Safety 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..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_);
« no previous file with comments | « no previous file | chromeos/accelerometer/accelerometer_reader.h » ('j') | chromeos/accelerometer/accelerometer_reader.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698