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(). |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 // cb = Bind(&TakesOwnership, Passed(CreateFoo())); | 122 // cb = Bind(&TakesOwnership, Passed(CreateFoo())); |
123 // | 123 // |
124 // // |arg| in TakesOwnership() is given ownership of Foo(). |cb| | 124 // // |arg| in TakesOwnership() is given ownership of Foo(). |cb| |
125 // // no longer owns Foo() and, if reset, would not delete Foo(). | 125 // // no longer owns Foo() and, if reset, would not delete Foo(). |
126 // cb.Run(); // Foo() is now transferred to |arg| and deleted. | 126 // cb.Run(); // Foo() is now transferred to |arg| and deleted. |
127 // cb.Run(); // This CHECK()s since Foo() already been used once. | 127 // cb.Run(); // This CHECK()s since Foo() already been used once. |
128 // | 128 // |
129 // Passed() is particularly useful with PostTask() when you are transferring | 129 // Passed() is particularly useful with PostTask() when you are transferring |
130 // ownership of an argument into a task, but don't necessarily know if the | 130 // ownership of an argument into a task, but don't necessarily know if the |
131 // task will always be executed. This can happen if the task is cancellable | 131 // task will always be executed. This can happen if the task is cancellable |
132 // or if it is posted to a MessageLoopProxy. | 132 // or if it is posted to a TaskRunner. |
133 // | 133 // |
134 // | 134 // |
135 // SIMPLE FUNCTIONS AND UTILITIES. | 135 // SIMPLE FUNCTIONS AND UTILITIES. |
136 // | 136 // |
137 // DoNothing() - Useful for creating a Closure that does nothing when called. | 137 // DoNothing() - Useful for creating a Closure that does nothing when called. |
138 // DeletePointer<T>() - Useful for creating a Closure that will delete a | 138 // DeletePointer<T>() - Useful for creating a Closure that will delete a |
139 // pointer when invoked. Only use this when necessary. | 139 // pointer when invoked. Only use this when necessary. |
140 // In most cases MessageLoop::DeleteSoon() is a better | 140 // In most cases MessageLoop::DeleteSoon() is a better |
141 // fit. | 141 // fit. |
142 | 142 |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 BASE_EXPORT void DoNothing(); | 593 BASE_EXPORT void DoNothing(); |
594 | 594 |
595 template<typename T> | 595 template<typename T> |
596 void DeletePointer(T* obj) { | 596 void DeletePointer(T* obj) { |
597 delete obj; | 597 delete obj; |
598 } | 598 } |
599 | 599 |
600 } // namespace base | 600 } // namespace base |
601 | 601 |
602 #endif // BASE_BIND_HELPERS_H_ | 602 #endif // BASE_BIND_HELPERS_H_ |
OLD | NEW |