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

Unified Diff: base/task.cc

Issue 8120015: Add ScopedClosureRunner. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: unittests Created 9 years, 2 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 | « base/task.h ('k') | base/task_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/task.cc
diff --git a/base/task.cc b/base/task.cc
index 8c614734863fb5c8e34959dd2b00b4ac8c80e538..89d2aa80e7fbb599113e6d6efd4fe5feb9e310ae 100644
--- a/base/task.cc
+++ b/base/task.cc
@@ -34,6 +34,21 @@ Task* ScopedTaskRunner::Release() {
return tmp;
}
+ScopedClosureRunner::ScopedClosureRunner(const Closure& closure)
+ : closure_(closure) {
+}
+
+ScopedClosureRunner::~ScopedClosureRunner() {
+ if (!closure_.is_null())
+ closure_.Run();
+}
+
+Closure ScopedClosureRunner::Release() {
+ Closure result = closure_;
+ closure_.Reset();
+ return result;
+}
+
namespace subtle {
TaskClosureAdapter::TaskClosureAdapter(Task* task)
« no previous file with comments | « base/task.h ('k') | base/task_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698