| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 MojoResult MessagePipeDispatcher::WriteMessageImplNoLock( | 143 MojoResult MessagePipeDispatcher::WriteMessageImplNoLock( |
| 144 const void* bytes, | 144 const void* bytes, |
| 145 uint32_t num_bytes, | 145 uint32_t num_bytes, |
| 146 std::vector<DispatcherTransport>* transports, | 146 std::vector<DispatcherTransport>* transports, |
| 147 MojoWriteMessageFlags flags) { | 147 MojoWriteMessageFlags flags) { |
| 148 DCHECK(!transports || (transports->size() > 0 && | 148 DCHECK(!transports || (transports->size() > 0 && |
| 149 transports->size() <= kMaxMessageNumHandles)); | 149 transports->size() <= kMaxMessageNumHandles)); |
| 150 | 150 |
| 151 lock().AssertAcquired(); | 151 lock().AssertAcquired(); |
| 152 | 152 |
| 153 if (!VerifyUserPointerWithSize<1>(bytes, num_bytes)) | 153 if (!VerifyUserPointer<void>(bytes, num_bytes)) |
| 154 return MOJO_RESULT_INVALID_ARGUMENT; | 154 return MOJO_RESULT_INVALID_ARGUMENT; |
| 155 if (num_bytes > kMaxMessageNumBytes) | 155 if (num_bytes > kMaxMessageNumBytes) |
| 156 return MOJO_RESULT_RESOURCE_EXHAUSTED; | 156 return MOJO_RESULT_RESOURCE_EXHAUSTED; |
| 157 | 157 |
| 158 return message_pipe_->WriteMessage(port_, bytes, num_bytes, transports, | 158 return message_pipe_->WriteMessage(port_, bytes, num_bytes, transports, |
| 159 flags); | 159 flags); |
| 160 } | 160 } |
| 161 | 161 |
| 162 MojoResult MessagePipeDispatcher::ReadMessageImplNoLock( | 162 MojoResult MessagePipeDispatcher::ReadMessageImplNoLock( |
| 163 void* bytes, | 163 void* bytes, |
| 164 uint32_t* num_bytes, | 164 uint32_t* num_bytes, |
| 165 DispatcherVector* dispatchers, | 165 DispatcherVector* dispatchers, |
| 166 uint32_t* num_dispatchers, | 166 uint32_t* num_dispatchers, |
| 167 MojoReadMessageFlags flags) { | 167 MojoReadMessageFlags flags) { |
| 168 lock().AssertAcquired(); | 168 lock().AssertAcquired(); |
| 169 | 169 |
| 170 if (num_bytes) { | 170 if (num_bytes) { |
| 171 if (!VerifyUserPointer<uint32_t>(num_bytes)) | 171 if (!VerifyUserPointer<uint32_t>(num_bytes, 1)) |
| 172 return MOJO_RESULT_INVALID_ARGUMENT; | 172 return MOJO_RESULT_INVALID_ARGUMENT; |
| 173 if (!VerifyUserPointerWithSize<1>(bytes, *num_bytes)) | 173 if (!VerifyUserPointer<void>(bytes, *num_bytes)) |
| 174 return MOJO_RESULT_INVALID_ARGUMENT; | 174 return MOJO_RESULT_INVALID_ARGUMENT; |
| 175 } | 175 } |
| 176 | 176 |
| 177 return message_pipe_->ReadMessage(port_, bytes, num_bytes, dispatchers, | 177 return message_pipe_->ReadMessage(port_, bytes, num_bytes, dispatchers, |
| 178 num_dispatchers, flags); | 178 num_dispatchers, flags); |
| 179 } | 179 } |
| 180 | 180 |
| 181 MojoResult MessagePipeDispatcher::AddWaiterImplNoLock(Waiter* waiter, | 181 MojoResult MessagePipeDispatcher::AddWaiterImplNoLock(Waiter* waiter, |
| 182 MojoWaitFlags flags, | 182 MojoWaitFlags flags, |
| 183 MojoResult wake_result) { | 183 MojoResult wake_result) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 | 234 |
| 235 // MessagePipeDispatcherTransport ---------------------------------------------- | 235 // MessagePipeDispatcherTransport ---------------------------------------------- |
| 236 | 236 |
| 237 MessagePipeDispatcherTransport::MessagePipeDispatcherTransport( | 237 MessagePipeDispatcherTransport::MessagePipeDispatcherTransport( |
| 238 DispatcherTransport transport) : DispatcherTransport(transport) { | 238 DispatcherTransport transport) : DispatcherTransport(transport) { |
| 239 DCHECK_EQ(message_pipe_dispatcher()->GetType(), Dispatcher::kTypeMessagePipe); | 239 DCHECK_EQ(message_pipe_dispatcher()->GetType(), Dispatcher::kTypeMessagePipe); |
| 240 } | 240 } |
| 241 | 241 |
| 242 } // namespace system | 242 } // namespace system |
| 243 } // namespace mojo | 243 } // namespace mojo |
| OLD | NEW |