Index: base/bind_helpers.h |
diff --git a/base/bind_helpers.h b/base/bind_helpers.h |
index af6ff26787bf58a587e6b60efb5149b5a849aaac..ae2a63cd1219ca7e7439daae1e6d666c3985f8d6 100644 |
--- a/base/bind_helpers.h |
+++ b/base/bind_helpers.h |
@@ -6,7 +6,13 @@ |
// can be used specify the refcounting and reference semantics of arguments |
// that are bound by the Bind() function in base/bind.h. |
// |
-// The public functions are base::Unretained(), base::Owned(), bass::Passed(), |
+// It also defines a set of simple functions and utilities that people want |
+// when using Callback<> and Bind(). |
+// |
+// |
+// ARGUMENT BINDING WRAPPERS |
+// |
+// The wrapper functions are base::Unretained(), base::Owned(), bass::Passed(), |
// base::ConstRef(), and base::IgnoreResult(). |
// |
// Unretained() allows Bind() to bind a non-refcounted class, and to disable |
@@ -124,6 +130,19 @@ |
// ownership of an argument into a task, but don't necessarily know if the |
// task will always be executed. This can happen if the task is cancellable |
// or if it is posted to a MessageLoopProxy. |
+// |
+// |
+// SIMPLE FUNCTIONS AND UTILITIES. |
+// |
+// DoNothing() - Useful for creating a Closure that does nothing when called. |
+// DeletePointer<T>() - Useful for creating a Closure that will delete a |
+// pointer when invoked. Only use this when necessary. |
+// In most cases MessageLoop::DeleteSoon() is a better |
+// fit. |
+// ScopedClosureRunner - Scoper object that runs the wrapped closure when it |
+// goes out of scope. It's conceptually similar to |
+// scoped_ptr<> but calls Run() instead of deleting |
+// the pointer. |
#ifndef BASE_BIND_HELPERS_H_ |
#define BASE_BIND_HELPERS_H_ |
@@ -517,6 +536,28 @@ IgnoreResult(const Callback<T>& data) { |
return internal::IgnoreResultHelper<Callback<T> >(data); |
} |
+BASE_EXPORT void DoNothing(); |
+ |
+template<typename T> |
+void DeletePointer(T* obj) { |
+ delete obj; |
+} |
+ |
+// ScopedClosureRunner is akin to scoped_ptr for Closures. It ensures that the |
+// Closure is executed and deleted no matter how the current scope exits. |
+class BASE_EXPORT ScopedClosureRunner { |
+ public: |
+ explicit ScopedClosureRunner(const Closure& closure); |
+ ~ScopedClosureRunner(); |
+ |
+ Closure Release(); |
+ |
+ private: |
+ Closure closure_; |
+ |
+ DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedClosureRunner); |
+}; |
+ |
} // namespace base |
#endif // BASE_BIND_HELPERS_H_ |