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

Unified Diff: media/base/bind_to_current_loop.h

Issue 1553593002: Add base::BindToTaskRunner and BindToCurrentThread (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 5 years 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
« no previous file with comments | « base/bind_to_task_runner_unittest.cc ('k') | media/base/bind_to_current_loop_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/bind_to_current_loop.h
diff --git a/media/base/bind_to_current_loop.h b/media/base/bind_to_current_loop.h
index da568ed6ac55caa56a4ce8677b44e39735e8cf11..835cb7ad9849c9d63995f00878059d75cde0dcd1 100644
--- a/media/base/bind_to_current_loop.h
+++ b/media/base/bind_to_current_loop.h
@@ -5,64 +5,15 @@
#ifndef MEDIA_BASE_BIND_TO_CURRENT_LOOP_H_
#define MEDIA_BASE_BIND_TO_CURRENT_LOOP_H_
-#include "base/bind.h"
-#include "base/location.h"
-#include "base/memory/scoped_vector.h"
-#include "base/single_thread_task_runner.h"
-#include "base/thread_task_runner_handle.h"
+#include "base/bind_to_task_runner.h"
-// This is a helper utility for base::Bind()ing callbacks to the current
-// MessageLoop. The typical use is when |a| (of class |A|) wants to hand a
-// callback such as base::Bind(&A::AMethod, a) to |b|, but needs to ensure that
-// when |b| executes the callback, it does so on |a|'s current MessageLoop.
-//
-// Typical usage: request to be called back on the current thread:
-// other->StartAsyncProcessAndCallMeBack(
-// media::BindToCurrentLoop(base::Bind(&MyClass::MyMethod, this)));
-//
-// Note that like base::Bind(), BindToCurrentLoop() can't bind non-constant
-// references, and that *unlike* base::Bind(), BindToCurrentLoop() makes copies
-// of its arguments, and thus can't be used with arrays.
+// DEPRECATED. New code should use base::BindToCurrentThread() instead.
namespace media {
-// Mimic base::internal::CallbackForward, replacing p.Pass() with
-// base::Passed(&p) to account for the extra layer of indirection.
-namespace internal {
template <typename T>
-T& TrampolineForward(T& t) { return t; }
-
-template <typename T, typename R>
-base::internal::PassedWrapper<scoped_ptr<T, R> > TrampolineForward(
- scoped_ptr<T, R>& p) { return base::Passed(&p); }
-
-template <typename T>
-base::internal::PassedWrapper<ScopedVector<T> > TrampolineForward(
- ScopedVector<T>& p) { return base::Passed(&p); }
-
-// First, tell the compiler TrampolineHelper is a struct template with one
-// type parameter. Then define specializations where the type is a function
-// returning void and taking zero or more arguments.
-template <typename Sig> struct TrampolineHelper;
-
-template <typename... Args>
-struct TrampolineHelper<void(Args...)> {
- static void Run(
- const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
- const base::Callback<void(Args...)>& cb,
- Args... args) {
- task_runner->PostTask(FROM_HERE,
- base::Bind(cb, TrampolineForward(args)...));
- }
-};
-
-} // namespace internal
-
-template<typename T>
-static base::Callback<T> BindToCurrentLoop(
- const base::Callback<T>& cb) {
- return base::Bind(&internal::TrampolineHelper<T>::Run,
- base::ThreadTaskRunnerHandle::Get(), cb);
+base::Callback<T> BindToCurrentLoop(const base::Callback<T>& cb) {
+ return base::BindToCurrentThread(cb);
}
} // namespace media
« no previous file with comments | « base/bind_to_task_runner_unittest.cc ('k') | media/base/bind_to_current_loop_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698