The Serial API will use Mojo data pipes as the data transport between the render process and the device service. These pipes will then be exposed to the web as a ReadableStream/WritableStream pair.
The Fetch API currently has a way to wrap a data pipe in a stream however it is buried deeply inside the implementation of that particular API. The Serial API will not only need a similar wrapper but for testing we will also want to read and write to a data pipe from JavaScript and the stream abstraction is a good one.
This issue tracks writing generic wrappers around a Mojo data pipe consumer or producer handle that provide a ReadableStream or WritableStream respectively. These will be used internally by the Serial API and exposed for testing through the Mojo JS bindings.
Two new methods, toReadableStream() and toWritableStream(), will be added to the MojoHandle interface. Once this is done the existing writeData(), queryData(), discardData() and readData() methods can probably be removed. They are currently unused outside of tests.
Comment 1 by reillyg@chromium.org
, Oct 8