| OLD | NEW | 
|   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_ | 
| OLD | NEW |