| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef GOOGLE_APIS_DRIVE_TASK_UTIL_H_ | 5 #ifndef GOOGLE_APIS_DRIVE_TASK_UTIL_H_ |
| 6 #define GOOGLE_APIS_DRIVE_TASK_UTIL_H_ | 6 #define GOOGLE_APIS_DRIVE_TASK_UTIL_H_ |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/thread_task_runner_handle.h" |
| 10 | 10 |
| 11 namespace google_apis { | 11 namespace google_apis { |
| 12 | 12 |
| 13 // Runs the task with the task runner. | 13 // Runs the task with the task runner. |
| 14 void RunTaskWithTaskRunner(scoped_refptr<base::TaskRunner> task_runner, | 14 void RunTaskWithTaskRunner(scoped_refptr<base::TaskRunner> task_runner, |
| 15 const base::Closure& task); | 15 const base::Closure& task); |
| 16 | 16 |
| 17 namespace internal { | 17 namespace internal { |
| 18 | 18 |
| 19 // Implementation of the composed callback, whose signature is |Sig|. | 19 // Implementation of the composed callback, whose signature is |Sig|. |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 DCHECK(!callback.is_null()); | 109 DCHECK(!callback.is_null()); |
| 110 return base::Bind( | 110 return base::Bind( |
| 111 &internal::ComposedCallback<typename CallbackType::RunType>::Run, | 111 &internal::ComposedCallback<typename CallbackType::RunType>::Run, |
| 112 runner, callback); | 112 runner, callback); |
| 113 } | 113 } |
| 114 | 114 |
| 115 // Returns callback which runs the given |callback| on the current thread. | 115 // Returns callback which runs the given |callback| on the current thread. |
| 116 template<typename CallbackType> | 116 template<typename CallbackType> |
| 117 CallbackType CreateRelayCallback(const CallbackType& callback) { | 117 CallbackType CreateRelayCallback(const CallbackType& callback) { |
| 118 return CreateComposedCallback( | 118 return CreateComposedCallback( |
| 119 base::Bind(&RunTaskWithTaskRunner, base::MessageLoopProxy::current()), | 119 base::Bind(&RunTaskWithTaskRunner, base::ThreadTaskRunnerHandle::Get()), |
| 120 callback); | 120 callback); |
| 121 } | 121 } |
| 122 | 122 |
| 123 } // namespace google_apis | 123 } // namespace google_apis |
| 124 | 124 |
| 125 #endif // GOOGLE_APIS_DRIVE_TASK_UTIL_H_ | 125 #endif // GOOGLE_APIS_DRIVE_TASK_UTIL_H_ |
| OLD | NEW |