blob: 8c614734863fb5c8e34959dd2b00b4ac8c80e538 [file] [log] [blame]
wez@chromium.org6d4ad682011-05-28 04:35:11 +09001// Copyright (c) 2011 The Chromium Authors. All rights reserved.
erg@chromium.org493f5f62010-07-16 06:03:54 +09002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "base/task.h"
6
7Task::Task() {
8}
9
10Task::~Task() {
11}
12
13CancelableTask::CancelableTask() {
14}
15
16CancelableTask::~CancelableTask() {
17}
wez@chromium.org6d4ad682011-05-28 04:35:11 +090018
19namespace base {
20
21ScopedTaskRunner::ScopedTaskRunner(Task* task) : task_(task) {
22}
23
24ScopedTaskRunner::~ScopedTaskRunner() {
25 if (task_) {
26 task_->Run();
27 delete task_;
28 }
29}
30
31Task* ScopedTaskRunner::Release() {
32 Task* tmp = task_;
33 task_ = NULL;
34 return tmp;
35}
36
ajwong@chromium.org12fa0922011-07-27 03:25:16 +090037namespace subtle {
38
39TaskClosureAdapter::TaskClosureAdapter(Task* task)
40 : task_(task),
41 should_leak_task_(&kTaskLeakingDefault) {
42}
43
44TaskClosureAdapter::TaskClosureAdapter(Task* task, bool* should_leak_task)
45 : task_(task),
46 should_leak_task_(should_leak_task) {
47}
48
49TaskClosureAdapter::~TaskClosureAdapter() {
50 if (!*should_leak_task_) {
51 delete task_;
52 }
53}
54
55void TaskClosureAdapter::Run() {
56 task_->Run();
57 delete task_;
58 task_ = NULL;
59}
60
61// Don't leak tasks by default.
62bool TaskClosureAdapter::kTaskLeakingDefault = false;
63
64} // namespace subtle
65
wez@chromium.org6d4ad682011-05-28 04:35:11 +090066} // namespace base