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, num_bytes, !!(flags & MOJO_READ_DATA_FLAG_ALL_OR_NONE), | 80 elements, |
| 81 num_bytes, |
| 82 !!(flags & MOJO_READ_DATA_FLAG_ALL_OR_NONE), |
81 !!(flags & MOJO_READ_DATA_FLAG_PEEK)); | 83 !!(flags & MOJO_READ_DATA_FLAG_PEEK)); |
82 } | 84 } |
83 | 85 |
84 MojoResult DataPipeConsumerDispatcher::BeginReadDataImplNoLock( | 86 MojoResult DataPipeConsumerDispatcher::BeginReadDataImplNoLock( |
85 UserPointer<const void*> buffer, | 87 UserPointer<const void*> buffer, |
86 UserPointer<uint32_t> buffer_num_bytes, | 88 UserPointer<uint32_t> buffer_num_bytes, |
87 MojoReadDataFlags flags) { | 89 MojoReadDataFlags flags) { |
88 lock().AssertAcquired(); | 90 lock().AssertAcquired(); |
89 | 91 |
90 // These flags may not be used in two-phase mode. | 92 // These flags may not be used in two-phase mode. |
91 if ((flags & MOJO_READ_DATA_FLAG_DISCARD) || | 93 if ((flags & MOJO_READ_DATA_FLAG_DISCARD) || |
92 (flags & MOJO_READ_DATA_FLAG_QUERY) || (flags & MOJO_READ_DATA_FLAG_PEEK)) | 94 (flags & MOJO_READ_DATA_FLAG_QUERY) || |
| 95 (flags & MOJO_READ_DATA_FLAG_PEEK)) |
93 return MOJO_RESULT_INVALID_ARGUMENT; | 96 return MOJO_RESULT_INVALID_ARGUMENT; |
94 | 97 |
95 return data_pipe_->ConsumerBeginReadData( | 98 return data_pipe_->ConsumerBeginReadData( |
96 buffer, buffer_num_bytes, (flags & MOJO_READ_DATA_FLAG_ALL_OR_NONE)); | 99 buffer, buffer_num_bytes, (flags & MOJO_READ_DATA_FLAG_ALL_OR_NONE)); |
97 } | 100 } |
98 | 101 |
99 MojoResult DataPipeConsumerDispatcher::EndReadDataImplNoLock( | 102 MojoResult DataPipeConsumerDispatcher::EndReadDataImplNoLock( |
100 uint32_t num_bytes_read) { | 103 uint32_t num_bytes_read) { |
101 lock().AssertAcquired(); | 104 lock().AssertAcquired(); |
102 | 105 |
(...skipping 22 matching lines...) Expand all Loading... |
125 data_pipe_->ConsumerRemoveWaiter(waiter, signals_state); | 128 data_pipe_->ConsumerRemoveWaiter(waiter, signals_state); |
126 } | 129 } |
127 | 130 |
128 bool DataPipeConsumerDispatcher::IsBusyNoLock() const { | 131 bool DataPipeConsumerDispatcher::IsBusyNoLock() const { |
129 lock().AssertAcquired(); | 132 lock().AssertAcquired(); |
130 return data_pipe_->ConsumerIsBusy(); | 133 return data_pipe_->ConsumerIsBusy(); |
131 } | 134 } |
132 | 135 |
133 } // namespace system | 136 } // namespace system |
134 } // namespace mojo | 137 } // namespace mojo |
OLD | NEW |