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

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

Issue 416203002: Convert BeginReadData...() to use the new user pointer handling (see r285350). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 4 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/data_pipe.h ('k') | mojo/system/data_pipe_consumer_dispatcher.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 #include "mojo/system/data_pipe.h" 5 #include "mojo/system/data_pipe.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 base::AutoLock locker(lock_); 279 base::AutoLock locker(lock_);
280 DCHECK(has_local_consumer_no_lock()); 280 DCHECK(has_local_consumer_no_lock());
281 281
282 if (consumer_in_two_phase_read_no_lock()) 282 if (consumer_in_two_phase_read_no_lock())
283 return MOJO_RESULT_BUSY; 283 return MOJO_RESULT_BUSY;
284 284
285 // Note: Don't need to validate |*num_bytes| for query. 285 // Note: Don't need to validate |*num_bytes| for query.
286 return ConsumerQueryDataImplNoLock(num_bytes); 286 return ConsumerQueryDataImplNoLock(num_bytes);
287 } 287 }
288 288
289 MojoResult DataPipe::ConsumerBeginReadData(const void** buffer, 289 MojoResult DataPipe::ConsumerBeginReadData(
290 uint32_t* buffer_num_bytes, 290 UserPointer<const void*> buffer,
291 bool all_or_none) { 291 UserPointer<uint32_t> buffer_num_bytes,
292 bool all_or_none) {
292 base::AutoLock locker(lock_); 293 base::AutoLock locker(lock_);
293 DCHECK(has_local_consumer_no_lock()); 294 DCHECK(has_local_consumer_no_lock());
294 295
295 if (consumer_in_two_phase_read_no_lock()) 296 if (consumer_in_two_phase_read_no_lock())
296 return MOJO_RESULT_BUSY; 297 return MOJO_RESULT_BUSY;
297 298
298 if (all_or_none && *buffer_num_bytes % element_num_bytes_ != 0) 299 uint32_t min_num_bytes_to_read = 0;
299 return MOJO_RESULT_INVALID_ARGUMENT; 300 if (all_or_none) {
301 min_num_bytes_to_read = buffer_num_bytes.Get();
302 if (min_num_bytes_to_read % element_num_bytes_ != 0)
303 return MOJO_RESULT_INVALID_ARGUMENT;
304 }
300 305
301 MojoResult rv = ConsumerBeginReadDataImplNoLock(buffer, buffer_num_bytes, 306 MojoResult rv = ConsumerBeginReadDataImplNoLock(buffer, buffer_num_bytes,
302 all_or_none); 307 min_num_bytes_to_read);
303 if (rv != MOJO_RESULT_OK) 308 if (rv != MOJO_RESULT_OK)
304 return rv; 309 return rv;
305 DCHECK(consumer_in_two_phase_read_no_lock()); 310 DCHECK(consumer_in_two_phase_read_no_lock());
306 return MOJO_RESULT_OK; 311 return MOJO_RESULT_OK;
307 } 312 }
308 313
309 MojoResult DataPipe::ConsumerEndReadData(uint32_t num_bytes_read) { 314 MojoResult DataPipe::ConsumerEndReadData(uint32_t num_bytes_read) {
310 base::AutoLock locker(lock_); 315 base::AutoLock locker(lock_);
311 DCHECK(has_local_consumer_no_lock()); 316 DCHECK(has_local_consumer_no_lock());
312 317
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 void DataPipe::AwakeConsumerWaitersForStateChangeNoLock( 404 void DataPipe::AwakeConsumerWaitersForStateChangeNoLock(
400 const HandleSignalsState& new_consumer_state) { 405 const HandleSignalsState& new_consumer_state) {
401 lock_.AssertAcquired(); 406 lock_.AssertAcquired();
402 if (!has_local_consumer_no_lock()) 407 if (!has_local_consumer_no_lock())
403 return; 408 return;
404 consumer_waiter_list_->AwakeWaitersForStateChange(new_consumer_state); 409 consumer_waiter_list_->AwakeWaitersForStateChange(new_consumer_state);
405 } 410 }
406 411
407 } // namespace system 412 } // namespace system
408 } // namespace mojo 413 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/system/data_pipe.h ('k') | mojo/system/data_pipe_consumer_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698