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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 if (!VerifyUserPointer<uint32_t>(num_bytes)) | 59 if (!VerifyUserPointer<uint32_t>(num_bytes)) |
60 return MOJO_RESULT_INVALID_ARGUMENT; | 60 return MOJO_RESULT_INVALID_ARGUMENT; |
61 if (!VerifyUserPointerWithSize<1>(elements, *num_bytes)) | 61 if (!VerifyUserPointerWithSize<1>(elements, *num_bytes)) |
62 return MOJO_RESULT_INVALID_ARGUMENT; | 62 return MOJO_RESULT_INVALID_ARGUMENT; |
63 | 63 |
64 return data_pipe_->ProducerWriteData( | 64 return data_pipe_->ProducerWriteData( |
65 elements, num_bytes, (flags & MOJO_WRITE_DATA_FLAG_ALL_OR_NONE)); | 65 elements, num_bytes, (flags & MOJO_WRITE_DATA_FLAG_ALL_OR_NONE)); |
66 } | 66 } |
67 | 67 |
68 MojoResult DataPipeProducerDispatcher::BeginWriteDataImplNoLock( | 68 MojoResult DataPipeProducerDispatcher::BeginWriteDataImplNoLock( |
69 void** buffer, | 69 UserPointer<void*> buffer, |
70 uint32_t* buffer_num_bytes, | 70 UserPointer<uint32_t> buffer_num_bytes, |
71 MojoWriteDataFlags flags) { | 71 MojoWriteDataFlags flags) { |
72 lock().AssertAcquired(); | 72 lock().AssertAcquired(); |
73 | 73 |
74 if (!VerifyUserPointerWithCount<void*>(buffer, 1)) | |
75 return MOJO_RESULT_INVALID_ARGUMENT; | |
76 if (!VerifyUserPointer<uint32_t>(buffer_num_bytes)) | |
77 return MOJO_RESULT_INVALID_ARGUMENT; | |
78 | |
79 return data_pipe_->ProducerBeginWriteData( | 74 return data_pipe_->ProducerBeginWriteData( |
80 buffer, buffer_num_bytes, (flags & MOJO_WRITE_DATA_FLAG_ALL_OR_NONE)); | 75 buffer, buffer_num_bytes, (flags & MOJO_WRITE_DATA_FLAG_ALL_OR_NONE)); |
81 } | 76 } |
82 | 77 |
83 MojoResult DataPipeProducerDispatcher::EndWriteDataImplNoLock( | 78 MojoResult DataPipeProducerDispatcher::EndWriteDataImplNoLock( |
84 uint32_t num_bytes_written) { | 79 uint32_t num_bytes_written) { |
85 lock().AssertAcquired(); | 80 lock().AssertAcquired(); |
86 | 81 |
87 return data_pipe_->ProducerEndWriteData(num_bytes_written); | 82 return data_pipe_->ProducerEndWriteData(num_bytes_written); |
88 } | 83 } |
(...skipping 11 matching lines...) Expand all Loading... |
100 data_pipe_->ProducerRemoveWaiter(waiter); | 95 data_pipe_->ProducerRemoveWaiter(waiter); |
101 } | 96 } |
102 | 97 |
103 bool DataPipeProducerDispatcher::IsBusyNoLock() const { | 98 bool DataPipeProducerDispatcher::IsBusyNoLock() const { |
104 lock().AssertAcquired(); | 99 lock().AssertAcquired(); |
105 return data_pipe_->ProducerIsBusy(); | 100 return data_pipe_->ProducerIsBusy(); |
106 } | 101 } |
107 | 102 |
108 } // namespace system | 103 } // namespace system |
109 } // namespace mojo | 104 } // namespace mojo |
OLD | NEW |