| Index: base/bind_to_current_loop.h
|
| diff --git a/media/base/bind_to_current_loop.h b/base/bind_to_current_loop.h
|
| similarity index 54%
|
| rename from media/base/bind_to_current_loop.h
|
| rename to base/bind_to_current_loop.h
|
| index cb3e28d4839641f3745684fc7757f87c3aa4cba9..2dd5e07c1e38ec67300edf61002d14e970f23f24 100644
|
| --- a/media/base/bind_to_current_loop.h
|
| +++ b/base/bind_to_current_loop.h
|
| @@ -2,12 +2,12 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef MEDIA_BASE_BIND_TO_CURRENT_LOOP_H_
|
| -#define MEDIA_BASE_BIND_TO_CURRENT_LOOP_H_
|
| +#ifndef BASE_BIND_TO_CURRENT_LOOP_H_
|
| +#define BASE_BIND_TO_CURRENT_LOOP_H_
|
|
|
| #include "base/bind.h"
|
| #include "base/location.h"
|
| -#include "base/message_loop/message_loop_proxy.h"
|
| +#include "base/message_loop/message_loop.h"
|
| #include "base/single_thread_task_runner.h"
|
|
|
| // This is a helper utility for base::Bind()ing callbacks to the current
|
| @@ -17,27 +17,31 @@
|
| //
|
| // Typical usage: request to be called back on the current thread:
|
| // other->StartAsyncProcessAndCallMeBack(
|
| -// media::BindToCurrentLoop(base::Bind(&MyClass::MyMethod, this)));
|
| +// base::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.
|
| +// Note that like base::Bind(), base::BindToCurrentLoop() can't bind
|
| +// non-constant references, and that *unlike* base::Bind(),
|
| +// base::BindToCurrentLoop() makes copies of its arguments, and thus can't be
|
| +// used with arrays.
|
|
|
| -namespace media {
|
| +namespace base {
|
| +
|
| +namespace internal {
|
|
|
| // 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); }
|
| +PassedWrapper<scoped_ptr<T, R> > TrampolineForward(scoped_ptr<T, R>& p) {
|
| + return Passed(&p);
|
| +}
|
|
|
| template <typename T>
|
| -base::internal::PassedWrapper<ScopedVector<T> > TrampolineForward(
|
| - ScopedVector<T>& p) { return base::Passed(&p); }
|
| +PassedWrapper<ScopedVector<T> > TrampolineForward(ScopedVector<T>& p) {
|
| + return Passed(&p);
|
| +}
|
|
|
| // First, tell the compiler TrampolineHelper is a struct template with one
|
| // type parameter. Then define specializations where the type is a function
|
| @@ -46,24 +50,22 @@ 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) {
|
| + static void Run(const scoped_refptr<SingleThreadTaskRunner>& task_runner,
|
| + const Callback<void(Args...)>& cb,
|
| + Args... args) {
|
| task_runner->PostTask(FROM_HERE,
|
| - base::Bind(cb, TrampolineForward(args)...));
|
| + 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::MessageLoopProxy::current(), cb);
|
| +static Callback<T> BindToCurrentLoop(const Callback<T>& cb) {
|
| + return Bind(&internal::TrampolineHelper<T>::Run,
|
| + MessageLoop::current()->task_runner(), cb);
|
| }
|
|
|
| -} // namespace media
|
| +} // namespace base
|
|
|
| -#endif // MEDIA_BASE_BIND_TO_CURRENT_LOOP_H_
|
| +#endif // BASE_BIND_TO_CURRENT_LOOP_H_
|
|
|