Chromium Code Reviews| 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 #include "base/bind.h" | |
| 8 | |
| 7 Task::Task() { | 9 Task::Task() { |
| 8 } | 10 } |
| 9 | 11 |
| 10 Task::~Task() { | 12 Task::~Task() { |
| 11 } | 13 } |
| 12 | 14 |
| 13 CancelableTask::CancelableTask() { | 15 CancelableTask::CancelableTask() { |
| 14 } | 16 } |
| 15 | 17 |
| 16 CancelableTask::~CancelableTask() { | 18 CancelableTask::~CancelableTask() { |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 27 delete task_; | 29 delete task_; |
| 28 } | 30 } |
| 29 } | 31 } |
| 30 | 32 |
| 31 Task* ScopedTaskRunner::Release() { | 33 Task* ScopedTaskRunner::Release() { |
| 32 Task* tmp = task_; | 34 Task* tmp = task_; |
| 33 task_ = NULL; | 35 task_ = NULL; |
| 34 return tmp; | 36 return tmp; |
| 35 } | 37 } |
| 36 | 38 |
| 39 namespace internal { | |
| 40 | |
| 41 PostTaskAndReplyRelay::PostTaskAndReplyRelay(const Closure& task, | |
| 42 const Closure& reply) | |
| 43 : task_(task), | |
| 44 reply_(reply), | |
| 45 origin_loop_(MessageLoop::Current()) { | |
| 46 } | |
| 47 | |
| 48 PostTaskAndReplyRelay::~PostTaskAndReplyRelay() { | |
| 49 DCHECK(origin_loop_ == MessageLoop::Current()); | |
| 50 } | |
| 51 | |
| 52 void PostTaskAndReplyRelay::Run() { | |
| 53 task_.Run(); | |
| 54 origin_loop_->PostTask( | |
|
darin (slow to review)
2011/07/01 04:15:32
what if the origin thread is already gone? i susp
willchan no longer on Chromium
2011/07/01 15:13:54
Yes, MessageLoopProxy FTW.
awong
2011/07/02 00:36:57
Done.
| |
| 55 base::Bind(&PostTaskAndReplyRelay::RunReplyAndSelfDestruct, | |
|
willchan no longer on Chromium
2011/07/01 15:13:54
We're already in base::, so the prefix probably is
awong
2011/07/02 00:36:57
Done.
| |
| 56 base::Unretained(this))); | |
| 57 } | |
| 58 | |
| 59 void PostTaskAndReplyRelay::RunReplyAndSelfDestruct() { | |
| 60 reply_.Run(); | |
| 61 delete this; | |
| 62 } | |
| 63 } // namespace internal | |
|
darin (slow to review)
2011/07/01 04:15:32
nit: add a new line above the close of the namespa
awong
2011/07/02 00:36:57
Done.
| |
| 64 | |
| 65 | |
| 37 } // namespace base | 66 } // namespace base |
| OLD | NEW |