OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/task.h" | 5 #include "base/task.h" |
6 | 6 |
7 Task::Task() { | 7 Task::Task() { |
8 } | 8 } |
9 | 9 |
10 Task::~Task() { | 10 Task::~Task() { |
(...skipping 16 matching lines...) Expand all Loading... |
27 delete task_; | 27 delete task_; |
28 } | 28 } |
29 } | 29 } |
30 | 30 |
31 Task* ScopedTaskRunner::Release() { | 31 Task* ScopedTaskRunner::Release() { |
32 Task* tmp = task_; | 32 Task* tmp = task_; |
33 task_ = NULL; | 33 task_ = NULL; |
34 return tmp; | 34 return tmp; |
35 } | 35 } |
36 | 36 |
| 37 ScopedClosureRunner::ScopedClosureRunner(const Closure& closure) |
| 38 : closure_(closure) { |
| 39 } |
| 40 |
| 41 ScopedClosureRunner::~ScopedClosureRunner() { |
| 42 if (!closure_.is_null()) |
| 43 closure_.Run(); |
| 44 } |
| 45 |
| 46 Closure ScopedClosureRunner::Release() { |
| 47 Closure result = closure_; |
| 48 closure_.Reset(); |
| 49 return result; |
| 50 } |
| 51 |
37 namespace subtle { | 52 namespace subtle { |
38 | 53 |
39 TaskClosureAdapter::TaskClosureAdapter(Task* task) | 54 TaskClosureAdapter::TaskClosureAdapter(Task* task) |
40 : task_(task), | 55 : task_(task), |
41 should_leak_task_(&kTaskLeakingDefault) { | 56 should_leak_task_(&kTaskLeakingDefault) { |
42 } | 57 } |
43 | 58 |
44 TaskClosureAdapter::TaskClosureAdapter(Task* task, bool* should_leak_task) | 59 TaskClosureAdapter::TaskClosureAdapter(Task* task, bool* should_leak_task) |
45 : task_(task), | 60 : task_(task), |
46 should_leak_task_(should_leak_task) { | 61 should_leak_task_(should_leak_task) { |
(...skipping 10 matching lines...) Expand all Loading... |
57 delete task_; | 72 delete task_; |
58 task_ = NULL; | 73 task_ = NULL; |
59 } | 74 } |
60 | 75 |
61 // Don't leak tasks by default. | 76 // Don't leak tasks by default. |
62 bool TaskClosureAdapter::kTaskLeakingDefault = false; | 77 bool TaskClosureAdapter::kTaskLeakingDefault = false; |
63 | 78 |
64 } // namespace subtle | 79 } // namespace subtle |
65 | 80 |
66 } // namespace base | 81 } // namespace base |
OLD | NEW |