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

Unified Diff: media/base/bind_to_loop.h.pump

Issue 27420004: Remove threading from RendererGpuVideoAcceleratorFactories (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dthread
Patch Set: f77fc38a Unittest fixes. Created 7 years, 2 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: media/base/bind_to_loop.h.pump
diff --git a/media/base/bind_to_loop.h.pump b/media/base/bind_to_loop.h.pump
index 8490413eb1cc333cb2279712014f825c7487779c..eea6032d9bceccf1d40300d025bb99a680c1ab6f 100644
--- a/media/base/bind_to_loop.h.pump
+++ b/media/base/bind_to_loop.h.pump
@@ -18,6 +18,7 @@ $var MAX_ARITY = 7
#include "base/bind.h"
#include "base/location.h"
#include "base/message_loop/message_loop_proxy.h"
+#include "base/synchronization/waitable_event.h"
// This is a helper utility for base::Bind()ing callbacks on to particular
// MessageLoops. A typical use is when |a| (of class |A|) wants to hand a
@@ -55,6 +56,10 @@ base::internal::PassedWrapper<ScopedVector<T> > TrampolineForward(
template <typename T> struct TrampolineHelper;
+// Caller helper to call a base::Closure synchronously
+void TrampolineSyncCaller(const base::Closure& closure,
+ base::WaitableEvent* waiter);
+
$range ARITY 0..MAX_ARITY
$for ARITY [[
$range ARG 1..ARITY
@@ -71,6 +76,24 @@ $for ARG , [[A$(ARG) a$(ARG)]]
$if ARITY != 0 [[, ]]
$for ARG , [[internal::TrampolineForward(a$(ARG))]]));
}
+ static void RunSync(
+ const scoped_refptr<base::MessageLoopProxy>& loop,
+ const base::Callback<void($for ARG , [[A$(ARG)]])>& cb
+$if ARITY != 0 [[, ]]
+$for ARG , [[A$(ARG) a$(ARG)]]
+) {
+ DCHECK(!loop->BelongsToCurrentThread());
+ base::WaitableEvent waiter(false, false);
+ loop->PostTask(
+ FROM_HERE,
+ base::Bind(
+ &TrampolineSyncCaller,
+ base::Bind(cb
+$if ARITY != 0 [[, ]]
+$for ARG , [[internal::TrampolineForward(a$(ARG))]]),
+ &waiter));
+ waiter.Wait();
+ }
};
@@ -86,6 +109,13 @@ static base::Callback<T> BindToLoop(
}
template<typename T>
+static base::Callback<T> BindToLoopSync(
+ const scoped_refptr<base::MessageLoopProxy>& loop,
+ const base::Callback<T>& cb) {
+ return base::Bind(&internal::TrampolineHelper<T>::RunSync, loop, cb);
+}
+
+template<typename T>
static base::Callback<T> BindToCurrentLoop(
const base::Callback<T>& cb) {
return BindToLoop(base::MessageLoopProxy::current(), cb);

Powered by Google App Engine
This is Rietveld 408576698