mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 02:37:42 +00:00
LibWeb: Add ReadableStreamByteController interface
This commit is contained in:
parent
c7aa4fa166
commit
819b6332d1
10 changed files with 253 additions and 1 deletions
|
@ -10,6 +10,7 @@
|
|||
#include <LibWeb/Bindings/ExceptionOrUtils.h>
|
||||
#include <LibWeb/DOM/AbortSignal.h>
|
||||
#include <LibWeb/Streams/AbstractOperations.h>
|
||||
#include <LibWeb/Streams/ReadableByteStreamController.h>
|
||||
#include <LibWeb/Streams/ReadableStream.h>
|
||||
#include <LibWeb/Streams/ReadableStreamDefaultController.h>
|
||||
#include <LibWeb/Streams/ReadableStreamDefaultReader.h>
|
||||
|
@ -739,6 +740,24 @@ WebIDL::ExceptionOr<void> set_up_readable_stream_default_controller_from_underly
|
|||
return set_up_readable_stream_default_controller(stream, controller, move(start_algorithm), move(pull_algorithm), move(cancel_algorithm), high_water_mark, move(size_algorithm));
|
||||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#readable-byte-stream-controller-get-desired-size
|
||||
Optional<double> readable_byte_stream_controller_get_desired_size(ReadableByteStreamController const& controller)
|
||||
{
|
||||
auto stream = controller.stream();
|
||||
|
||||
// 1. Let state be controller.[[stream]].[[state]].
|
||||
// 2. If state is "errored", return null.
|
||||
if (stream->is_errored())
|
||||
return {};
|
||||
|
||||
// 3. If state is "closed", return 0.
|
||||
if (stream->is_closed())
|
||||
return 0.0;
|
||||
|
||||
// 4. Return controller.[[strategyHWM]] − controller.[[queueTotalSize]].
|
||||
return controller.strategy_hwm() - controller.queue_total_size();
|
||||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#acquire-writable-stream-default-writer
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<WritableStreamDefaultWriter>> acquire_writable_stream_default_writer(WritableStream& stream)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue