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

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

Issue 1885663002: EDK: Add implementation of data pipe producer write 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_producer_dispatcher.h ('k') | mojo/edk/system/dispatcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/data_pipe_producer_dispatcher.cc
diff --git a/mojo/edk/system/data_pipe_producer_dispatcher.cc b/mojo/edk/system/data_pipe_producer_dispatcher.cc
index 726f1bbb26d8917fb336010b3fa43ed0d7cb94da..febe21766c35ef73f213e8b1bd903e0f097e5dce 100644
--- a/mojo/edk/system/data_pipe_producer_dispatcher.cc
+++ b/mojo/edk/system/data_pipe_producer_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,51 @@ DataPipeProducerDispatcher::CreateEquivalentDispatcherAndCloseImplNoLock() {
return dispatcher;
}
+MojoResult DataPipeProducerDispatcher::SetDataPipeProducerOptionsImplNoLock(
+ UserPointer<const MojoDataPipeProducerOptions> options) {
+ mutex().AssertHeld();
+
+ // The default of 0 means 1 element (however big that is).
+ uint32_t write_threshold_num_bytes = 0;
+ if (!options.IsNull()) {
+ UserOptionsReader<MojoDataPipeProducerOptions> reader(options);
+ if (!reader.is_valid())
+ return MOJO_RESULT_INVALID_ARGUMENT;
+
+ if (!OPTIONS_STRUCT_HAS_MEMBER(MojoDataPipeProducerOptions,
+ write_threshold_num_bytes, reader))
+ return MOJO_RESULT_OK;
+
+ write_threshold_num_bytes = reader.options().write_threshold_num_bytes;
+ }
+
+ return data_pipe_->ProducerSetOptions(write_threshold_num_bytes);
+}
+
+MojoResult DataPipeProducerDispatcher::GetDataPipeProducerOptionsImplNoLock(
+ UserPointer<MojoDataPipeProducerOptions> options,
+ uint32_t options_num_bytes) {
+ mutex().AssertHeld();
+
+ // Note: If/when |MojoDataPipeProducerOptions| is extended beyond its initial
+ // definition, more work will be necessary. (See the definition of
+ // |MojoGetDataPipeProducerOptions()| in mojo/public/c/system/data_pipe.h.)
+ static_assert(sizeof(MojoDataPipeProducerOptions) == 8u,
+ "MojoDataPipeProducerOptions has been extended!");
+
+ if (options_num_bytes < sizeof(MojoDataPipeProducerOptions))
+ return MOJO_RESULT_INVALID_ARGUMENT;
+
+ uint32_t write_threshold_num_bytes = 0;
+ data_pipe_->ProducerGetOptions(&write_threshold_num_bytes);
+ MojoDataPipeProducerOptions model_options = {
+ sizeof(MojoDataPipeProducerOptions), // |struct_size|.
+ write_threshold_num_bytes, // |write_threshold_num_bytes|.
+ };
+ options.Put(model_options);
+ return MOJO_RESULT_OK;
+}
+
MojoResult DataPipeProducerDispatcher::WriteDataImplNoLock(
UserPointer<const void> elements,
UserPointer<uint32_t> num_bytes,
« no previous file with comments | « mojo/edk/system/data_pipe_producer_dispatcher.h ('k') | mojo/edk/system/dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698