blob: ce4c3e7192d4d58571ccadf67c7661898c5357a2 [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:5935namespace internal {
36
37template <typename Signature>
38using OnceCallback = Callback<Signature,
39 internal::CopyMode::MoveOnly,
40 internal::RepeatMode::Once>;
41template <typename Signature>
42using RepeatingCallback = Callback<Signature,
43 internal::CopyMode::Copyable,
44 internal::RepeatMode::Repeating>;
45using OnceClosure = OnceCallback<void()>;
46using RepeatingClosure = RepeatingCallback<void()>;
47
48} // namespace internal
[email protected]2d715662011-11-28 22:00:2949} // namespace base
50
danakj0a448602015-03-10 00:31:1651#endif // BASE_CALLBACK_FORWARD_H_