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/edk/system/message_pipe.h" | 5 #include "mojo/edk/system/message_pipe.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "mojo/edk/system/channel.h" | 8 #include "mojo/edk/system/channel.h" |
9 #include "mojo/edk/system/channel_endpoint.h" | 9 #include "mojo/edk/system/channel_endpoint.h" |
10 #include "mojo/edk/system/channel_endpoint_id.h" | 10 #include "mojo/edk/system/channel_endpoint_id.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 UserPointer<const void> bytes, | 145 UserPointer<const void> bytes, |
146 uint32_t num_bytes, | 146 uint32_t num_bytes, |
147 std::vector<DispatcherTransport>* transports, | 147 std::vector<DispatcherTransport>* transports, |
148 MojoWriteMessageFlags flags) { | 148 MojoWriteMessageFlags flags) { |
149 DCHECK(port == 0 || port == 1); | 149 DCHECK(port == 0 || port == 1); |
150 | 150 |
151 base::AutoLock locker(lock_); | 151 base::AutoLock locker(lock_); |
152 return EnqueueMessageNoLock( | 152 return EnqueueMessageNoLock( |
153 GetPeerPort(port), | 153 GetPeerPort(port), |
154 make_scoped_ptr(new MessageInTransit( | 154 make_scoped_ptr(new MessageInTransit( |
155 MessageInTransit::kTypeEndpoint, | 155 MessageInTransit::kTypeEndpointClient, |
156 MessageInTransit::kSubtypeEndpointData, num_bytes, bytes)), | 156 MessageInTransit::kSubtypeEndpointClientData, num_bytes, bytes)), |
157 transports); | 157 transports); |
158 } | 158 } |
159 | 159 |
160 MojoResult MessagePipe::ReadMessage(unsigned port, | 160 MojoResult MessagePipe::ReadMessage(unsigned port, |
161 UserPointer<void> bytes, | 161 UserPointer<void> bytes, |
162 UserPointer<uint32_t> num_bytes, | 162 UserPointer<uint32_t> num_bytes, |
163 DispatcherVector* dispatchers, | 163 DispatcherVector* dispatchers, |
164 uint32_t* num_dispatchers, | 164 uint32_t* num_dispatchers, |
165 MojoReadMessageFlags flags) { | 165 MojoReadMessageFlags flags) { |
166 DCHECK(port == 0 || port == 1); | 166 DCHECK(port == 0 || port == 1); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 DCHECK(!endpoints_[1]); | 311 DCHECK(!endpoints_[1]); |
312 } | 312 } |
313 | 313 |
314 MojoResult MessagePipe::EnqueueMessageNoLock( | 314 MojoResult MessagePipe::EnqueueMessageNoLock( |
315 unsigned port, | 315 unsigned port, |
316 scoped_ptr<MessageInTransit> message, | 316 scoped_ptr<MessageInTransit> message, |
317 std::vector<DispatcherTransport>* transports) { | 317 std::vector<DispatcherTransport>* transports) { |
318 DCHECK(port == 0 || port == 1); | 318 DCHECK(port == 0 || port == 1); |
319 DCHECK(message); | 319 DCHECK(message); |
320 | 320 |
321 DCHECK_EQ(message->type(), MessageInTransit::kTypeEndpoint); | 321 DCHECK_EQ(message->type(), MessageInTransit::kTypeEndpointClient); |
322 DCHECK(endpoints_[GetPeerPort(port)]); | 322 DCHECK(endpoints_[GetPeerPort(port)]); |
323 | 323 |
324 // The destination port need not be open, unlike the source port. | 324 // The destination port need not be open, unlike the source port. |
325 if (!endpoints_[port]) | 325 if (!endpoints_[port]) |
326 return MOJO_RESULT_FAILED_PRECONDITION; | 326 return MOJO_RESULT_FAILED_PRECONDITION; |
327 | 327 |
328 if (transports) { | 328 if (transports) { |
329 MojoResult result = AttachTransportsNoLock(port, message.get(), transports); | 329 MojoResult result = AttachTransportsNoLock(port, message.get(), transports); |
330 if (result != MOJO_RESULT_OK) | 330 if (result != MOJO_RESULT_OK) |
331 return result; | 331 return result; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 LOG(WARNING) << "Enqueueing null dispatcher"; | 375 LOG(WARNING) << "Enqueueing null dispatcher"; |
376 dispatchers->push_back(nullptr); | 376 dispatchers->push_back(nullptr); |
377 } | 377 } |
378 } | 378 } |
379 message->SetDispatchers(dispatchers.Pass()); | 379 message->SetDispatchers(dispatchers.Pass()); |
380 return MOJO_RESULT_OK; | 380 return MOJO_RESULT_OK; |
381 } | 381 } |
382 | 382 |
383 } // namespace system | 383 } // namespace system |
384 } // namespace mojo | 384 } // namespace mojo |
OLD | NEW |