Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1002)

Side by Side Diff: base/post_task_and_reply_with_result_internal.h

Issue 2637843002: Migrate base::TaskRunner from Closure to OnceClosure (Closed)
Patch Set: rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/message_loop/message_loop_task_runner.cc ('k') | base/sequenced_task_runner.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_POST_TASK_AND_REPLY_WITH_RESULT_INTERNAL_H_ 5 #ifndef BASE_POST_TASK_AND_REPLY_WITH_RESULT_INTERNAL_H_
6 #define BASE_POST_TASK_AND_REPLY_WITH_RESULT_INTERNAL_H_ 6 #define BASE_POST_TASK_AND_REPLY_WITH_RESULT_INTERNAL_H_
7 7
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 11
12 namespace base { 12 namespace base {
13 13
14 namespace internal { 14 namespace internal {
15 15
16 // Adapts a function that produces a result via a return value to 16 // Adapts a function that produces a result via a return value to
17 // one that returns via an output parameter. 17 // one that returns via an output parameter.
18 template <typename ReturnType> 18 template <typename ReturnType>
19 void ReturnAsParamAdapter(const Callback<ReturnType(void)>& func, 19 void ReturnAsParamAdapter(OnceCallback<ReturnType()> func, ReturnType* result) {
20 ReturnType* result) { 20 *result = std::move(func).Run();
21 *result = func.Run();
22 } 21 }
23 22
24 // Adapts a T* result to a callblack that expects a T. 23 // Adapts a T* result to a callblack that expects a T.
25 template <typename TaskReturnType, typename ReplyArgType> 24 template <typename TaskReturnType, typename ReplyArgType>
26 void ReplyAdapter(const Callback<void(ReplyArgType)>& callback, 25 void ReplyAdapter(OnceCallback<void(ReplyArgType)> callback,
27 TaskReturnType* result) { 26 TaskReturnType* result) {
28 callback.Run(std::move(*result)); 27 std::move(callback).Run(std::move(*result));
29 } 28 }
30 29
31 } // namespace internal 30 } // namespace internal
32 31
33 } // namespace base 32 } // namespace base
34 33
35 #endif // BASE_POST_TASK_AND_REPLY_WITH_RESULT_INTERNAL_H_ 34 #endif // BASE_POST_TASK_AND_REPLY_WITH_RESULT_INTERNAL_H_
OLDNEW
« no previous file with comments | « base/message_loop/message_loop_task_runner.cc ('k') | base/sequenced_task_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698