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