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

Side by Side Diff: base/task.cc

Issue 9086002: base::Bind: Remove Task. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Style fix. Created 8 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/task.h ('k') | base/threading/thread_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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() {
8 }
9
10 Task::~Task() {
11 }
12
13 namespace base { 7 namespace base {
14 8
15 ScopedClosureRunner::ScopedClosureRunner(const Closure& closure) 9 ScopedClosureRunner::ScopedClosureRunner(const Closure& closure)
16 : closure_(closure) { 10 : closure_(closure) {
17 } 11 }
18 12
19 ScopedClosureRunner::~ScopedClosureRunner() { 13 ScopedClosureRunner::~ScopedClosureRunner() {
20 if (!closure_.is_null()) 14 if (!closure_.is_null())
21 closure_.Run(); 15 closure_.Run();
22 } 16 }
23 17
24 Closure ScopedClosureRunner::Release() { 18 Closure ScopedClosureRunner::Release() {
25 Closure result = closure_; 19 Closure result = closure_;
26 closure_.Reset(); 20 closure_.Reset();
27 return result; 21 return result;
28 } 22 }
29 23
30 namespace subtle {
31
32 TaskClosureAdapter::TaskClosureAdapter(Task* task)
33 : task_(task),
34 should_leak_task_(&kTaskLeakingDefault) {
35 }
36
37 TaskClosureAdapter::TaskClosureAdapter(Task* task, bool* should_leak_task)
38 : task_(task),
39 should_leak_task_(should_leak_task) {
40 }
41
42 TaskClosureAdapter::~TaskClosureAdapter() {
43 if (!*should_leak_task_) {
44 delete task_;
45 }
46 }
47
48 void TaskClosureAdapter::Run() {
49 task_->Run();
50 delete task_;
51 task_ = NULL;
52 }
53
54 // Don't leak tasks by default.
55 bool TaskClosureAdapter::kTaskLeakingDefault = false;
56
57 } // namespace subtle
58
59 } // namespace base 24 } // namespace base
OLDNEW
« no previous file with comments | « base/task.h ('k') | base/threading/thread_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698