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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
135 return ReadMessageImplNoLock(bytes, num_bytes, dispatchers, num_dispatchers, | 135 return ReadMessageImplNoLock(bytes, num_bytes, dispatchers, num_dispatchers, |
136 flags); | 136 flags); |
137 } | 137 } |
138 | 138 |
139 MojoResult Dispatcher::WriteData(const void* elements, | 139 MojoResult Dispatcher::WriteData(UserPointer<const void> elements, |
140 uint32_t* num_bytes, | 140 UserPointer<uint32_t> num_bytes, |
141 MojoWriteDataFlags flags) { | 141 MojoWriteDataFlags flags) { |
142 base::AutoLock locker(lock_); | 142 base::AutoLock locker(lock_); |
143 if (is_closed_) | 143 if (is_closed_) |
144 return MOJO_RESULT_INVALID_ARGUMENT; | 144 return MOJO_RESULT_INVALID_ARGUMENT; |
145 | 145 |
146 return WriteDataImplNoLock(elements, num_bytes, flags); | 146 return WriteDataImplNoLock(elements, num_bytes, flags); |
147 } | 147 } |
148 | 148 |
149 MojoResult Dispatcher::BeginWriteData(UserPointer<void*> buffer, | 149 MojoResult Dispatcher::BeginWriteData(UserPointer<void*> buffer, |
150 UserPointer<uint32_t> buffer_num_bytes, | 150 UserPointer<uint32_t> buffer_num_bytes, |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 UserPointer<uint32_t> /*num_bytes*/, | 270 UserPointer<uint32_t> /*num_bytes*/, |
271 DispatcherVector* /*dispatchers*/, | 271 DispatcherVector* /*dispatchers*/, |
272 uint32_t* /*num_dispatchers*/, | 272 uint32_t* /*num_dispatchers*/, |
273 MojoReadMessageFlags /*flags*/) { | 273 MojoReadMessageFlags /*flags*/) { |
274 lock_.AssertAcquired(); | 274 lock_.AssertAcquired(); |
275 DCHECK(!is_closed_); | 275 DCHECK(!is_closed_); |
276 // By default, not supported. Only needed for message pipe dispatchers. | 276 // By default, not supported. Only needed for message pipe dispatchers. |
277 return MOJO_RESULT_INVALID_ARGUMENT; | 277 return MOJO_RESULT_INVALID_ARGUMENT; |
278 } | 278 } |
279 | 279 |
280 MojoResult Dispatcher::WriteDataImplNoLock(const void* /*elements*/, | 280 MojoResult Dispatcher::WriteDataImplNoLock(UserPointer<const void> /*elements*/, |
281 uint32_t* /*num_bytes*/, | 281 UserPointer<uint32_t> /*num_bytes*/, |
282 MojoWriteDataFlags /*flags*/) { | 282 MojoWriteDataFlags /*flags*/) { |
283 lock_.AssertAcquired(); | 283 lock_.AssertAcquired(); |
284 DCHECK(!is_closed_); | 284 DCHECK(!is_closed_); |
285 // By default, not supported. Only needed for data pipe dispatchers. | 285 // By default, not supported. Only needed for data pipe dispatchers. |
286 return MOJO_RESULT_INVALID_ARGUMENT; | 286 return MOJO_RESULT_INVALID_ARGUMENT; |
287 } | 287 } |
288 | 288 |
289 MojoResult Dispatcher::BeginWriteDataImplNoLock( | 289 MojoResult Dispatcher::BeginWriteDataImplNoLock( |
290 UserPointer<void*> /*buffer*/, | 290 UserPointer<void*> /*buffer*/, |
291 UserPointer<uint32_t> /*buffer_num_bytes*/, | 291 UserPointer<uint32_t> /*buffer_num_bytes*/, |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 // DispatcherTransport --------------------------------------------------------- | 455 // DispatcherTransport --------------------------------------------------------- |
456 | 456 |
457 void DispatcherTransport::End() { | 457 void DispatcherTransport::End() { |
458 DCHECK(dispatcher_); | 458 DCHECK(dispatcher_); |
459 dispatcher_->lock_.Release(); | 459 dispatcher_->lock_.Release(); |
460 dispatcher_ = NULL; | 460 dispatcher_ = NULL; |
461 } | 461 } |
462 | 462 |
463 } // namespace system | 463 } // namespace system |
464 } // namespace mojo | 464 } // namespace mojo |
OLD | NEW |