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

Unified Diff: mojo/public/cpp/system/data_pipe.h

Issue 2875143002: Reduce boilerplate when creating simple mojom::URLLoaders. (Closed)
Patch Set: Created 3 years, 7 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 | « media/remoting/demuxer_stream_adapter.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/system/data_pipe.h
diff --git a/mojo/public/cpp/system/data_pipe.h b/mojo/public/cpp/system/data_pipe.h
index 0dbc3c74e5e62c1d01f48ba68947726d66e899f9..9f58c27c3300a3b28098b876123ed3b33c576ad2 100644
--- a/mojo/public/cpp/system/data_pipe.h
+++ b/mojo/public/cpp/system/data_pipe.h
@@ -134,6 +134,7 @@ inline MojoResult EndReadDataRaw(DataPipeConsumerHandle data_pipe_consumer,
class DataPipe {
public:
DataPipe();
+ explicit DataPipe(uint32_t capacity_num_bytes);
explicit DataPipe(const MojoCreateDataPipeOptions& options);
~DataPipe();
@@ -148,6 +149,19 @@ inline DataPipe::DataPipe() {
DCHECK_EQ(MOJO_RESULT_OK, result);
}
+inline DataPipe::DataPipe(uint32_t capacity_num_bytes) {
+ MojoCreateDataPipeOptions options;
+ options.struct_size = sizeof(MojoCreateDataPipeOptions);
+ options.flags = MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE;
+ options.element_num_bytes = 1;
+ options.capacity_num_bytes = capacity_num_bytes;
+ mojo::DataPipe data_pipe(options);
+ MojoResult result =
+ CreateDataPipe(&options, &producer_handle, &consumer_handle);
+ ALLOW_UNUSED_LOCAL(result);
+ DCHECK_EQ(MOJO_RESULT_OK, result);
+}
+
inline DataPipe::DataPipe(const MojoCreateDataPipeOptions& options) {
MojoResult result =
CreateDataPipe(&options, &producer_handle, &consumer_handle);
« no previous file with comments | « media/remoting/demuxer_stream_adapter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698