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/dispatcher.h" | 5 #include "mojo/system/dispatcher.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "mojo/system/constants.h" | 8 #include "mojo/system/constants.h" |
9 #include "mojo/system/message_pipe_dispatcher.h" | 9 #include "mojo/system/message_pipe_dispatcher.h" |
10 #include "mojo/system/platform_handle_dispatcher.h" | 10 #include "mojo/system/platform_handle_dispatcher.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 DCHECK(!transports || (transports->size() > 0 && | 113 DCHECK(!transports || (transports->size() > 0 && |
114 transports->size() < kMaxMessageNumHandles)); | 114 transports->size() < kMaxMessageNumHandles)); |
115 | 115 |
116 base::AutoLock locker(lock_); | 116 base::AutoLock locker(lock_); |
117 if (is_closed_) | 117 if (is_closed_) |
118 return MOJO_RESULT_INVALID_ARGUMENT; | 118 return MOJO_RESULT_INVALID_ARGUMENT; |
119 | 119 |
120 return WriteMessageImplNoLock(bytes, num_bytes, transports, flags); | 120 return WriteMessageImplNoLock(bytes, num_bytes, transports, flags); |
121 } | 121 } |
122 | 122 |
123 MojoResult Dispatcher::ReadMessage(void* bytes, | 123 MojoResult Dispatcher::ReadMessage(UserPointer<void> bytes, |
124 uint32_t* num_bytes, | 124 UserPointer<uint32_t> num_bytes, |
125 DispatcherVector* dispatchers, | 125 DispatcherVector* dispatchers, |
126 uint32_t* num_dispatchers, | 126 uint32_t* num_dispatchers, |
127 MojoReadMessageFlags flags) { | 127 MojoReadMessageFlags flags) { |
128 DCHECK(!num_dispatchers || *num_dispatchers == 0 || | 128 DCHECK(!num_dispatchers || *num_dispatchers == 0 || |
129 (dispatchers && dispatchers->empty())); | 129 (dispatchers && dispatchers->empty())); |
130 | 130 |
131 base::AutoLock locker(lock_); | 131 base::AutoLock locker(lock_); |
132 if (is_closed_) | 132 if (is_closed_) |
133 return MOJO_RESULT_INVALID_ARGUMENT; | 133 return MOJO_RESULT_INVALID_ARGUMENT; |
134 | 134 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 const void* /*bytes*/, | 258 const void* /*bytes*/, |
259 uint32_t /*num_bytes*/, | 259 uint32_t /*num_bytes*/, |
260 std::vector<DispatcherTransport>* /*transports*/, | 260 std::vector<DispatcherTransport>* /*transports*/, |
261 MojoWriteMessageFlags /*flags*/) { | 261 MojoWriteMessageFlags /*flags*/) { |
262 lock_.AssertAcquired(); | 262 lock_.AssertAcquired(); |
263 DCHECK(!is_closed_); | 263 DCHECK(!is_closed_); |
264 // By default, not supported. Only needed for message pipe dispatchers. | 264 // By default, not supported. Only needed for message pipe dispatchers. |
265 return MOJO_RESULT_INVALID_ARGUMENT; | 265 return MOJO_RESULT_INVALID_ARGUMENT; |
266 } | 266 } |
267 | 267 |
268 MojoResult Dispatcher::ReadMessageImplNoLock(void* /*bytes*/, | 268 MojoResult Dispatcher::ReadMessageImplNoLock( |
269 uint32_t* /*num_bytes*/, | 269 UserPointer<void> /*bytes*/, |
270 DispatcherVector* /*dispatchers*/, | 270 UserPointer<uint32_t> /*num_bytes*/, |
271 uint32_t* /*num_dispatchers*/, | 271 DispatcherVector* /*dispatchers*/, |
272 MojoReadMessageFlags /*flags*/) { | 272 uint32_t* /*num_dispatchers*/, |
| 273 MojoReadMessageFlags /*flags*/) { |
273 lock_.AssertAcquired(); | 274 lock_.AssertAcquired(); |
274 DCHECK(!is_closed_); | 275 DCHECK(!is_closed_); |
275 // By default, not supported. Only needed for message pipe dispatchers. | 276 // By default, not supported. Only needed for message pipe dispatchers. |
276 return MOJO_RESULT_INVALID_ARGUMENT; | 277 return MOJO_RESULT_INVALID_ARGUMENT; |
277 } | 278 } |
278 | 279 |
279 MojoResult Dispatcher::WriteDataImplNoLock(const void* /*elements*/, | 280 MojoResult Dispatcher::WriteDataImplNoLock(const void* /*elements*/, |
280 uint32_t* /*num_bytes*/, | 281 uint32_t* /*num_bytes*/, |
281 MojoWriteDataFlags /*flags*/) { | 282 MojoWriteDataFlags /*flags*/) { |
282 lock_.AssertAcquired(); | 283 lock_.AssertAcquired(); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 // DispatcherTransport --------------------------------------------------------- | 455 // DispatcherTransport --------------------------------------------------------- |
455 | 456 |
456 void DispatcherTransport::End() { | 457 void DispatcherTransport::End() { |
457 DCHECK(dispatcher_); | 458 DCHECK(dispatcher_); |
458 dispatcher_->lock_.Release(); | 459 dispatcher_->lock_.Release(); |
459 dispatcher_ = NULL; | 460 dispatcher_ = NULL; |
460 } | 461 } |
461 | 462 |
462 } // namespace system | 463 } // namespace system |
463 } // namespace mojo | 464 } // namespace mojo |
OLD | NEW |