| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 MojoResult Dispatcher::WriteData(const void* elements, | 139 MojoResult Dispatcher::WriteData(const void* elements, |
| 140 uint32_t* num_bytes, | 140 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(void** buffer, | 149 MojoResult Dispatcher::BeginWriteData(UserPointer<void*> buffer, |
| 150 uint32_t* buffer_num_bytes, | 150 UserPointer<uint32_t> buffer_num_bytes, |
| 151 MojoWriteDataFlags flags) { | 151 MojoWriteDataFlags flags) { |
| 152 base::AutoLock locker(lock_); | 152 base::AutoLock locker(lock_); |
| 153 if (is_closed_) | 153 if (is_closed_) |
| 154 return MOJO_RESULT_INVALID_ARGUMENT; | 154 return MOJO_RESULT_INVALID_ARGUMENT; |
| 155 | 155 |
| 156 return BeginWriteDataImplNoLock(buffer, buffer_num_bytes, flags); | 156 return BeginWriteDataImplNoLock(buffer, buffer_num_bytes, flags); |
| 157 } | 157 } |
| 158 | 158 |
| 159 MojoResult Dispatcher::EndWriteData(uint32_t num_bytes_written) { | 159 MojoResult Dispatcher::EndWriteData(uint32_t num_bytes_written) { |
| 160 base::AutoLock locker(lock_); | 160 base::AutoLock locker(lock_); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 | 278 |
| 279 MojoResult Dispatcher::WriteDataImplNoLock(const void* /*elements*/, | 279 MojoResult Dispatcher::WriteDataImplNoLock(const void* /*elements*/, |
| 280 uint32_t* /*num_bytes*/, | 280 uint32_t* /*num_bytes*/, |
| 281 MojoWriteDataFlags /*flags*/) { | 281 MojoWriteDataFlags /*flags*/) { |
| 282 lock_.AssertAcquired(); | 282 lock_.AssertAcquired(); |
| 283 DCHECK(!is_closed_); | 283 DCHECK(!is_closed_); |
| 284 // By default, not supported. Only needed for data pipe dispatchers. | 284 // By default, not supported. Only needed for data pipe dispatchers. |
| 285 return MOJO_RESULT_INVALID_ARGUMENT; | 285 return MOJO_RESULT_INVALID_ARGUMENT; |
| 286 } | 286 } |
| 287 | 287 |
| 288 MojoResult Dispatcher::BeginWriteDataImplNoLock(void** /*buffer*/, | 288 MojoResult Dispatcher::BeginWriteDataImplNoLock( |
| 289 uint32_t* /*buffer_num_bytes*/, | 289 UserPointer<void*> /*buffer*/, |
| 290 MojoWriteDataFlags /*flags*/) { | 290 UserPointer<uint32_t> /*buffer_num_bytes*/, |
| 291 MojoWriteDataFlags /*flags*/) { |
| 291 lock_.AssertAcquired(); | 292 lock_.AssertAcquired(); |
| 292 DCHECK(!is_closed_); | 293 DCHECK(!is_closed_); |
| 293 // By default, not supported. Only needed for data pipe dispatchers. | 294 // By default, not supported. Only needed for data pipe dispatchers. |
| 294 return MOJO_RESULT_INVALID_ARGUMENT; | 295 return MOJO_RESULT_INVALID_ARGUMENT; |
| 295 } | 296 } |
| 296 | 297 |
| 297 MojoResult Dispatcher::EndWriteDataImplNoLock(uint32_t /*num_bytes_written*/) { | 298 MojoResult Dispatcher::EndWriteDataImplNoLock(uint32_t /*num_bytes_written*/) { |
| 298 lock_.AssertAcquired(); | 299 lock_.AssertAcquired(); |
| 299 DCHECK(!is_closed_); | 300 DCHECK(!is_closed_); |
| 300 // By default, not supported. Only needed for data pipe dispatchers. | 301 // By default, not supported. Only needed for data pipe dispatchers. |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 // DispatcherTransport --------------------------------------------------------- | 453 // DispatcherTransport --------------------------------------------------------- |
| 453 | 454 |
| 454 void DispatcherTransport::End() { | 455 void DispatcherTransport::End() { |
| 455 DCHECK(dispatcher_); | 456 DCHECK(dispatcher_); |
| 456 dispatcher_->lock_.Release(); | 457 dispatcher_->lock_.Release(); |
| 457 dispatcher_ = NULL; | 458 dispatcher_ = NULL; |
| 458 } | 459 } |
| 459 | 460 |
| 460 } // namespace system | 461 } // namespace system |
| 461 } // namespace mojo | 462 } // namespace mojo |
| OLD | NEW |