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/edk/system/data_pipe_consumer_dispatcher.h" | 5 #include "mojo/edk/system/data_pipe_consumer_dispatcher.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "mojo/edk/system/data_pipe.h" | 8 #include "mojo/edk/system/data_pipe.h" |
9 #include "mojo/edk/system/memory.h" | 9 #include "mojo/edk/system/memory.h" |
10 | 10 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 if ((flags & MOJO_READ_DATA_FLAG_QUERY)) { | 70 if ((flags & MOJO_READ_DATA_FLAG_QUERY)) { |
71 if ((flags & MOJO_READ_DATA_FLAG_PEEK)) | 71 if ((flags & MOJO_READ_DATA_FLAG_PEEK)) |
72 return MOJO_RESULT_INVALID_ARGUMENT; | 72 return MOJO_RESULT_INVALID_ARGUMENT; |
73 DCHECK(!(flags & MOJO_READ_DATA_FLAG_DISCARD)); // Handled above. | 73 DCHECK(!(flags & MOJO_READ_DATA_FLAG_DISCARD)); // Handled above. |
74 DVLOG_IF(2, !elements.IsNull()) | 74 DVLOG_IF(2, !elements.IsNull()) |
75 << "Query mode: ignoring non-null |elements|"; | 75 << "Query mode: ignoring non-null |elements|"; |
76 return data_pipe_->ConsumerQueryData(num_bytes); | 76 return data_pipe_->ConsumerQueryData(num_bytes); |
77 } | 77 } |
78 | 78 |
79 return data_pipe_->ConsumerReadData( | 79 return data_pipe_->ConsumerReadData( |
80 elements, | 80 elements, num_bytes, !!(flags & MOJO_READ_DATA_FLAG_ALL_OR_NONE), |
81 num_bytes, | |
82 !!(flags & MOJO_READ_DATA_FLAG_ALL_OR_NONE), | |
83 !!(flags & MOJO_READ_DATA_FLAG_PEEK)); | 81 !!(flags & MOJO_READ_DATA_FLAG_PEEK)); |
84 } | 82 } |
85 | 83 |
86 MojoResult DataPipeConsumerDispatcher::BeginReadDataImplNoLock( | 84 MojoResult DataPipeConsumerDispatcher::BeginReadDataImplNoLock( |
87 UserPointer<const void*> buffer, | 85 UserPointer<const void*> buffer, |
88 UserPointer<uint32_t> buffer_num_bytes, | 86 UserPointer<uint32_t> buffer_num_bytes, |
89 MojoReadDataFlags flags) { | 87 MojoReadDataFlags flags) { |
90 lock().AssertAcquired(); | 88 lock().AssertAcquired(); |
91 | 89 |
92 // These flags may not be used in two-phase mode. | 90 // These flags may not be used in two-phase mode. |
93 if ((flags & MOJO_READ_DATA_FLAG_DISCARD) || | 91 if ((flags & MOJO_READ_DATA_FLAG_DISCARD) || |
94 (flags & MOJO_READ_DATA_FLAG_QUERY) || | 92 (flags & MOJO_READ_DATA_FLAG_QUERY) || (flags & MOJO_READ_DATA_FLAG_PEEK)) |
95 (flags & MOJO_READ_DATA_FLAG_PEEK)) | |
96 return MOJO_RESULT_INVALID_ARGUMENT; | 93 return MOJO_RESULT_INVALID_ARGUMENT; |
97 | 94 |
98 return data_pipe_->ConsumerBeginReadData( | 95 return data_pipe_->ConsumerBeginReadData( |
99 buffer, buffer_num_bytes, (flags & MOJO_READ_DATA_FLAG_ALL_OR_NONE)); | 96 buffer, buffer_num_bytes, (flags & MOJO_READ_DATA_FLAG_ALL_OR_NONE)); |
100 } | 97 } |
101 | 98 |
102 MojoResult DataPipeConsumerDispatcher::EndReadDataImplNoLock( | 99 MojoResult DataPipeConsumerDispatcher::EndReadDataImplNoLock( |
103 uint32_t num_bytes_read) { | 100 uint32_t num_bytes_read) { |
104 lock().AssertAcquired(); | 101 lock().AssertAcquired(); |
105 | 102 |
(...skipping 22 matching lines...) Expand all Loading... |
128 data_pipe_->ConsumerRemoveWaiter(waiter, signals_state); | 125 data_pipe_->ConsumerRemoveWaiter(waiter, signals_state); |
129 } | 126 } |
130 | 127 |
131 bool DataPipeConsumerDispatcher::IsBusyNoLock() const { | 128 bool DataPipeConsumerDispatcher::IsBusyNoLock() const { |
132 lock().AssertAcquired(); | 129 lock().AssertAcquired(); |
133 return data_pipe_->ConsumerIsBusy(); | 130 return data_pipe_->ConsumerIsBusy(); |
134 } | 131 } |
135 | 132 |
136 } // namespace system | 133 } // namespace system |
137 } // namespace mojo | 134 } // namespace mojo |
OLD | NEW |