Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1648)

Unified Diff: base/callback_helpers.h

Issue 2091503004: Add move constructor in ScopedClosureRunner. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/callback_helpers.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/callback_helpers.h
diff --git a/base/callback_helpers.h b/base/callback_helpers.h
index 860803989f4b45cf9c55f4a55d0ebcd785bb047e..c4b0d867634751fbc3e0dfa3a4b0b7177def79e8 100644
--- a/base/callback_helpers.h
+++ b/base/callback_helpers.h
@@ -27,16 +27,27 @@ 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.
+// ScopedClosureRunner is akin to std::unique_ptr<> for Closures. It ensures
+// that the Closure is executed no matter how the current scope exits.
class BASE_EXPORT ScopedClosureRunner {
public:
ScopedClosureRunner();
explicit ScopedClosureRunner(const Closure& closure);
~ScopedClosureRunner();
+ ScopedClosureRunner(ScopedClosureRunner&& other);
+
+ // Calls the current closure if it's set and replaces it with the closure from
+ // |other|.
+ ScopedClosureRunner& operator=(ScopedClosureRunner&& other);
+
+ // Calls the current closure and resets it, so it wont be called again.
void Reset();
+
+ // Calls the current closure and replaces it with the new one.
void Reset(const Closure& closure);
+
+ // Releases the Closure without calling.
Closure Release() WARN_UNUSED_RESULT;
private:
« no previous file with comments | « no previous file | base/callback_helpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698