Chromium Code Reviews| 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, |
| 91 // handles, num_handles, | |
|
darin (slow to review)
2013/11/11 21:22:21
nit: remove commented out code or add a TODO?
viettrungluu
2013/11/11 22:40:26
Oops, deleted. Thanks.
| |
| 89 flags); | 92 flags); |
| 90 } | 93 } |
| 91 | 94 |
| 92 MojoResult MessagePipe::AddWaiter(unsigned port, | 95 MojoResult MessagePipe::AddWaiter(unsigned port, |
| 93 Waiter* waiter, | 96 Waiter* waiter, |
| 94 MojoWaitFlags flags, | 97 MojoWaitFlags flags, |
| 95 MojoResult wake_result) { | 98 MojoResult wake_result) { |
| 96 DCHECK(port == 0 || port == 1); | 99 DCHECK(port == 0 || port == 1); |
| 97 | 100 |
| 98 base::AutoLock locker(lock_); | 101 base::AutoLock locker(lock_); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 rv = MOJO_RESULT_UNKNOWN; | 196 rv = MOJO_RESULT_UNKNOWN; |
| 194 break; | 197 break; |
| 195 } | 198 } |
| 196 | 199 |
| 197 message->Destroy(); | 200 message->Destroy(); |
| 198 return rv; | 201 return rv; |
| 199 } | 202 } |
| 200 | 203 |
| 201 } // namespace system | 204 } // namespace system |
| 202 } // namespace mojo | 205 } // namespace mojo |
| OLD | NEW |