Re: Overlap between StreamReader and FileReader

This looks nice. It looks like it should already handle the flow control
issues mentioned earlier in the thread, simply by performing the read on
demand, though reporting the result asynchronously.

-Ken



On Wed, Sep 25, 2013 at 9:17 PM, Takeshi Yoshino <tyoshino@google.com>wrote:

> As we don't see any strong demand for flow control and sync read
> functionality, I've revised the proposal.
>
> Though we can separate state/error signaling from Stream and keep them
> done by each API (e.g. XHR) as Aymeric said, EoF signal still needs to be
> conveyed through Stream.
>
> ----
>
> enum StreamReadType {
>   "",
>   "blob",
>   "arraybuffer",
>   "text"
> };
>
> interface StreamConsumeResult {
>   readonly attribute boolean eof;
>   readonly any data;
>   readonly unsigned long long size;
> };
>
> [Constructor(optional DOMString mime)]
> interface Stream {
>   readonly attribute DOMString type;  // MIME type
>
>   // Rejected on error. No more write op shouldn't be made.
>   //
>   // Fulfilled when the write completes. It doesn't guarantee that the
> written data has been
>   // read out successfully.
>   //
>   // The contents of ArrayBufferView must not be modified until the
> promise is fulfilled.
>   //
>   // Fulfill may be delayed when the Stream considers itself to be full.
>   //
>   // write(), close() must not be called again until the Promise of the
> last write() is fulfilled.
>   Promise<void> write((DOMString or ArrayBufferView or Blob)? data);
>   void close();
>
>   attribute StreamReadType readType;
>   attribute DOMString readEncoding;
>
>   // read(), skip(), pipe() must not be called again until the Promise of
> the last read(), skip(), pipe() is fulfilled.
>
>   // Rejected on error. No more read op shouldn't be made.
>   //
>   // If size is specified,
>   // - if EoF: fulfilled with data up to EoF
>   // - otherwise: fulfilled with data of size bytes
>   //
>   // If size is omitted, (all or part of) data available for read now will
> be returned.
>   //
>   // If readType is set to text, size of the result may be smaller than
> the value specified for the size argument.
>   Promise<StreamConsumeResult> read(optional [Clamp] long long size);
>
>   // Rejected on error. Fulfilled on completion.
>   //
>   // .data of result is not used. .size of result is the skipped amount.
>   Promise<StreamConsumeResult> skip([Clamp] long long size);  // .data is
> skipped size
>
>   // Rejected on error. Fulfilled on completion.
>   //
>   // If size is omitted, transfer until EoF is encountered.
>   //
>   // .data of result is not used. .size of result is the size of data
> transferred.
>   Promise<StreamConsumeResult> pipe(Stream destination, optional [Clamp]
> long long size);
> };
>
>

Received on Saturday, 28 September 2013 02:45:49 UTC