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

Unified Diff: mojo/edk/system/data_pipe_consumer_dispatcher.cc

Issue 1865663002: Let MojoSetDataPipeConsumerOptions() take null options. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 8 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/edk/system/core_unittest.cc ('k') | mojo/public/c/system/tests/core_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/data_pipe_consumer_dispatcher.cc
diff --git a/mojo/edk/system/data_pipe_consumer_dispatcher.cc b/mojo/edk/system/data_pipe_consumer_dispatcher.cc
index 5d10c77264990f2eaa5fe5ac1ad4275091153ac4..2b3aed0fd0f3afff21e6f37c5b2d0dba44ceeb07 100644
--- a/mojo/edk/system/data_pipe_consumer_dispatcher.cc
+++ b/mojo/edk/system/data_pipe_consumer_dispatcher.cc
@@ -79,16 +79,21 @@ MojoResult DataPipeConsumerDispatcher::SetDataPipeConsumerOptionsImplNoLock(
UserPointer<const MojoDataPipeConsumerOptions> options) {
mutex().AssertHeld();
- UserOptionsReader<MojoDataPipeConsumerOptions> reader(options);
- if (!reader.is_valid())
- return MOJO_RESULT_INVALID_ARGUMENT;
+ // The default of 0 means 1 element (however big that is).
+ uint32_t read_threshold_num_bytes = 0;
+ if (!options.IsNull()) {
+ UserOptionsReader<MojoDataPipeConsumerOptions> reader(options);
+ if (!reader.is_valid())
+ return MOJO_RESULT_INVALID_ARGUMENT;
- if (!OPTIONS_STRUCT_HAS_MEMBER(MojoDataPipeConsumerOptions,
- read_threshold_num_bytes, reader))
- return MOJO_RESULT_OK;
+ if (!OPTIONS_STRUCT_HAS_MEMBER(MojoDataPipeConsumerOptions,
+ read_threshold_num_bytes, reader))
+ return MOJO_RESULT_OK;
+
+ read_threshold_num_bytes = reader.options().read_threshold_num_bytes;
+ }
- return data_pipe_->ConsumerSetOptions(
- reader.options().read_threshold_num_bytes);
+ return data_pipe_->ConsumerSetOptions(read_threshold_num_bytes);
}
MojoResult DataPipeConsumerDispatcher::GetDataPipeConsumerOptionsImplNoLock(
« no previous file with comments | « mojo/edk/system/core_unittest.cc ('k') | mojo/public/c/system/tests/core_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698