| Index: base/task.cc
|
| diff --git a/base/task.cc b/base/task.cc
|
| index 8c614734863fb5c8e34959dd2b00b4ac8c80e538..b770355c73f9122e6cbe03ac9162985a619a1f21 100644
|
| --- a/base/task.cc
|
| +++ b/base/task.cc
|
| @@ -4,6 +4,9 @@
|
|
|
| #include "base/task.h"
|
|
|
| +#include "base/bind.h"
|
| +#include "base/message_loop_proxy.h"
|
| +
|
| Task::Task() {
|
| }
|
|
|
| @@ -63,4 +66,42 @@ bool TaskClosureAdapter::kTaskLeakingDefault = false;
|
|
|
| } // namespace subtle
|
|
|
| +namespace internal {
|
| +
|
| +PostTaskAndReplyRelay::PostTaskAndReplyRelay(
|
| + const tracked_objects::Location& from_here,
|
| + const Closure& task,
|
| + const Closure& reply)
|
| + : from_here_(from_here),
|
| + origin_loop_(MessageLoopProxy::CreateForCurrentThread()) {
|
| + task_ = task;
|
| + reply_ = reply;
|
| +}
|
| +
|
| +PostTaskAndReplyRelay::~PostTaskAndReplyRelay() {
|
| + DCHECK(origin_loop_->BelongsToCurrentThread());
|
| + task_.Reset();
|
| + reply_.Reset();
|
| +}
|
| +
|
| +void PostTaskAndReplyRelay::Run() {
|
| + task_.Run();
|
| + origin_loop_->PostTask(
|
| + from_here_,
|
| + Bind(&PostTaskAndReplyRelay::RunReplyAndSelfDestruct,
|
| + base::Unretained(this)));
|
| +}
|
| +
|
| +void PostTaskAndReplyRelay::RunReplyAndSelfDestruct() {
|
| + DCHECK(origin_loop_->BelongsToCurrentThread());
|
| + task_.Reset();
|
| +
|
| + reply_.Run();
|
| +
|
| + // Cue mission impossible theme.
|
| + delete this;
|
| +}
|
| +
|
| +} // namespace internal
|
| +
|
| } // namespace base
|
|
|