Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(576)

Side by Side Diff: mojo/system/local_data_pipe.cc

Issue 339193005: Mojo: Rename (Mojo)WaitFlagsState -> (Mojo)HandleSignalsState. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « mojo/system/local_data_pipe.h ('k') | mojo/system/local_message_pipe_endpoint.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // TODO(vtl): I currently potentially overflow in doing index calculations. 5 // TODO(vtl): I currently potentially overflow in doing index calculations.
6 // E.g., |start_index_| and |current_num_bytes_| fit into a |uint32_t|, but 6 // E.g., |start_index_| and |current_num_bytes_| fit into a |uint32_t|, but
7 // their sum may not. This is bad and poses a security risk. (We're currently 7 // their sum may not. This is bad and poses a security risk. (We're currently
8 // saved by the limit on capacity -- the maximum size of the buffer, checked in 8 // saved by the limit on capacity -- the maximum size of the buffer, checked in
9 // |DataPipe::ValidateOptions()|, is currently sufficiently small. 9 // |DataPipe::ValidateOptions()|, is currently sufficiently small.
10 10
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 MojoResult LocalDataPipe::ProducerEndWriteDataImplNoLock( 144 MojoResult LocalDataPipe::ProducerEndWriteDataImplNoLock(
145 uint32_t num_bytes_written) { 145 uint32_t num_bytes_written) {
146 DCHECK_LE(num_bytes_written, 146 DCHECK_LE(num_bytes_written,
147 producer_two_phase_max_num_bytes_written_no_lock()); 147 producer_two_phase_max_num_bytes_written_no_lock());
148 current_num_bytes_ += num_bytes_written; 148 current_num_bytes_ += num_bytes_written;
149 DCHECK_LE(current_num_bytes_, capacity_num_bytes()); 149 DCHECK_LE(current_num_bytes_, capacity_num_bytes());
150 set_producer_two_phase_max_num_bytes_written_no_lock(0); 150 set_producer_two_phase_max_num_bytes_written_no_lock(0);
151 return MOJO_RESULT_OK; 151 return MOJO_RESULT_OK;
152 } 152 }
153 153
154 WaitFlagsState LocalDataPipe::ProducerGetWaitFlagsStateNoLock() const { 154 HandleSignalsState LocalDataPipe::ProducerGetHandleSignalsStateNoLock() const {
155 WaitFlagsState rv; 155 HandleSignalsState rv;
156 if (consumer_open_no_lock()) { 156 if (consumer_open_no_lock()) {
157 if ((may_discard() || current_num_bytes_ < capacity_num_bytes()) && 157 if ((may_discard() || current_num_bytes_ < capacity_num_bytes()) &&
158 !producer_in_two_phase_write_no_lock()) 158 !producer_in_two_phase_write_no_lock())
159 rv.satisfied_signals |= MOJO_HANDLE_SIGNAL_WRITABLE; 159 rv.satisfied_signals |= MOJO_HANDLE_SIGNAL_WRITABLE;
160 rv.satisfiable_signals |= MOJO_HANDLE_SIGNAL_WRITABLE; 160 rv.satisfiable_signals |= MOJO_HANDLE_SIGNAL_WRITABLE;
161 } 161 }
162 return rv; 162 return rv;
163 } 163 }
164 164
165 void LocalDataPipe::ConsumerCloseImplNoLock() { 165 void LocalDataPipe::ConsumerCloseImplNoLock() {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 266
267 MojoResult LocalDataPipe::ConsumerEndReadDataImplNoLock( 267 MojoResult LocalDataPipe::ConsumerEndReadDataImplNoLock(
268 uint32_t num_bytes_read) { 268 uint32_t num_bytes_read) {
269 DCHECK_LE(num_bytes_read, consumer_two_phase_max_num_bytes_read_no_lock()); 269 DCHECK_LE(num_bytes_read, consumer_two_phase_max_num_bytes_read_no_lock());
270 DCHECK_LE(start_index_ + num_bytes_read, capacity_num_bytes()); 270 DCHECK_LE(start_index_ + num_bytes_read, capacity_num_bytes());
271 MarkDataAsConsumedNoLock(num_bytes_read); 271 MarkDataAsConsumedNoLock(num_bytes_read);
272 set_consumer_two_phase_max_num_bytes_read_no_lock(0); 272 set_consumer_two_phase_max_num_bytes_read_no_lock(0);
273 return MOJO_RESULT_OK; 273 return MOJO_RESULT_OK;
274 } 274 }
275 275
276 WaitFlagsState LocalDataPipe::ConsumerGetWaitFlagsStateNoLock() const { 276 HandleSignalsState LocalDataPipe::ConsumerGetHandleSignalsStateNoLock() const {
277 WaitFlagsState rv; 277 HandleSignalsState rv;
278 if (current_num_bytes_ > 0) { 278 if (current_num_bytes_ > 0) {
279 if (!consumer_in_two_phase_read_no_lock()) 279 if (!consumer_in_two_phase_read_no_lock())
280 rv.satisfied_signals |= MOJO_HANDLE_SIGNAL_READABLE; 280 rv.satisfied_signals |= MOJO_HANDLE_SIGNAL_READABLE;
281 rv.satisfiable_signals |= MOJO_HANDLE_SIGNAL_READABLE; 281 rv.satisfiable_signals |= MOJO_HANDLE_SIGNAL_READABLE;
282 } else if (producer_open_no_lock()) { 282 } else if (producer_open_no_lock()) {
283 rv.satisfiable_signals |= MOJO_HANDLE_SIGNAL_READABLE; 283 rv.satisfiable_signals |= MOJO_HANDLE_SIGNAL_READABLE;
284 } 284 }
285 return rv; 285 return rv;
286 } 286 }
287 287
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 323
324 void LocalDataPipe::MarkDataAsConsumedNoLock(size_t num_bytes) { 324 void LocalDataPipe::MarkDataAsConsumedNoLock(size_t num_bytes) {
325 DCHECK_LE(num_bytes, current_num_bytes_); 325 DCHECK_LE(num_bytes, current_num_bytes_);
326 start_index_ += num_bytes; 326 start_index_ += num_bytes;
327 start_index_ %= capacity_num_bytes(); 327 start_index_ %= capacity_num_bytes();
328 current_num_bytes_ -= num_bytes; 328 current_num_bytes_ -= num_bytes;
329 } 329 }
330 330
331 } // namespace system 331 } // namespace system
332 } // namespace mojo 332 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/system/local_data_pipe.h ('k') | mojo/system/local_message_pipe_endpoint.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698