OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "mojo/system/message_pipe.h" | 5 #include "mojo/system/message_pipe.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "mojo/system/channel.h" | 9 #include "mojo/system/channel.h" |
10 #include "mojo/system/local_message_pipe_endpoint.h" | 10 #include "mojo/system/local_message_pipe_endpoint.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 endpoints_[destination_port]->Close(); | 57 endpoints_[destination_port]->Close(); |
58 endpoints_[destination_port].reset(); | 58 endpoints_[destination_port].reset(); |
59 } | 59 } |
60 } | 60 } |
61 | 61 |
62 // TODO(vtl): Support sending handles. | 62 // TODO(vtl): Support sending handles. |
63 // TODO(vtl): Handle flags. | 63 // TODO(vtl): Handle flags. |
64 MojoResult MessagePipe::WriteMessage( | 64 MojoResult MessagePipe::WriteMessage( |
65 unsigned port, | 65 unsigned port, |
66 const void* bytes, uint32_t num_bytes, | 66 const void* bytes, uint32_t num_bytes, |
67 const MojoHandle* /*handles*/, uint32_t /*num_handles*/, | 67 const std::vector<Dispatcher*>* /*dispatchers*/, |
68 MojoWriteMessageFlags flags) { | 68 MojoWriteMessageFlags flags) { |
69 DCHECK(port == 0 || port == 1); | 69 DCHECK(port == 0 || port == 1); |
70 return EnqueueMessage( | 70 return EnqueueMessage( |
71 GetPeerPort(port), | 71 GetPeerPort(port), |
72 MessageInTransit::Create( | 72 MessageInTransit::Create( |
73 MessageInTransit::kTypeMessagePipeEndpoint, | 73 MessageInTransit::kTypeMessagePipeEndpoint, |
74 MessageInTransit::kSubtypeMessagePipeEndpointData, | 74 MessageInTransit::kSubtypeMessagePipeEndpointData, |
75 bytes, num_bytes)); | 75 bytes, num_bytes)); |
76 } | 76 } |
77 | 77 |
78 MojoResult MessagePipe::ReadMessage(unsigned port, | 78 MojoResult MessagePipe::ReadMessage( |
79 void* bytes, uint32_t* num_bytes, | 79 unsigned port, |
80 MojoHandle* handles, uint32_t* num_handles, | 80 void* bytes, uint32_t* num_bytes, |
81 MojoReadMessageFlags flags) { | 81 uint32_t max_num_dispatchers, |
| 82 std::vector<scoped_refptr<Dispatcher> >* dispatchers, |
| 83 MojoReadMessageFlags flags) { |
82 DCHECK(port == 0 || port == 1); | 84 DCHECK(port == 0 || port == 1); |
83 | 85 |
84 base::AutoLock locker(lock_); | 86 base::AutoLock locker(lock_); |
85 DCHECK(endpoints_[port].get()); | 87 DCHECK(endpoints_[port].get()); |
86 | 88 |
87 return endpoints_[port]->ReadMessage(bytes, num_bytes, | 89 return endpoints_[port]->ReadMessage(bytes, num_bytes, |
88 handles, num_handles, | 90 NULL, NULL, |
89 flags); | 91 flags); |
90 } | 92 } |
91 | 93 |
92 MojoResult MessagePipe::AddWaiter(unsigned port, | 94 MojoResult MessagePipe::AddWaiter(unsigned port, |
93 Waiter* waiter, | 95 Waiter* waiter, |
94 MojoWaitFlags flags, | 96 MojoWaitFlags flags, |
95 MojoResult wake_result) { | 97 MojoResult wake_result) { |
96 DCHECK(port == 0 || port == 1); | 98 DCHECK(port == 0 || port == 1); |
97 | 99 |
98 base::AutoLock locker(lock_); | 100 base::AutoLock locker(lock_); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 rv = MOJO_RESULT_UNKNOWN; | 195 rv = MOJO_RESULT_UNKNOWN; |
194 break; | 196 break; |
195 } | 197 } |
196 | 198 |
197 message->Destroy(); | 199 message->Destroy(); |
198 return rv; | 200 return rv; |
199 } | 201 } |
200 | 202 |
201 } // namespace system | 203 } // namespace system |
202 } // namespace mojo | 204 } // namespace mojo |
OLD | NEW |