summaryrefslogtreecommitdiffstats
path: root/base/task.cc
diff options
context:
space:
mode:
authorajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-26 18:25:16 +0000
committerajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-26 18:25:16 +0000
commit180c85e3e3691042ab617fd0755dcde6e75d5fbd (patch)
treeb9d4fd7a77f7f54dce4463960326ef7b0cd7a270 /base/task.cc
parent324ab8e0d77303333f8ad7de3b54d248587687db (diff)
downloadchromium_src-180c85e3e3691042ab617fd0755dcde6e75d5fbd.zip
chromium_src-180c85e3e3691042ab617fd0755dcde6e75d5fbd.tar.gz
chromium_src-180c85e3e3691042ab617fd0755dcde6e75d5fbd.tar.bz2
Support Closure in ALL the loops!
Add an overload for PostTask into MessageLoopProxy, and WorkerPool. BUG=35223 TEST=unittests. Review URL: http://codereview.chromium.org/7316015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94129 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/task.cc')
-rw-r--r--base/task.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/base/task.cc b/base/task.cc
index e4da547..8c61473 100644
--- a/base/task.cc
+++ b/base/task.cc
@@ -34,4 +34,33 @@ Task* ScopedTaskRunner::Release() {
return tmp;
}
+namespace subtle {
+
+TaskClosureAdapter::TaskClosureAdapter(Task* task)
+ : task_(task),
+ should_leak_task_(&kTaskLeakingDefault) {
+}
+
+TaskClosureAdapter::TaskClosureAdapter(Task* task, bool* should_leak_task)
+ : task_(task),
+ should_leak_task_(should_leak_task) {
+}
+
+TaskClosureAdapter::~TaskClosureAdapter() {
+ if (!*should_leak_task_) {
+ delete task_;
+ }
+}
+
+void TaskClosureAdapter::Run() {
+ task_->Run();
+ delete task_;
+ task_ = NULL;
+}
+
+// Don't leak tasks by default.
+bool TaskClosureAdapter::kTaskLeakingDefault = false;
+
+} // namespace subtle
+
} // namespace base