OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/message_loop_proxy.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | |
9 #include "base/location.h" | |
10 #include "base/threading/post_task_and_reply_impl.h" | |
11 | 8 |
12 namespace base { | 9 namespace base { |
13 | 10 |
14 namespace { | |
15 | |
16 class PostTaskAndReplyMessageLoopProxy : public internal::PostTaskAndReplyImpl { | |
17 public: | |
18 PostTaskAndReplyMessageLoopProxy(MessageLoopProxy* destination) | |
19 : destination_(destination) { | |
20 } | |
21 | |
22 private: | |
23 virtual bool PostTask(const tracked_objects::Location& from_here, | |
24 const base::Closure& task) OVERRIDE { | |
25 return destination_->PostTask(from_here, task); | |
26 } | |
27 | |
28 // Non-owning. | |
29 MessageLoopProxy* destination_; | |
30 }; | |
31 | |
32 } // namespace | |
33 | |
34 MessageLoopProxy::MessageLoopProxy() { | 11 MessageLoopProxy::MessageLoopProxy() { |
35 } | 12 } |
36 | 13 |
37 MessageLoopProxy::~MessageLoopProxy() { | 14 MessageLoopProxy::~MessageLoopProxy() { |
38 } | 15 } |
39 | 16 |
40 bool MessageLoopProxy::PostTaskAndReply( | |
41 const tracked_objects::Location& from_here, | |
42 const Closure& task, | |
43 const Closure& reply) { | |
44 return PostTaskAndReplyMessageLoopProxy(this).PostTaskAndReply( | |
45 from_here, task, reply); | |
46 } | |
47 | |
48 void MessageLoopProxy::OnDestruct() const { | |
49 delete this; | |
50 } | |
51 | |
52 bool MessageLoopProxy::DeleteSoonInternal( | |
53 const tracked_objects::Location& from_here, | |
54 void(*deleter)(const void*), | |
55 const void* object) { | |
56 return PostNonNestableTask(from_here, base::Bind(deleter, object)); | |
57 } | |
58 | |
59 bool MessageLoopProxy::ReleaseSoonInternal( | |
60 const tracked_objects::Location& from_here, | |
61 void(*releaser)(const void*), | |
62 const void* object) { | |
63 return PostNonNestableTask(from_here, base::Bind(releaser, object)); | |
64 } | |
65 | |
66 } // namespace base | 17 } // namespace base |
OLD | NEW |