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

Side by Side Diff: base/callback_forward.h

Issue 2042223002: Introduce OnceClosure and BindOnce (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 3 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
OLDNEW
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, Copyable,
16 }; 16 };
17 17
18 enum class RepeatMode {
19 Once,
dcheng 2016/09/08 04:09:01 Super minor optional nit: here, the order is Once,
tzik 2016/09/12 11:00:34 Done. I moved all .*Once.* before Repeating.
20 Repeating,
21 };
22
18 } // namespace internal 23 } // namespace internal
19 24
20 template <typename Signature, 25 template <typename Signature,
21 internal::CopyMode copy_mode = internal::CopyMode::Copyable> 26 internal::CopyMode copy_mode = internal::CopyMode::Copyable,
27 internal::RepeatMode repeat_mode = internal::RepeatMode::Repeating>
22 class Callback; 28 class Callback;
23 29
24 // Syntactic sugar to make Callback<void()> easier to declare since it 30 // Syntactic sugar to make Callback<void()> easier to declare since it
25 // will be used in a lot of APIs with delayed execution. 31 // will be used in a lot of APIs with delayed execution.
26 using Closure = Callback<void()>; 32 using Closure = Callback<void()>;
27 33
34 namespace internal {
35
36 template <typename Signature>
37 using RepeatingCallback = Callback<Signature,
38 internal::CopyMode::Copyable,
39 internal::RepeatMode::Repeating>;
40 template <typename Signature>
41 using OnceCallback = Callback<Signature,
42 internal::CopyMode::MoveOnly,
43 internal::RepeatMode::Once>;
44 using RepeatingClosure = RepeatingCallback<void()>;
45 using OnceClosure = OnceCallback<void()>;
46
47 } // namespace internal
28 } // namespace base 48 } // namespace base
29 49
30 #endif // BASE_CALLBACK_FORWARD_H_ 50 #endif // BASE_CALLBACK_FORWARD_H_
OLDNEW
« base/callback.h ('K') | « base/callback.h ('k') | base/callback_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698