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

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

Issue 1856113002: EDK: Add implementation of data pipe consumer read threshold stuff. (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/data_pipe_consumer_dispatcher.h ('k') | mojo/edk/system/data_pipe_impl.h » ('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 a32e05e1e3c383d55d6e8a88ade7d5205d6b81f3..5d10c77264990f2eaa5fe5ac1ad4275091153ac4 100644
--- a/mojo/edk/system/data_pipe_consumer_dispatcher.cc
+++ b/mojo/edk/system/data_pipe_consumer_dispatcher.cc
@@ -9,6 +9,7 @@
#include "base/logging.h"
#include "mojo/edk/system/data_pipe.h"
#include "mojo/edk/system/memory.h"
+#include "mojo/edk/system/options_validation.h"
using mojo::platform::ScopedPlatformHandle;
using mojo::util::MutexLocker;
@@ -74,6 +75,46 @@ DataPipeConsumerDispatcher::CreateEquivalentDispatcherAndCloseImplNoLock() {
return dispatcher;
}
+MojoResult DataPipeConsumerDispatcher::SetDataPipeConsumerOptionsImplNoLock(
+ UserPointer<const MojoDataPipeConsumerOptions> options) {
+ mutex().AssertHeld();
+
+ 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;
+
+ return data_pipe_->ConsumerSetOptions(
+ reader.options().read_threshold_num_bytes);
+}
+
+MojoResult DataPipeConsumerDispatcher::GetDataPipeConsumerOptionsImplNoLock(
+ UserPointer<MojoDataPipeConsumerOptions> options,
+ uint32_t options_num_bytes) {
+ mutex().AssertHeld();
+
+ // Note: If/when |MojoDataPipeConsumerOptions| is extended beyond its initial
+ // definition, more work will be necessary. (See the definition of
+ // |MojoGetDataPipeConsumerOptions()| in mojo/public/c/system/data_pipe.h.)
+ static_assert(sizeof(MojoDataPipeConsumerOptions) == 8u,
+ "MojoDataPipeConsumerOptions has been extended!");
+
+ if (options_num_bytes < sizeof(MojoDataPipeConsumerOptions))
+ return MOJO_RESULT_INVALID_ARGUMENT;
+
+ uint32_t read_threshold_num_bytes = 0;
+ data_pipe_->ConsumerGetOptions(&read_threshold_num_bytes);
+ MojoDataPipeConsumerOptions model_options = {
+ sizeof(MojoDataPipeConsumerOptions), // |struct_size|.
+ read_threshold_num_bytes, // |read_threshold_num_bytes|.
+ };
+ options.Put(model_options);
+ return MOJO_RESULT_OK;
+}
+
MojoResult DataPipeConsumerDispatcher::ReadDataImplNoLock(
UserPointer<void> elements,
UserPointer<uint32_t> num_bytes,
« no previous file with comments | « mojo/edk/system/data_pipe_consumer_dispatcher.h ('k') | mojo/edk/system/data_pipe_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698