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 3// found in the LICENSE file. 4 5#ifndef BASE_CALLBACK_FORWARD_H_ 6#define BASE_CALLBACK_FORWARD_H_ 7 8namespace base { 9namespace internal { 10 11// 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 { 15 MoveOnly, 16 Copyable, 17}; 18 19enum class RepeatMode { 20 Once, 21 Repeating, 22}; 23 24} // namespace internal 25 26template <typename Signature, 27 internal::CopyMode copy_mode = internal::CopyMode::Copyable, 28 internal::RepeatMode repeat_mode = internal::RepeatMode::Repeating> 29class Callback; 30 31// Syntactic sugar to make Callback<void()> easier to declare since it 32// will be used in a lot of APIs with delayed execution. 33using Closure = Callback<void()>; 34 35template <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 46} // namespace base 47 48#endif // BASE_CALLBACK_FORWARD_H_ 49