[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