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

Unified Diff: base/task.h

Issue 7062013: Move media library AutoTaskRunner to base and rename ScopedTaskRunner. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments and add unit test. Created 9 years, 7 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/task.cc » ('j') | base/task_unittest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/task.h
diff --git a/base/task.h b/base/task.h
index b698576ef899e3d4c0faad1c8845f13b22bbe4e1..6372bb35a03091065b79391a5522e8a26727e5af 100644
--- a/base/task.h
+++ b/base/task.h
@@ -546,4 +546,24 @@ inline Task* NewRunnableFunction(Function function, const A& a, const B& b,
function, MakeTuple(a, b, c, d, e, f, g, h));
}
+namespace base {
+
+// ScopedTaskRunner is akin to scoped_ptr for Tasks. It ensures that the Task
+// is executed and deleted no matter how the current scope exits.
+class ScopedTaskRunner {
+ public:
+ // Takes ownership of the task.
+ explicit ScopedTaskRunner(Task* task);
+ ~ScopedTaskRunner();
+
+ Task* Release();
+
+ private:
+ Task* task_;
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedTaskRunner);
+};
+
+}
awong 2011/05/26 19:01:01 style-OCD nit: End namespaces with a comment. }
Wez 2011/05/26 20:53:46 Done.
+
#endif // BASE_TASK_H_
« no previous file with comments | « no previous file | base/task.cc » ('j') | base/task_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698