| Index: base/task_runner_util.h
|
| diff --git a/base/task_runner_util.h b/base/task_runner_util.h
|
| index ba8e120c6f4393496130d9bef69a275b28533752..3d39654946555484c1e2ebc23a830a5c78a57393 100644
|
| --- a/base/task_runner_util.h
|
| +++ b/base/task_runner_util.h
|
| @@ -17,21 +17,21 @@ namespace internal {
|
| // Adapts a function that produces a result via a return value to
|
| // one that returns via an output parameter.
|
| template <typename ReturnType>
|
| -void ReturnAsParamAdapter(const Callback<ReturnType(void)>& func,
|
| +void ReturnAsParamAdapter(OnceCallback<ReturnType()> func,
|
| ReturnType* result) {
|
| - *result = func.Run();
|
| + *result = std::move(func).Run();
|
| }
|
|
|
| // Adapts a T* result to a callblack that expects a T.
|
| template <typename TaskReturnType, typename ReplyArgType>
|
| -void ReplyAdapter(const Callback<void(ReplyArgType)>& callback,
|
| +void ReplyAdapter(OnceCallback<void(ReplyArgType)> callback,
|
| TaskReturnType* result) {
|
| // TODO(ajwong): Remove this conditional and add a DCHECK to enforce that
|
| // |reply| must be non-null in PostTaskAndReplyWithResult() below after
|
| // current code that relies on this API softness has been removed.
|
| // http://crbug.com/162712
|
| if (!callback.is_null())
|
| - callback.Run(std::move(*result));
|
| + std::move(callback).Run(std::move(*result));
|
| }
|
|
|
| } // namespace internal
|
| @@ -51,18 +51,33 @@ void ReplyAdapter(const Callback<void(ReplyArgType)>& callback,
|
| // Bind(&DoWorkAndReturn),
|
| // Bind(&Callback));
|
| template <typename TaskReturnType, typename ReplyArgType>
|
| +bool PostTaskAndReplyWithResult(TaskRunner* task_runner,
|
| + const tracked_objects::Location& from_here,
|
| + OnceCallback<TaskReturnType()> task,
|
| + OnceCallback<void(ReplyArgType)> reply) {
|
| + TaskReturnType* result = new TaskReturnType();
|
| + return task_runner->PostTaskAndReply(
|
| + from_here, BindOnce(&internal::ReturnAsParamAdapter<TaskReturnType>,
|
| + std::move(task), result),
|
| + BindOnce(&internal::ReplyAdapter<TaskReturnType, ReplyArgType>,
|
| + std::move(reply), base::Owned(result)));
|
| +}
|
| +
|
| +template <typename TaskReturnType,
|
| + typename ReplyArgType,
|
| + internal::CopyMode task_copy_mode,
|
| + internal::RepeatMode task_repeat_mode,
|
| + internal::CopyMode reply_copy_mode,
|
| + internal::RepeatMode reply_repeat_mode>
|
| bool PostTaskAndReplyWithResult(
|
| TaskRunner* task_runner,
|
| const tracked_objects::Location& from_here,
|
| - const Callback<TaskReturnType(void)>& task,
|
| - const Callback<void(ReplyArgType)>& reply) {
|
| - TaskReturnType* result = new TaskReturnType();
|
| - return task_runner->PostTaskAndReply(
|
| - from_here,
|
| - base::Bind(&internal::ReturnAsParamAdapter<TaskReturnType>, task,
|
| - result),
|
| - base::Bind(&internal::ReplyAdapter<TaskReturnType, ReplyArgType>, reply,
|
| - base::Owned(result)));
|
| + Callback<TaskReturnType(), task_copy_mode, task_repeat_mode> task,
|
| + Callback<void(ReplyArgType), reply_copy_mode, reply_repeat_mode> reply) {
|
| + return PostTaskAndReplyWithResult(
|
| + task_runner, from_here,
|
| + OnceCallback<TaskReturnType()>(std::move(task)),
|
| + OnceCallback<void(ReplyArgType)>(std::move(reply)));
|
| }
|
|
|
| } // namespace base
|
|
|