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/threading/post_task_and_reply_impl.h" | |
| 6 | |
| 5 #include "base/message_loop_proxy.h" | 7 #include "base/message_loop_proxy.h" |
|
awong
2011/10/05 17:27:01
Add #include bind.h and location.h for IWYU.
Jói
2011/10/06 14:20:31
Done.
| |
| 6 | 8 |
| 7 #include "base/bind.h" | |
| 8 #include "base/location.h" | |
| 9 | |
| 10 namespace base { | 9 namespace base { |
| 11 | 10 |
| 12 namespace { | 11 namespace { |
| 13 | 12 |
| 14 // This relay class remembers the MessageLoop that it was created on, and | 13 // This relay class remembers the MessageLoop that it was created on, and |
| 15 // ensures that both the |task| and |reply| Closures are deleted on this same | 14 // ensures that both the |task| and |reply| Closures are deleted on this same |
| 16 // thread. Also, |task| is guaranteed to be deleted before |reply| is run or | 15 // thread. Also, |task| is guaranteed to be deleted before |reply| is run or |
| 17 // deleted. | 16 // deleted. |
| 18 // | 17 // |
| 19 // If this is not possible because the originating MessageLoop is no longer | 18 // If this is not possible because the originating MessageLoop is no longer |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 } | 59 } |
| 61 | 60 |
| 62 tracked_objects::Location from_here_; | 61 tracked_objects::Location from_here_; |
| 63 scoped_refptr<MessageLoopProxy> origin_loop_; | 62 scoped_refptr<MessageLoopProxy> origin_loop_; |
| 64 Closure reply_; | 63 Closure reply_; |
| 65 Closure task_; | 64 Closure task_; |
| 66 }; | 65 }; |
| 67 | 66 |
| 68 } // namespace | 67 } // namespace |
| 69 | 68 |
| 70 MessageLoopProxy::MessageLoopProxy() { | 69 bool PostTaskAndReplyImpl::PostTaskAndReply( |
| 71 } | |
| 72 | |
| 73 MessageLoopProxy::~MessageLoopProxy() { | |
| 74 } | |
| 75 | |
| 76 bool MessageLoopProxy::PostTaskAndReply( | |
| 77 const tracked_objects::Location& from_here, | 70 const tracked_objects::Location& from_here, |
| 78 const Closure& task, | 71 const Closure& task, |
| 79 const Closure& reply) { | 72 const Closure& reply) { |
| 80 PostTaskAndReplyRelay* relay = | 73 PostTaskAndReplyRelay* relay = |
| 81 new PostTaskAndReplyRelay(from_here, task, reply); | 74 new PostTaskAndReplyRelay(from_here, task, reply); |
| 82 if (!PostTask(from_here, Bind(&PostTaskAndReplyRelay::Run, | 75 if (!PostTask(from_here, Bind(&PostTaskAndReplyRelay::Run, |
| 83 Unretained(relay)))) { | 76 Unretained(relay)))) { |
| 84 delete relay; | 77 delete relay; |
| 85 return false; | 78 return false; |
| 86 } | 79 } |
| 87 | 80 |
| 88 return true; | 81 return true; |
| 89 } | 82 } |
| 90 | 83 |
| 91 void MessageLoopProxy::OnDestruct() const { | |
| 92 delete this; | |
| 93 } | |
| 94 | |
| 95 } // namespace base | 84 } // namespace base |
| OLD | NEW |