| 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/data_pipe_consumer_dispatcher.h" | 5 #include "mojo/system/data_pipe_consumer_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "mojo/system/data_pipe.h" | 8 #include "mojo/system/data_pipe.h" |
| 9 #include "mojo/system/memory.h" | 9 #include "mojo/system/memory.h" |
| 10 | 10 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 76 |
| 77 // Only verify |elements| if we're neither discarding nor querying. | 77 // Only verify |elements| if we're neither discarding nor querying. |
| 78 if (!VerifyUserPointerWithSize<1>(elements, *num_bytes)) | 78 if (!VerifyUserPointerWithSize<1>(elements, *num_bytes)) |
| 79 return MOJO_RESULT_INVALID_ARGUMENT; | 79 return MOJO_RESULT_INVALID_ARGUMENT; |
| 80 | 80 |
| 81 return data_pipe_->ConsumerReadData( | 81 return data_pipe_->ConsumerReadData( |
| 82 elements, num_bytes, (flags & MOJO_READ_DATA_FLAG_ALL_OR_NONE)); | 82 elements, num_bytes, (flags & MOJO_READ_DATA_FLAG_ALL_OR_NONE)); |
| 83 } | 83 } |
| 84 | 84 |
| 85 MojoResult DataPipeConsumerDispatcher::BeginReadDataImplNoLock( | 85 MojoResult DataPipeConsumerDispatcher::BeginReadDataImplNoLock( |
| 86 const void** buffer, | 86 UserPointer<const void*> buffer, |
| 87 uint32_t* buffer_num_bytes, | 87 UserPointer<uint32_t> buffer_num_bytes, |
| 88 MojoReadDataFlags flags) { | 88 MojoReadDataFlags flags) { |
| 89 lock().AssertAcquired(); | 89 lock().AssertAcquired(); |
| 90 | 90 |
| 91 if (!VerifyUserPointerWithCount<const void*>(buffer, 1)) | |
| 92 return MOJO_RESULT_INVALID_ARGUMENT; | |
| 93 if (!VerifyUserPointer<uint32_t>(buffer_num_bytes)) | |
| 94 return MOJO_RESULT_INVALID_ARGUMENT; | |
| 95 // These flags may not be used in two-phase mode. | 91 // These flags may not be used in two-phase mode. |
| 96 if ((flags & MOJO_READ_DATA_FLAG_DISCARD) || | 92 if ((flags & MOJO_READ_DATA_FLAG_DISCARD) || |
| 97 (flags & MOJO_READ_DATA_FLAG_QUERY)) | 93 (flags & MOJO_READ_DATA_FLAG_QUERY)) |
| 98 return MOJO_RESULT_INVALID_ARGUMENT; | 94 return MOJO_RESULT_INVALID_ARGUMENT; |
| 99 | 95 |
| 100 return data_pipe_->ConsumerBeginReadData( | 96 return data_pipe_->ConsumerBeginReadData( |
| 101 buffer, buffer_num_bytes, (flags & MOJO_READ_DATA_FLAG_ALL_OR_NONE)); | 97 buffer, buffer_num_bytes, (flags & MOJO_READ_DATA_FLAG_ALL_OR_NONE)); |
| 102 } | 98 } |
| 103 | 99 |
| 104 MojoResult DataPipeConsumerDispatcher::EndReadDataImplNoLock( | 100 MojoResult DataPipeConsumerDispatcher::EndReadDataImplNoLock( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 121 data_pipe_->ConsumerRemoveWaiter(waiter); | 117 data_pipe_->ConsumerRemoveWaiter(waiter); |
| 122 } | 118 } |
| 123 | 119 |
| 124 bool DataPipeConsumerDispatcher::IsBusyNoLock() const { | 120 bool DataPipeConsumerDispatcher::IsBusyNoLock() const { |
| 125 lock().AssertAcquired(); | 121 lock().AssertAcquired(); |
| 126 return data_pipe_->ConsumerIsBusy(); | 122 return data_pipe_->ConsumerIsBusy(); |
| 127 } | 123 } |
| 128 | 124 |
| 129 } // namespace system | 125 } // namespace system |
| 130 } // namespace mojo | 126 } // namespace mojo |
| OLD | NEW |