Blinkeuses et Blinkeurs!
We hereby announce our Intent to Implement "Streams API" (the reading part of it for a start).
Primary eng/PM emails
tyos...@chromium.org (kenji...@chromium.org)
Spec
The Streams API (Editor’s Draft) https://dvcs.w3.org/hg/streams-api/raw-file/tip/Overview.htm
XMLHttpRequest (Editor’s Draft) https://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html
Ongoing discussion at W3C http://lists.w3.org/Archives/Public/public-webapps/
Summary
An API for representing binary data in web applications as a Stream object, as well as programmatically building and reading its contents. It’s designed to be used in conjunction with other web platform APIs such as the XMLHttpRequest.
The extension for XMLHttpRequest proposed in the spec enables reading an HTTP response body and writing an HTTP request body progressively via the XMLHttpRequest. For the first step, we’re going to implement reading part, i.e. add Stream, StreamReader and the new responseType “stream” to XMLHttpRequest.
(This Intent to Implement doesn’t cover the writing part, i.e. StreamBuilder and overloading of send() method for Stream type)
Motivation
To implement interactive webapps like chat, video streaming, etc. we’ve been using the XMLHttpRequest with some hack such as COMET as a realtime-bidirectional messaging infrastructure. XMLHttpRequest was originally designed with a focus on request-response model communication. There’s no method available to send messages in the same HTTP transaction. This is important to improve the efficiency of applications which generates data to be streamed to the server. Streams API solves this exact problem by providing an interface to pass streamed data to the XMLHttpRequest by sending it as the body of the HTTP request.
Furthermore, to implement server based notifications, server-push with chunked response and polling has been the traditional approach. On the other hand, Streams API’s StreamReader makes it possible to receive the body of an HTTP response streamed by a server using asynchronous API similar to how FileReader works.
Compatibility Risk
No new compatibility break. In the future, it’s possible that the API surface will be changed. For the initial release, the API will be hidden behind a flag.
Ongoing technical constraints
None.
OWP launch tracking bug?
Row on feature dashboard?
Yes.
Requesting approval to ship?
No (behind runtime flag. We’ll send intent to ship again when it’s time)
Darin,I talked to Adrian Bateman (Microsoft) at the last W3C F2F about the possibility of making Blob inherit from Stream and he said that they initially proposed doing that, but I think he said that someone from Mozilla was afraid that making such a change so late in the game for the File API spec would derail things. Obviously this is only one data point so it may still be worth starting a thread about making this change on the webapps list and see what happens.
Thanks for comments, all.I did some prototyping today to estimate size of task.
I'll start writing a separate but probably short intent-to-implement for Future. If it turned out to be better to have one doc, I can merge them.
--
http://annevankesteren.nl/
That's not quite what I had in mind.
I was suggesting it could be a property of a Stream (and hence a Blob) that its data may only be available to be consumed once. This property would be set at instantiation time and be fixed thereafter. A File would probably always be read many.
-Darin
That's not quite what I had in mind.
I was suggesting it could be a property of a Stream (and hence a Blob) that its data may only be available to be consumed once. This property would be set at instantiation time and be fixed thereafter. A File would probably always be read many.
I think I would keep slice() on Blob. That avoids messy issues related to size of stream being unknown.
As for read-once blobs, I don't think slice() needs to copy. I think the read-once property should apply to the backing data for the blob. A blob slice is just another reference to the same "read-once" data.
Slicing a Blob happens synchronously, so it can't be a "deep copy" type of operation anyways.
-Darin
I think I would keep slice() on Blob. That avoids messy issues related to size of stream being unknown.
As for read-once blobs, I don't think slice() needs to copy. I think the read-once property should apply to the backing data for the blob. A blob slice is just another reference to the same "read-once" data.