| 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_dispatcher.h" | 5 #include "mojo/system/message_pipe_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "mojo/system/channel.h" | 8 #include "mojo/system/channel.h" |
| 9 #include "mojo/system/constants.h" | 9 #include "mojo/system/constants.h" |
| 10 #include "mojo/system/local_message_pipe_endpoint.h" | 10 #include "mojo/system/local_message_pipe_endpoint.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 if (!VerifyUserPointerWithSize<1>(bytes, num_bytes)) | 191 if (!VerifyUserPointerWithSize<1>(bytes, num_bytes)) |
| 192 return MOJO_RESULT_INVALID_ARGUMENT; | 192 return MOJO_RESULT_INVALID_ARGUMENT; |
| 193 if (num_bytes > kMaxMessageNumBytes) | 193 if (num_bytes > kMaxMessageNumBytes) |
| 194 return MOJO_RESULT_RESOURCE_EXHAUSTED; | 194 return MOJO_RESULT_RESOURCE_EXHAUSTED; |
| 195 | 195 |
| 196 return message_pipe_->WriteMessage(port_, bytes, num_bytes, transports, | 196 return message_pipe_->WriteMessage(port_, bytes, num_bytes, transports, |
| 197 flags); | 197 flags); |
| 198 } | 198 } |
| 199 | 199 |
| 200 MojoResult MessagePipeDispatcher::ReadMessageImplNoLock( | 200 MojoResult MessagePipeDispatcher::ReadMessageImplNoLock( |
| 201 void* bytes, | 201 UserPointer<void> bytes, |
| 202 uint32_t* num_bytes, | 202 UserPointer<uint32_t> num_bytes, |
| 203 DispatcherVector* dispatchers, | 203 DispatcherVector* dispatchers, |
| 204 uint32_t* num_dispatchers, | 204 uint32_t* num_dispatchers, |
| 205 MojoReadMessageFlags flags) { | 205 MojoReadMessageFlags flags) { |
| 206 lock().AssertAcquired(); | 206 lock().AssertAcquired(); |
| 207 | |
| 208 if (num_bytes) { | |
| 209 if (!VerifyUserPointer<uint32_t>(num_bytes)) | |
| 210 return MOJO_RESULT_INVALID_ARGUMENT; | |
| 211 if (!VerifyUserPointerWithSize<1>(bytes, *num_bytes)) | |
| 212 return MOJO_RESULT_INVALID_ARGUMENT; | |
| 213 } | |
| 214 | |
| 215 return message_pipe_->ReadMessage(port_, bytes, num_bytes, dispatchers, | 207 return message_pipe_->ReadMessage(port_, bytes, num_bytes, dispatchers, |
| 216 num_dispatchers, flags); | 208 num_dispatchers, flags); |
| 217 } | 209 } |
| 218 | 210 |
| 219 MojoResult MessagePipeDispatcher::AddWaiterImplNoLock(Waiter* waiter, | 211 MojoResult MessagePipeDispatcher::AddWaiterImplNoLock(Waiter* waiter, |
| 220 MojoHandleSignals signals, | 212 MojoHandleSignals signals, |
| 221 uint32_t context) { | 213 uint32_t context) { |
| 222 lock().AssertAcquired(); | 214 lock().AssertAcquired(); |
| 223 return message_pipe_->AddWaiter(port_, waiter, signals, context); | 215 return message_pipe_->AddWaiter(port_, waiter, signals, context); |
| 224 } | 216 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 | 264 |
| 273 // MessagePipeDispatcherTransport ---------------------------------------------- | 265 // MessagePipeDispatcherTransport ---------------------------------------------- |
| 274 | 266 |
| 275 MessagePipeDispatcherTransport::MessagePipeDispatcherTransport( | 267 MessagePipeDispatcherTransport::MessagePipeDispatcherTransport( |
| 276 DispatcherTransport transport) : DispatcherTransport(transport) { | 268 DispatcherTransport transport) : DispatcherTransport(transport) { |
| 277 DCHECK_EQ(message_pipe_dispatcher()->GetType(), Dispatcher::kTypeMessagePipe); | 269 DCHECK_EQ(message_pipe_dispatcher()->GetType(), Dispatcher::kTypeMessagePipe); |
| 278 } | 270 } |
| 279 | 271 |
| 280 } // namespace system | 272 } // namespace system |
| 281 } // namespace mojo | 273 } // namespace mojo |
| OLD | NEW |