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

Unified Diff: mojo/system/data_pipe.cc

Issue 423583002: Convert WriteData...() 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, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/system/data_pipe.h ('k') | mojo/system/data_pipe_producer_dispatcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/system/data_pipe.cc
diff --git a/mojo/system/data_pipe.cc b/mojo/system/data_pipe.cc
index 7b7a0d35e42f535cb49a02748cd9d4ebb1ee3f4f..b0b350f808b154d73a898a8fb14a86fcee4b40c5 100644
--- a/mojo/system/data_pipe.cc
+++ b/mojo/system/data_pipe.cc
@@ -94,8 +94,8 @@ void DataPipe::ProducerClose() {
ConsumerGetHandleSignalsStateNoLock());
}
-MojoResult DataPipe::ProducerWriteData(const void* elements,
- uint32_t* num_bytes,
+MojoResult DataPipe::ProducerWriteData(UserPointer<const void> elements,
+ UserPointer<uint32_t> num_bytes,
bool all_or_none) {
base::AutoLock locker(lock_);
DCHECK(has_local_producer_no_lock());
@@ -106,14 +106,19 @@ MojoResult DataPipe::ProducerWriteData(const void* elements,
return MOJO_RESULT_FAILED_PRECONDITION;
// Returning "busy" takes priority over "invalid argument".
- if (*num_bytes % element_num_bytes_ != 0)
+ uint32_t max_num_bytes_to_write = num_bytes.Get();
+ if (max_num_bytes_to_write % element_num_bytes_ != 0)
return MOJO_RESULT_INVALID_ARGUMENT;
- if (*num_bytes == 0)
+ if (max_num_bytes_to_write == 0)
return MOJO_RESULT_OK; // Nothing to do.
+ uint32_t min_num_bytes_to_write = all_or_none ? max_num_bytes_to_write : 0;
+
HandleSignalsState old_consumer_state = ConsumerGetHandleSignalsStateNoLock();
- MojoResult rv = ProducerWriteDataImplNoLock(elements, num_bytes, all_or_none);
+ MojoResult rv = ProducerWriteDataImplNoLock(elements, num_bytes,
+ max_num_bytes_to_write,
+ min_num_bytes_to_write);
HandleSignalsState new_consumer_state = ConsumerGetHandleSignalsStateNoLock();
if (!new_consumer_state.equals(old_consumer_state))
AwakeConsumerWaitersForStateChangeNoLock(new_consumer_state);
« no previous file with comments | « mojo/system/data_pipe.h ('k') | mojo/system/data_pipe_producer_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698