LibWeb: Add Streams::ReadableStreamDefaultReader::read_all_bytes

This commit is contained in:
Shannon Booth 2023-06-17 15:26:20 +12:00 committed by Andreas Kling
parent 46f9a49bd8
commit 3df10d7fb6
Notes: sideshowbarker 2024-07-17 03:03:37 +09:00
2 changed files with 18 additions and 0 deletions

View File

@ -169,6 +169,22 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> ReadableStreamDefaultReader::
return JS::NonnullGCPtr { verify_cast<JS::Promise>(*promise_capability->promise()) };
}
// https://streams.spec.whatwg.org/#readablestreamdefaultreader-read-all-bytes
WebIDL::ExceptionOr<void> ReadableStreamDefaultReader::read_all_bytes(ReadLoopReadRequest::SuccessSteps success_steps, ReadLoopReadRequest::FailureSteps failure_steps)
{
auto& realm = this->realm();
auto& vm = realm.vm();
// 1. Let readRequest be a new read request with the following items:
// NOTE: items and steps in ReadLoopReadRequest.
auto read_request = adopt_ref(*new ReadLoopReadRequest(vm, realm, *this, move(success_steps), move(failure_steps)));
// 2. Perform ! ReadableStreamDefaultReaderRead(this, readRequest).
TRY(readable_stream_default_reader_read(*this, read_request));
return {};
}
// https://streams.spec.whatwg.org/#default-reader-release-lock
WebIDL::ExceptionOr<void> ReadableStreamDefaultReader::release_lock()
{

View File

@ -66,6 +66,8 @@ public:
virtual ~ReadableStreamDefaultReader() override = default;
WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> read();
WebIDL::ExceptionOr<void> read_all_bytes(ReadLoopReadRequest::SuccessSteps, ReadLoopReadRequest::FailureSteps);
WebIDL::ExceptionOr<void> release_lock();
SinglyLinkedList<NonnullRefPtr<ReadRequest>>& read_requests() { return m_read_requests; }