| Index: chrome/browser/sync_file_system/drive_backend/callback_helper.h
|
| diff --git a/chrome/browser/sync_file_system/drive_backend/callback_helper.h b/chrome/browser/sync_file_system/drive_backend/callback_helper.h
|
| index 2dd97964a52d9aea78af4fac4b015f44a597649a..822ba65ffe07e0d54a02610334d51cf4b304f5d9 100644
|
| --- a/chrome/browser/sync_file_system/drive_backend/callback_helper.h
|
| +++ b/chrome/browser/sync_file_system/drive_backend/callback_helper.h
|
| @@ -1,3 +1,8 @@
|
| +// This file was GENERATED by command:
|
| +// pump.py callback_helper.h.pump
|
| +// DO NOT EDIT BY HAND!!!
|
| +
|
| +
|
| // Copyright 2014 The Chromium Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
| @@ -7,7 +12,10 @@
|
|
|
| #include "base/bind.h"
|
| #include "base/location.h"
|
| -#include "base/message_loop/message_loop_proxy.h"
|
| +#include "base/logging.h"
|
| +#include "base/thread_task_runner_handle.h"
|
| +
|
| +// TODO(tzik): Merge this file to media/base/bind_to_current_loop.h.
|
|
|
| namespace sync_file_system {
|
| namespace drive_backend {
|
| @@ -30,45 +38,118 @@ RebindForward(T& t) {
|
| return t;
|
| }
|
|
|
| -template <typename T>
|
| -void RelayToTaskRunner1(base::SequencedTaskRunner* task_runner,
|
| - const tracked_objects::Location& from_here,
|
| - const base::Callback<void(T)>& callback,
|
| - T arg) {
|
| - task_runner->PostTask(
|
| - from_here, base::Bind(callback, RebindForward(arg)));
|
| -}
|
| +template <typename>
|
| +struct RelayToTaskRunnerHelper;
|
|
|
| -template <typename T1, typename T2>
|
| -void RelayToTaskRunner2(base::SequencedTaskRunner* task_runner,
|
| - const tracked_objects::Location& from_here,
|
| - const base::Callback<void(T1, T2)>& callback,
|
| - T1 arg1,
|
| - T2 arg2) {
|
| - task_runner->PostTask(
|
| - from_here, base::Bind(callback,
|
| - RebindForward(arg1),
|
| - RebindForward(arg2)));
|
| -}
|
| +template <>
|
| +struct RelayToTaskRunnerHelper<void()> {
|
| + static void Run(base::TaskRunner* task_runner,
|
| + const tracked_objects::Location& from_here,
|
| + const base::Callback<void()>& callback) {
|
| + task_runner->PostTask(from_here, base::Bind(callback));
|
| + }
|
| +};
|
| +
|
| +template <typename A1>
|
| +struct RelayToTaskRunnerHelper<void(A1)> {
|
| + static void Run(base::TaskRunner* task_runner,
|
| + const tracked_objects::Location& from_here,
|
| + const base::Callback<void(A1)>& callback, A1 a1) {
|
| + task_runner->PostTask(from_here, base::Bind(callback, RebindForward(a1)));
|
| + }
|
| +};
|
| +
|
| +template <typename A1, typename A2>
|
| +struct RelayToTaskRunnerHelper<void(A1, A2)> {
|
| + static void Run(base::TaskRunner* task_runner,
|
| + const tracked_objects::Location& from_here,
|
| + const base::Callback<void(A1, A2)>& callback, A1 a1, A2 a2) {
|
| + task_runner->PostTask(from_here, base::Bind(callback, RebindForward(a1),
|
| + RebindForward(a2)));
|
| + }
|
| +};
|
| +
|
| +template <typename A1, typename A2, typename A3>
|
| +struct RelayToTaskRunnerHelper<void(A1, A2, A3)> {
|
| + static void Run(base::TaskRunner* task_runner,
|
| + const tracked_objects::Location& from_here,
|
| + const base::Callback<void(A1, A2, A3)>& callback, A1 a1,
|
| + A2 a2, A3 a3) {
|
| + task_runner->PostTask(from_here, base::Bind(callback, RebindForward(a1),
|
| + RebindForward(a2), RebindForward(a3)));
|
| + }
|
| +};
|
| +
|
| +template <typename A1, typename A2, typename A3, typename A4>
|
| +struct RelayToTaskRunnerHelper<void(A1, A2, A3, A4)> {
|
| + static void Run(base::TaskRunner* task_runner,
|
| + const tracked_objects::Location& from_here,
|
| + const base::Callback<void(A1, A2, A3, A4)>& callback, A1 a1,
|
| + A2 a2, A3 a3, A4 a4) {
|
| + task_runner->PostTask(from_here, base::Bind(callback, RebindForward(a1),
|
| + RebindForward(a2), RebindForward(a3), RebindForward(a4)));
|
| + }
|
| +};
|
| +
|
| +template <typename A1, typename A2, typename A3, typename A4, typename A5>
|
| +struct RelayToTaskRunnerHelper<void(A1, A2, A3, A4, A5)> {
|
| + static void Run(base::TaskRunner* task_runner,
|
| + const tracked_objects::Location& from_here,
|
| + const base::Callback<void(A1, A2, A3, A4, A5)>& callback,
|
| + A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) {
|
| + task_runner->PostTask(from_here, base::Bind(callback, RebindForward(a1),
|
| + RebindForward(a2), RebindForward(a3), RebindForward(a4),
|
| + RebindForward(a5)));
|
| + }
|
| +};
|
| +
|
| +template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
| + typename A6>
|
| +struct RelayToTaskRunnerHelper<void(A1, A2, A3, A4, A5, A6)> {
|
| + static void Run(base::TaskRunner* task_runner,
|
| + const tracked_objects::Location& from_here,
|
| + const base::Callback<void(A1, A2, A3, A4, A5, A6)>& callback,
|
| + A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) {
|
| + task_runner->PostTask(from_here, base::Bind(callback, RebindForward(a1),
|
| + RebindForward(a2), RebindForward(a3), RebindForward(a4),
|
| + RebindForward(a5), RebindForward(a6)));
|
| + }
|
| +};
|
| +
|
| +template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
| + typename A6, typename A7>
|
| +struct RelayToTaskRunnerHelper<void(A1, A2, A3, A4, A5, A6, A7)> {
|
| + static void Run(base::TaskRunner* task_runner,
|
| + const tracked_objects::Location& from_here,
|
| + const base::Callback<void(A1, A2, A3, A4, A5, A6,
|
| + A7)>& callback, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
|
| + A7 a7) {
|
| + task_runner->PostTask(from_here, base::Bind(callback, RebindForward(a1),
|
| + RebindForward(a2), RebindForward(a3), RebindForward(a4),
|
| + RebindForward(a5), RebindForward(a6), RebindForward(a7)));
|
| + }
|
| +};
|
|
|
| } // namespace internal
|
|
|
| template <typename T>
|
| -base::Callback<void(T)> CreateRelayedCallback(
|
| - const base::Callback<void(T)>& callback) {
|
| - return base::Bind(&internal::RelayToTaskRunner1<T>,
|
| - base::MessageLoopProxy::current(),
|
| - FROM_HERE,
|
| +base::Callback<T> RelayCallbackToTaskRunner(
|
| + base::TaskRunner* task_runner,
|
| + const tracked_objects::Location& from_here,
|
| + const base::Callback<T>& callback) {
|
| + DCHECK(task_runner->RunsTasksOnCurrentThread());
|
| + return base::Bind(&internal::RelayToTaskRunnerHelper<T>::Run,
|
| + make_scoped_refptr(task_runner), from_here,
|
| callback);
|
| }
|
|
|
| -template <typename T1, typename T2>
|
| -base::Callback<void(T1, T2)> CreateRelayedCallback(
|
| - const base::Callback<void(T1, T2)>& callback) {
|
| - return base::Bind(&internal::RelayToTaskRunner2<T1, T2>,
|
| - base::MessageLoopProxy::current(),
|
| - FROM_HERE,
|
| - callback);
|
| +template <typename T>
|
| +base::Callback<T> RelayCallbackToCurrentThread(
|
| + const tracked_objects::Location& from_here,
|
| + const base::Callback<T>& callback) {
|
| + return RelayCallbackToTaskRunner(
|
| + base::ThreadTaskRunnerHandle::Get(),
|
| + from_here, callback);
|
| }
|
|
|
| } // namespace drive_backend
|
|
|