| Index: base/callback_helpers.h
|
| diff --git a/base/callback_helpers.h b/base/callback_helpers.h
|
| index 52cb71bbf2610d7e359a20b9250581511ea368c7..8481e3e71c0fc6c79f04e87e1158282888cb38cc 100644
|
| --- a/base/callback_helpers.h
|
| +++ b/base/callback_helpers.h
|
| @@ -14,7 +14,9 @@
|
| #ifndef BASE_CALLBACK_HELPERS_H_
|
| #define BASE_CALLBACK_HELPERS_H_
|
|
|
| +#include "base/basictypes.h"
|
| #include "base/callback.h"
|
| +#include "base/compiler_specific.h"
|
|
|
| namespace base {
|
|
|
| @@ -25,6 +27,24 @@ base::Callback<Sig> ResetAndReturn(base::Callback<Sig>* cb) {
|
| return ret;
|
| }
|
|
|
| +// 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:
|
| + ScopedClosureRunner();
|
| + explicit ScopedClosureRunner(const Closure& closure);
|
| + ~ScopedClosureRunner();
|
| +
|
| + void Reset();
|
| + void Reset(const Closure& closure);
|
| + Closure Release() WARN_UNUSED_RESULT;
|
| +
|
| + private:
|
| + Closure closure_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ScopedClosureRunner);
|
| +};
|
| +
|
| } // namespace base
|
|
|
| #endif // BASE_CALLBACK_HELPERS_H_
|
|
|