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

Unified Diff: base/observer_list_threadsafe.h

Issue 1749073002: Do V8 GC ASAP if system memory is pressured (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 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>;

Powered by Google App Engine
This is Rietveld 408576698