| 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 | 10 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 DCHECK(!transports || (transports->size() > 0 && | 101 DCHECK(!transports || (transports->size() > 0 && |
| 102 transports->size() < kMaxMessageNumHandles)); | 102 transports->size() < kMaxMessageNumHandles)); |
| 103 | 103 |
| 104 base::AutoLock locker(lock_); | 104 base::AutoLock locker(lock_); |
| 105 if (is_closed_) | 105 if (is_closed_) |
| 106 return MOJO_RESULT_INVALID_ARGUMENT; | 106 return MOJO_RESULT_INVALID_ARGUMENT; |
| 107 | 107 |
| 108 return WriteMessageImplNoLock(bytes, num_bytes, transports, flags); | 108 return WriteMessageImplNoLock(bytes, num_bytes, transports, flags); |
| 109 } | 109 } |
| 110 | 110 |
| 111 MojoResult Dispatcher::ReadMessage( | 111 MojoResult Dispatcher::ReadMessage(void* bytes, |
| 112 void* bytes, | 112 uint32_t* num_bytes, |
| 113 uint32_t* num_bytes, | 113 DispatcherVector* dispatchers, |
| 114 std::vector<scoped_refptr<Dispatcher> >* dispatchers, | 114 uint32_t* num_dispatchers, |
| 115 uint32_t* num_dispatchers, | |
| 116 MojoReadMessageFlags flags) { | 115 MojoReadMessageFlags flags) { |
| 117 DCHECK(!num_dispatchers || *num_dispatchers == 0 || | 116 DCHECK(!num_dispatchers || *num_dispatchers == 0 || |
| 118 (dispatchers && dispatchers->empty())); | 117 (dispatchers && dispatchers->empty())); |
| 119 | 118 |
| 120 base::AutoLock locker(lock_); | 119 base::AutoLock locker(lock_); |
| 121 if (is_closed_) | 120 if (is_closed_) |
| 122 return MOJO_RESULT_INVALID_ARGUMENT; | 121 return MOJO_RESULT_INVALID_ARGUMENT; |
| 123 | 122 |
| 124 return ReadMessageImplNoLock(bytes, num_bytes, dispatchers, num_dispatchers, | 123 return ReadMessageImplNoLock(bytes, num_bytes, dispatchers, num_dispatchers, |
| 125 flags); | 124 flags); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 const void* /*bytes*/, | 248 const void* /*bytes*/, |
| 250 uint32_t /*num_bytes*/, | 249 uint32_t /*num_bytes*/, |
| 251 std::vector<DispatcherTransport>* /*transports*/, | 250 std::vector<DispatcherTransport>* /*transports*/, |
| 252 MojoWriteMessageFlags /*flags*/) { | 251 MojoWriteMessageFlags /*flags*/) { |
| 253 lock_.AssertAcquired(); | 252 lock_.AssertAcquired(); |
| 254 DCHECK(!is_closed_); | 253 DCHECK(!is_closed_); |
| 255 // By default, not supported. Only needed for message pipe dispatchers. | 254 // By default, not supported. Only needed for message pipe dispatchers. |
| 256 return MOJO_RESULT_INVALID_ARGUMENT; | 255 return MOJO_RESULT_INVALID_ARGUMENT; |
| 257 } | 256 } |
| 258 | 257 |
| 259 MojoResult Dispatcher::ReadMessageImplNoLock( | 258 MojoResult Dispatcher::ReadMessageImplNoLock(void* /*bytes*/, |
| 260 void* /*bytes*/, | 259 uint32_t* /*num_bytes*/, |
| 261 uint32_t* /*num_bytes*/, | 260 DispatcherVector* /*dispatchers*/, |
| 262 std::vector<scoped_refptr<Dispatcher> >* /*dispatchers*/, | 261 uint32_t* /*num_dispatchers*/, |
| 263 uint32_t* /*num_dispatchers*/, | 262 MojoReadMessageFlags /*flags*/) { |
| 264 MojoReadMessageFlags /*flags*/) { | |
| 265 lock_.AssertAcquired(); | 263 lock_.AssertAcquired(); |
| 266 DCHECK(!is_closed_); | 264 DCHECK(!is_closed_); |
| 267 // By default, not supported. Only needed for message pipe dispatchers. | 265 // By default, not supported. Only needed for message pipe dispatchers. |
| 268 return MOJO_RESULT_INVALID_ARGUMENT; | 266 return MOJO_RESULT_INVALID_ARGUMENT; |
| 269 } | 267 } |
| 270 | 268 |
| 271 MojoResult Dispatcher::WriteDataImplNoLock(const void* /*elements*/, | 269 MojoResult Dispatcher::WriteDataImplNoLock(const void* /*elements*/, |
| 272 uint32_t* /*num_bytes*/, | 270 uint32_t* /*num_bytes*/, |
| 273 MojoWriteDataFlags /*flags*/) { | 271 MojoWriteDataFlags /*flags*/) { |
| 274 lock_.AssertAcquired(); | 272 lock_.AssertAcquired(); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 // DispatcherTransport --------------------------------------------------------- | 442 // DispatcherTransport --------------------------------------------------------- |
| 445 | 443 |
| 446 void DispatcherTransport::End() { | 444 void DispatcherTransport::End() { |
| 447 DCHECK(dispatcher_); | 445 DCHECK(dispatcher_); |
| 448 dispatcher_->lock_.Release(); | 446 dispatcher_->lock_.Release(); |
| 449 dispatcher_ = NULL; | 447 dispatcher_ = NULL; |
| 450 } | 448 } |
| 451 | 449 |
| 452 } // namespace system | 450 } // namespace system |
| 453 } // namespace mojo | 451 } // namespace mojo |
| OLD | NEW |