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 // This defines a set of argument wrappers and related factory methods that | 5 // This defines a set of argument wrappers and related factory methods that |
6 // can be used specify the refcounting and reference semantics of arguments | 6 // can be used specify the refcounting and reference semantics of arguments |
7 // that are bound by the Bind() function in base/bind.h. | 7 // that are bound by the Bind() function in base/bind.h. |
8 // | 8 // |
9 // It also defines a set of simple functions and utilities that people want | 9 // It also defines a set of simple functions and utilities that people want |
10 // when using Callback<> and Bind(). | 10 // when using Callback<> and Bind(). |
11 // | 11 // |
12 // | 12 // |
13 // ARGUMENT BINDING WRAPPERS | 13 // ARGUMENT BINDING WRAPPERS |
14 // | 14 // |
15 // The wrapper functions are base::Unretained(), base::Owned(), base::Passed(), | 15 // The wrapper functions are base::Unretained(), base::Owned(), base::Passed(), |
16 // base::ConstRef(), and base::IgnoreResult(). | 16 // base::ConstRef(), and base::IgnoreResult(). |
17 // | 17 // |
18 // Unretained() allows Bind() to bind a non-refcounted class, and to disable | 18 // Unretained() allows Bind() to bind a non-refcounted class, and to disable |
19 // refcounting on arguments that are refcounted objects. | 19 // refcounting on arguments that are refcounted objects. |
20 // | 20 // |
21 // Owned() transfers ownership of an object to the Callback resulting from | 21 // Owned() transfers ownership of an object to the Callback resulting from |
22 // bind; the object will be deleted when the Callback is deleted. | 22 // bind; the object will be deleted when the Callback is deleted. |
23 // | 23 // |
24 // Passed() is for transferring movable-but-not-copyable types (eg. scoped_ptr) | 24 // Passed() is for transferring movable-but-not-copyable types (eg. unique_ptr) |
25 // through a Callback. Logically, this signifies a destructive transfer of | 25 // through a Callback. Logically, this signifies a destructive transfer of |
26 // the state of the argument into the target function. Invoking | 26 // the state of the argument into the target function. Invoking |
27 // Callback::Run() twice on a Callback that was created with a Passed() | 27 // Callback::Run() twice on a Callback that was created with a Passed() |
28 // argument will CHECK() because the first invocation would have already | 28 // argument will CHECK() because the first invocation would have already |
29 // transferred ownership to the target function. | 29 // transferred ownership to the target function. |
30 // | 30 // |
31 // RetainedRef() accepts a ref counted object and retains a reference to it. | 31 // RetainedRef() accepts a ref counted object and retains a reference to it. |
32 // When the callback is called, the object is passed as a raw pointer. | 32 // When the callback is called, the object is passed as a raw pointer. |
33 // | 33 // |
34 // ConstRef() allows binding a constant reference to an argument rather | 34 // ConstRef() allows binding a constant reference to an argument rather |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 | 562 |
563 template <typename Functor> | 563 template <typename Functor> |
564 static bool IsCancelled(const Functor& functor, const BoundArgs&...) { | 564 static bool IsCancelled(const Functor& functor, const BoundArgs&...) { |
565 return functor.IsCancelled(); | 565 return functor.IsCancelled(); |
566 } | 566 } |
567 }; | 567 }; |
568 | 568 |
569 } // namespace base | 569 } // namespace base |
570 | 570 |
571 #endif // BASE_BIND_HELPERS_H_ | 571 #endif // BASE_BIND_HELPERS_H_ |
OLD | NEW |