[Streams API] Implement ReadableStreamController enqueue
authoryouenn.fablet@crf.canon.fr <youenn.fablet@crf.canon.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Jun 2015 10:19:43 +0000 (10:19 +0000)
committeryouenn.fablet@crf.canon.fr <youenn.fablet@crf.canon.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Jun 2015 10:19:43 +0000 (10:19 +0000)
commitfc32ba12698fcd9179e80d13f4c389fa0487b58f
treeedc9039e2e97f7cbc75858f0aa2ced6bfb43d2ed
parentc11155cfd28a98e3d3f1d97300e3cce944ed066e
[Streams API] Implement ReadableStreamController enqueue
https://bugs.webkit.org/show_bug.cgi?id=145210

Reviewed by Darin Adler.

Source/WebCore:

Added possibility to enqueue any JSValue within ReadableJSStream.
They are stored in a Vector of strongified JSValue.

Added support for streams that contain data but are asked to close.
This is done through m_closeRequested boolean and splitting actual closing of the stream from changeStateToClosed().

Chunk size and backpressure mechanism is not yet implemented.
Neither is pulling once enqueued data is processed.

Covered by rebased tests.

* Modules/streams/ReadableStream.cpp:
(WebCore::ReadableStream::changeStateToClosed): Split method with newly added close().
(WebCore::ReadableStream::close): Does the actual closing of stream once stream has no more values.
(WebCore::ReadableStream::read): Close the stream when stream is emptied and close is requested.
(WebCore::ReadableStream::resolveReadCallback): Added to enable ReadableJSStream to resolve read callbacks immediatly at enqueue time.
* Modules/streams/ReadableStream.h:
(WebCore::ReadableStream::isErrored): Getter added for the custom binding code.
(WebCore::ReadableStream::isCloseRequested): Ditto.
* bindings/js/JSReadableStreamControllerCustom.cpp:
(WebCore::JSReadableStreamController::enqueue): binding code for enqueue, taking care of raising exception if readable stream cannot enqueue.
* bindings/js/ReadableJSStream.cpp:
(WebCore::ReadableJSStream::hasValue):
(WebCore::ReadableJSStream::read):
(WebCore::ReadableJSStream::enqueue):
* bindings/js/ReadableJSStream.h:

LayoutTests:

* streams/reference-implementation/bad-underlying-sources-expected.txt:
* streams/reference-implementation/count-queuing-strategy-expected.txt:
* streams/reference-implementation/count-queuing-strategy.html:
* streams/reference-implementation/readable-stream-expected.txt:
* streams/reference-implementation/readable-stream-reader-expected.txt:
* streams/reference-implementation/readable-stream-reader.html:
* streams/reference-implementation/readable-stream-templated-expected.txt:
* streams/reference-implementation/readable-stream-templated.html:
* streams/reference-implementation/readable-stream.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@185197 268f45cc-cd09-0410-ab3c-d52691b4dbfc
16 files changed:
LayoutTests/ChangeLog
LayoutTests/streams/reference-implementation/bad-underlying-sources-expected.txt
LayoutTests/streams/reference-implementation/count-queuing-strategy-expected.txt
LayoutTests/streams/reference-implementation/count-queuing-strategy.html
LayoutTests/streams/reference-implementation/readable-stream-expected.txt
LayoutTests/streams/reference-implementation/readable-stream-reader-expected.txt
LayoutTests/streams/reference-implementation/readable-stream-reader.html
LayoutTests/streams/reference-implementation/readable-stream-templated-expected.txt
LayoutTests/streams/reference-implementation/readable-stream-templated.html
LayoutTests/streams/reference-implementation/readable-stream.html
Source/WebCore/ChangeLog
Source/WebCore/Modules/streams/ReadableStream.cpp
Source/WebCore/Modules/streams/ReadableStream.h
Source/WebCore/bindings/js/JSReadableStreamControllerCustom.cpp
Source/WebCore/bindings/js/ReadableJSStream.cpp
Source/WebCore/bindings/js/ReadableJSStream.h