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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 const void* elements, |
55 uint32_t* num_bytes, | 55 uint32_t* num_bytes, |
56 MojoWriteDataFlags flags) { | 56 MojoWriteDataFlags flags) { |
57 lock().AssertAcquired(); | 57 lock().AssertAcquired(); |
58 | 58 |
59 if (!VerifyUserPointer<uint32_t>(num_bytes, 1)) | 59 if (!VerifyUserPointer<uint32_t>(num_bytes)) |
60 return MOJO_RESULT_INVALID_ARGUMENT; | 60 return MOJO_RESULT_INVALID_ARGUMENT; |
61 if (!VerifyUserPointer<void>(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 void** buffer, |
70 uint32_t* buffer_num_bytes, | 70 uint32_t* buffer_num_bytes, |
71 MojoWriteDataFlags flags) { | 71 MojoWriteDataFlags flags) { |
72 lock().AssertAcquired(); | 72 lock().AssertAcquired(); |
73 | 73 |
74 if (!VerifyUserPointer<void*>(buffer, 1)) | 74 if (!VerifyUserPointerWithCount<void*>(buffer, 1)) |
75 return MOJO_RESULT_INVALID_ARGUMENT; | 75 return MOJO_RESULT_INVALID_ARGUMENT; |
76 if (!VerifyUserPointer<uint32_t>(buffer_num_bytes, 1)) | 76 if (!VerifyUserPointer<uint32_t>(buffer_num_bytes)) |
77 return MOJO_RESULT_INVALID_ARGUMENT; | 77 return MOJO_RESULT_INVALID_ARGUMENT; |
78 | 78 |
79 return data_pipe_->ProducerBeginWriteData( | 79 return data_pipe_->ProducerBeginWriteData( |
80 buffer, buffer_num_bytes, (flags & MOJO_WRITE_DATA_FLAG_ALL_OR_NONE)); | 80 buffer, buffer_num_bytes, (flags & MOJO_WRITE_DATA_FLAG_ALL_OR_NONE)); |
81 } | 81 } |
82 | 82 |
83 MojoResult DataPipeProducerDispatcher::EndWriteDataImplNoLock( | 83 MojoResult DataPipeProducerDispatcher::EndWriteDataImplNoLock( |
84 uint32_t num_bytes_written) { | 84 uint32_t num_bytes_written) { |
85 lock().AssertAcquired(); | 85 lock().AssertAcquired(); |
86 | 86 |
(...skipping 13 matching lines...) Expand all Loading... |
100 data_pipe_->ProducerRemoveWaiter(waiter); | 100 data_pipe_->ProducerRemoveWaiter(waiter); |
101 } | 101 } |
102 | 102 |
103 bool DataPipeProducerDispatcher::IsBusyNoLock() const { | 103 bool DataPipeProducerDispatcher::IsBusyNoLock() const { |
104 lock().AssertAcquired(); | 104 lock().AssertAcquired(); |
105 return data_pipe_->ProducerIsBusy(); | 105 return data_pipe_->ProducerIsBusy(); |
106 } | 106 } |
107 | 107 |
108 } // namespace system | 108 } // namespace system |
109 } // namespace mojo | 109 } // namespace mojo |
OLD | NEW |