| 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 BASE_TASK_RUNNER_UTIL_H_ | 5 #ifndef BASE_TASK_RUNNER_UTIL_H_ |
| 6 #define BASE_TASK_RUNNER_UTIL_H_ | 6 #define BASE_TASK_RUNNER_UTIL_H_ |
| 7 | 7 |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 // Bind(&Callback)); | 32 // Bind(&Callback)); |
| 33 template <typename TaskReturnType, typename ReplyArgType> | 33 template <typename TaskReturnType, typename ReplyArgType> |
| 34 bool PostTaskAndReplyWithResult(TaskRunner* task_runner, | 34 bool PostTaskAndReplyWithResult(TaskRunner* task_runner, |
| 35 const tracked_objects::Location& from_here, | 35 const tracked_objects::Location& from_here, |
| 36 Callback<TaskReturnType()> task, | 36 Callback<TaskReturnType()> task, |
| 37 Callback<void(ReplyArgType)> reply) { | 37 Callback<void(ReplyArgType)> reply) { |
| 38 DCHECK(task); | 38 DCHECK(task); |
| 39 DCHECK(reply); | 39 DCHECK(reply); |
| 40 TaskReturnType* result = new TaskReturnType(); | 40 TaskReturnType* result = new TaskReturnType(); |
| 41 return task_runner->PostTaskAndReply( | 41 return task_runner->PostTaskAndReply( |
| 42 from_here, base::Bind(&internal::ReturnAsParamAdapter<TaskReturnType>, | 42 from_here, |
| 43 std::move(task), result), | 43 base::BindOnce(&internal::ReturnAsParamAdapter<TaskReturnType>, |
| 44 base::Bind(&internal::ReplyAdapter<TaskReturnType, ReplyArgType>, | 44 std::move(task), result), |
| 45 std::move(reply), base::Owned(result))); | 45 base::BindOnce(&internal::ReplyAdapter<TaskReturnType, ReplyArgType>, |
| 46 std::move(reply), base::Owned(result))); |
| 46 } | 47 } |
| 47 | 48 |
| 48 } // namespace base | 49 } // namespace base |
| 49 | 50 |
| 50 #endif // BASE_TASK_RUNNER_UTIL_H_ | 51 #endif // BASE_TASK_RUNNER_UTIL_H_ |
| OLD | NEW |