Index: base/observer_list_threadsafe.h |
diff --git a/base/observer_list_threadsafe.h b/base/observer_list_threadsafe.h |
index 6154ae9b8dcdec45580eca955e7448d17948b1e1..baee84689bab0b40a0f30faf3f1016ee6004d244 100644 |
--- a/base/observer_list_threadsafe.h |
+++ b/base/observer_list_threadsafe.h |
@@ -191,6 +191,26 @@ class ObserverListThreadSafe |
} |
} |
+ // SyncNotify methods. |
+ // Make a thread-safe callback to each Observer in the list. |
+ // Note, these calls are synchronous. |
Mark Mentovai
2016/03/01 15:21:20
…and happen on thread that calls SyncNotify, which
|
+ template <class Method, class... Params> |
+ void SyncNotify(const tracked_objects::Location& from_here, |
+ Method m, |
+ const Params&... params) { |
+ internal::UnboundMethod<ObserverType, Method, Tuple<Params...>> method( |
+ m, MakeTuple(params...)); |
+ |
+ AutoLock lock(list_lock_); |
+ for (const auto& entry : observer_lists_) { |
+ ObserverListContext* context = entry.second; |
+ typename ObserverList<ObserverType>::Iterator it(&context->list); |
+ ObserverType* obs; |
+ while ((obs = it.GetNext()) != nullptr) |
+ method.Run(obs); |
+ } |
+ } |
+ |
private: |
// See comment above ObserverListThreadSafeTraits' definition. |
friend struct ObserverListThreadSafeTraits<ObserverType>; |