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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 // too. | 172 // too. |
173 scoped_refptr<MessagePipeDispatcher> rv = | 173 scoped_refptr<MessagePipeDispatcher> rv = |
174 new MessagePipeDispatcher(kDefaultCreateOptions); | 174 new MessagePipeDispatcher(kDefaultCreateOptions); |
175 rv->Init(message_pipe_, port_); | 175 rv->Init(message_pipe_, port_); |
176 message_pipe_ = NULL; | 176 message_pipe_ = NULL; |
177 port_ = kInvalidPort; | 177 port_ = kInvalidPort; |
178 return scoped_refptr<Dispatcher>(rv.get()); | 178 return scoped_refptr<Dispatcher>(rv.get()); |
179 } | 179 } |
180 | 180 |
181 MojoResult MessagePipeDispatcher::WriteMessageImplNoLock( | 181 MojoResult MessagePipeDispatcher::WriteMessageImplNoLock( |
182 const void* bytes, | 182 UserPointer<const void> bytes, |
183 uint32_t num_bytes, | 183 uint32_t num_bytes, |
184 std::vector<DispatcherTransport>* transports, | 184 std::vector<DispatcherTransport>* transports, |
185 MojoWriteMessageFlags flags) { | 185 MojoWriteMessageFlags flags) { |
186 DCHECK(!transports || (transports->size() > 0 && | 186 DCHECK(!transports || (transports->size() > 0 && |
187 transports->size() <= kMaxMessageNumHandles)); | 187 transports->size() <= kMaxMessageNumHandles)); |
188 | 188 |
189 lock().AssertAcquired(); | 189 lock().AssertAcquired(); |
190 | 190 |
191 if (!VerifyUserPointerWithSize<1>(bytes, num_bytes)) | |
192 return MOJO_RESULT_INVALID_ARGUMENT; | |
193 if (num_bytes > kMaxMessageNumBytes) | 191 if (num_bytes > kMaxMessageNumBytes) |
194 return MOJO_RESULT_RESOURCE_EXHAUSTED; | 192 return MOJO_RESULT_RESOURCE_EXHAUSTED; |
195 | 193 |
196 return message_pipe_->WriteMessage(port_, bytes, num_bytes, transports, | 194 return message_pipe_->WriteMessage(port_, bytes, num_bytes, transports, |
197 flags); | 195 flags); |
198 } | 196 } |
199 | 197 |
200 MojoResult MessagePipeDispatcher::ReadMessageImplNoLock( | 198 MojoResult MessagePipeDispatcher::ReadMessageImplNoLock( |
201 UserPointer<void> bytes, | 199 UserPointer<void> bytes, |
202 UserPointer<uint32_t> num_bytes, | 200 UserPointer<uint32_t> num_bytes, |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 | 262 |
265 // MessagePipeDispatcherTransport ---------------------------------------------- | 263 // MessagePipeDispatcherTransport ---------------------------------------------- |
266 | 264 |
267 MessagePipeDispatcherTransport::MessagePipeDispatcherTransport( | 265 MessagePipeDispatcherTransport::MessagePipeDispatcherTransport( |
268 DispatcherTransport transport) : DispatcherTransport(transport) { | 266 DispatcherTransport transport) : DispatcherTransport(transport) { |
269 DCHECK_EQ(message_pipe_dispatcher()->GetType(), Dispatcher::kTypeMessagePipe); | 267 DCHECK_EQ(message_pipe_dispatcher()->GetType(), Dispatcher::kTypeMessagePipe); |
270 } | 268 } |
271 | 269 |
272 } // namespace system | 270 } // namespace system |
273 } // namespace mojo | 271 } // namespace mojo |
OLD | NEW |