| OLD | NEW | 
|   1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |   1 // Copyright (c) 2011 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_CALLBACK_FORWARD_H_ |   5 #ifndef BASE_CALLBACK_FORWARD_H_ | 
|   6 #define BASE_CALLBACK_FORWARD_H_ |   6 #define BASE_CALLBACK_FORWARD_H_ | 
|   7  |   7  | 
|   8 namespace base { |   8 namespace base { | 
|   9 namespace internal { |   9 namespace internal { | 
|  10  |  10  | 
|  11 // CopyMode is used to control the copyablity of a Callback. |  11 // CopyMode is used to control the copyablity of a Callback. | 
|  12 // MoveOnly indicates the Callback is not copyable but movable, and Copyable |  12 // MoveOnly indicates the Callback is not copyable but movable, and Copyable | 
|  13 // indicates it is copyable and movable. |  13 // indicates it is copyable and movable. | 
|  14 enum class CopyMode { |  14 enum class CopyMode { | 
|  15   MoveOnly, Copyable, |  15   MoveOnly, | 
 |  16   Copyable, | 
 |  17 }; | 
 |  18  | 
 |  19 enum class RepeatMode { | 
 |  20   Once, | 
 |  21   Repeating, | 
|  16 }; |  22 }; | 
|  17  |  23  | 
|  18 }  // namespace internal |  24 }  // namespace internal | 
|  19  |  25  | 
|  20 template <typename Signature, |  26 template <typename Signature, | 
|  21           internal::CopyMode copy_mode = internal::CopyMode::Copyable> |  27           internal::CopyMode copy_mode = internal::CopyMode::Copyable, | 
 |  28           internal::RepeatMode repeat_mode = internal::RepeatMode::Repeating> | 
|  22 class Callback; |  29 class Callback; | 
|  23  |  30  | 
|  24 // Syntactic sugar to make Callback<void()> easier to declare since it |  31 // Syntactic sugar to make Callback<void()> easier to declare since it | 
|  25 // will be used in a lot of APIs with delayed execution. |  32 // will be used in a lot of APIs with delayed execution. | 
|  26 using Closure = Callback<void()>; |  33 using Closure = Callback<void()>; | 
|  27  |  34  | 
 |  35 namespace internal { | 
 |  36  | 
 |  37 template <typename Signature> | 
 |  38 using OnceCallback = Callback<Signature, | 
 |  39                               internal::CopyMode::MoveOnly, | 
 |  40                               internal::RepeatMode::Once>; | 
 |  41 template <typename Signature> | 
 |  42 using RepeatingCallback = Callback<Signature, | 
 |  43                                    internal::CopyMode::Copyable, | 
 |  44                                    internal::RepeatMode::Repeating>; | 
 |  45 using OnceClosure = OnceCallback<void()>; | 
 |  46 using RepeatingClosure = RepeatingCallback<void()>; | 
 |  47  | 
 |  48 }  // namespace internal | 
|  28 }  // namespace base |  49 }  // namespace base | 
|  29  |  50  | 
|  30 #endif  // BASE_CALLBACK_FORWARD_H_ |  51 #endif  // BASE_CALLBACK_FORWARD_H_ | 
| OLD | NEW |