| 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_producer_dispatcher.h" | 5 #include "mojo/system/data_pipe_producer_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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 lock().AssertAcquired(); | 44 lock().AssertAcquired(); |
| 45 | 45 |
| 46 scoped_refptr<DataPipeProducerDispatcher> rv = | 46 scoped_refptr<DataPipeProducerDispatcher> rv = |
| 47 new DataPipeProducerDispatcher(); | 47 new DataPipeProducerDispatcher(); |
| 48 rv->Init(data_pipe_); | 48 rv->Init(data_pipe_); |
| 49 data_pipe_ = NULL; | 49 data_pipe_ = NULL; |
| 50 return scoped_refptr<Dispatcher>(rv.get()); | 50 return scoped_refptr<Dispatcher>(rv.get()); |
| 51 } | 51 } |
| 52 | 52 |
| 53 MojoResult DataPipeProducerDispatcher::WriteDataImplNoLock( | 53 MojoResult DataPipeProducerDispatcher::WriteDataImplNoLock( |
| 54 const void* elements, | 54 UserPointer<const void> elements, |
| 55 uint32_t* num_bytes, | 55 UserPointer<uint32_t> num_bytes, |
| 56 MojoWriteDataFlags flags) { | 56 MojoWriteDataFlags flags) { |
| 57 lock().AssertAcquired(); | 57 lock().AssertAcquired(); |
| 58 | |
| 59 if (!VerifyUserPointer<uint32_t>(num_bytes)) | |
| 60 return MOJO_RESULT_INVALID_ARGUMENT; | |
| 61 if (!VerifyUserPointerWithSize<1>(elements, *num_bytes)) | |
| 62 return MOJO_RESULT_INVALID_ARGUMENT; | |
| 63 | |
| 64 return data_pipe_->ProducerWriteData( | 58 return data_pipe_->ProducerWriteData( |
| 65 elements, num_bytes, (flags & MOJO_WRITE_DATA_FLAG_ALL_OR_NONE)); | 59 elements, num_bytes, (flags & MOJO_WRITE_DATA_FLAG_ALL_OR_NONE)); |
| 66 } | 60 } |
| 67 | 61 |
| 68 MojoResult DataPipeProducerDispatcher::BeginWriteDataImplNoLock( | 62 MojoResult DataPipeProducerDispatcher::BeginWriteDataImplNoLock( |
| 69 UserPointer<void*> buffer, | 63 UserPointer<void*> buffer, |
| 70 UserPointer<uint32_t> buffer_num_bytes, | 64 UserPointer<uint32_t> buffer_num_bytes, |
| 71 MojoWriteDataFlags flags) { | 65 MojoWriteDataFlags flags) { |
| 72 lock().AssertAcquired(); | 66 lock().AssertAcquired(); |
| 73 | 67 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 95 data_pipe_->ProducerRemoveWaiter(waiter); | 89 data_pipe_->ProducerRemoveWaiter(waiter); |
| 96 } | 90 } |
| 97 | 91 |
| 98 bool DataPipeProducerDispatcher::IsBusyNoLock() const { | 92 bool DataPipeProducerDispatcher::IsBusyNoLock() const { |
| 99 lock().AssertAcquired(); | 93 lock().AssertAcquired(); |
| 100 return data_pipe_->ProducerIsBusy(); | 94 return data_pipe_->ProducerIsBusy(); |
| 101 } | 95 } |
| 102 | 96 |
| 103 } // namespace system | 97 } // namespace system |
| 104 } // namespace mojo | 98 } // namespace mojo |
| OLD | NEW |