blob: 13eed0eb0d2fd7e61f092698456fa92e04a46b3b [file] [log] [blame]
[email protected]2d715662011-11-28 22:00:291// 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
3// found in the LICENSE file.
4
5#ifndef BASE_CALLBACK_FORWARD_H_
6#define BASE_CALLBACK_FORWARD_H_
[email protected]2d715662011-11-28 22:00:297
8namespace base {
tzik77d411392016-03-09 09:47:039namespace internal {
[email protected]2d715662011-11-28 22:00:2910
tzik77d411392016-03-09 09:47:0311// CopyMode is used to control the copyablity of a Callback.
12// MoveOnly indicates the Callback is not copyable but movable, and Copyable
13// indicates it is copyable and movable.
14enum class CopyMode {
tzik27d1e312016-09-13 05:28:5915 MoveOnly,
16 Copyable,
17};
18
19enum class RepeatMode {
20 Once,
21 Repeating,
tzik77d411392016-03-09 09:47:0322};
23
24} // namespace internal
25
26template <typename Signature,
tzik27d1e312016-09-13 05:28:5927 internal::CopyMode copy_mode = internal::CopyMode::Copyable,
28 internal::RepeatMode repeat_mode = internal::RepeatMode::Repeating>
[email protected]2d715662011-11-28 22:00:2929class Callback;
30
tzik3bc7779b2015-12-19 09:18:4631// Syntactic sugar to make Callback<void()> easier to declare since it
tzikce3ecf82015-12-15 06:41:4932// will be used in a lot of APIs with delayed execution.
tzik3bc7779b2015-12-19 09:18:4633using Closure = Callback<void()>;
[email protected]2d715662011-11-28 22:00:2934
tzik27d1e312016-09-13 05:28:5935template <typename Signature>
36using OnceCallback = Callback<Signature,
37 internal::CopyMode::MoveOnly,
38 internal::RepeatMode::Once>;
39template <typename Signature>
40using RepeatingCallback = Callback<Signature,
41 internal::CopyMode::Copyable,
42 internal::RepeatMode::Repeating>;
43using OnceClosure = OnceCallback<void()>;
44using RepeatingClosure = RepeatingCallback<void()>;
45
[email protected]2d715662011-11-28 22:00:2946} // namespace base
47
danakj0a448602015-03-10 00:31:1648#endif // BASE_CALLBACK_FORWARD_H_