LibWeb: Remove small OOM error propagation from stream AOs
This commit is contained in:
parent
bbe6b84bd6
commit
13021a0fb9
Notes:
sideshowbarker
2024-07-17 07:16:27 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/13021a0fb9 Pull-request: https://github.com/SerenityOS/serenity/pull/24165 Reviewed-by: https://github.com/kennethmyhra ✅ Reviewed-by: https://github.com/shannonbooth ✅
3 changed files with 16 additions and 23 deletions
|
@ -2654,7 +2654,7 @@ void readable_byte_stream_controller_error(ReadableByteStreamController& control
|
|||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#abstract-opdef-readablebytestreamcontrollerfillreadrequestfromqueue
|
||||
WebIDL::ExceptionOr<void> readable_byte_stream_controller_fill_read_request_from_queue(ReadableByteStreamController& controller, JS::NonnullGCPtr<ReadRequest> read_request)
|
||||
void readable_byte_stream_controller_fill_read_request_from_queue(ReadableByteStreamController& controller, JS::NonnullGCPtr<ReadRequest> read_request)
|
||||
{
|
||||
auto& vm = controller.vm();
|
||||
auto& realm = controller.realm();
|
||||
|
@ -2673,12 +2673,10 @@ WebIDL::ExceptionOr<void> readable_byte_stream_controller_fill_read_request_from
|
|||
readable_byte_stream_controller_handle_queue_drain(controller);
|
||||
|
||||
// 6. Let view be ! Construct(%Uint8Array%, « entry’s buffer, entry’s byte offset, entry’s byte length »).
|
||||
auto view = MUST_OR_THROW_OOM(JS::construct(vm, *realm.intrinsics().uint8_array_constructor(), entry.buffer, JS::Value(entry.byte_offset), JS::Value(entry.byte_length)));
|
||||
auto view = MUST(JS::construct(vm, *realm.intrinsics().uint8_array_constructor(), entry.buffer, JS::Value(entry.byte_offset), JS::Value(entry.byte_length)));
|
||||
|
||||
// 7. Perform readRequest’s chunk steps, given view.
|
||||
read_request->on_chunk(view);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#readable-byte-stream-controller-get-desired-size
|
||||
|
@ -3166,7 +3164,7 @@ WebIDL::ExceptionOr<void> readable_byte_stream_controller_enqueue(ReadableByteSt
|
|||
// 9. If ! ReadableStreamHasDefaultReader(stream) is true,
|
||||
if (readable_stream_has_default_reader(*stream)) {
|
||||
// 1. Perform ! ReadableByteStreamControllerProcessReadRequestsUsingQueue(controller).
|
||||
TRY(readable_byte_stream_controller_process_read_requests_using_queue(controller));
|
||||
readable_byte_stream_controller_process_read_requests_using_queue(controller);
|
||||
|
||||
// 2. If ! ReadableStreamGetNumReadRequests(stream) is 0,
|
||||
if (readable_stream_get_num_read_requests(*stream) == 0) {
|
||||
|
@ -3191,7 +3189,7 @@ WebIDL::ExceptionOr<void> readable_byte_stream_controller_enqueue(ReadableByteSt
|
|||
}
|
||||
|
||||
// 3. Let transferredView be ! Construct(%Uint8Array%, « transferredBuffer, byteOffset, byteLength »).
|
||||
auto transferred_view = MUST_OR_THROW_OOM(JS::construct(vm, *realm.intrinsics().uint8_array_constructor(), transferred_buffer, JS::Value(byte_offset), JS::Value(byte_length)));
|
||||
auto transferred_view = MUST(JS::construct(vm, *realm.intrinsics().uint8_array_constructor(), transferred_buffer, JS::Value(byte_offset), JS::Value(byte_length)));
|
||||
|
||||
// 4. Perform ! ReadableStreamFulfillReadRequest(stream, transferredView, false).
|
||||
readable_stream_fulfill_read_request(*stream, transferred_view, false);
|
||||
|
@ -3323,7 +3321,7 @@ void readable_byte_stream_controller_process_pull_into_descriptors_using_queue(R
|
|||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#abstract-opdef-readablebytestreamcontrollerprocessreadrequestsusingqueue
|
||||
WebIDL::ExceptionOr<void> readable_byte_stream_controller_process_read_requests_using_queue(ReadableByteStreamController& controller)
|
||||
void readable_byte_stream_controller_process_read_requests_using_queue(ReadableByteStreamController& controller)
|
||||
{
|
||||
// 1. Let reader be controller.[[stream]].[[reader]].
|
||||
auto reader = controller.stream()->reader();
|
||||
|
@ -3336,17 +3334,15 @@ WebIDL::ExceptionOr<void> readable_byte_stream_controller_process_read_requests_
|
|||
while (!readable_stream_default_reader->read_requests().is_empty()) {
|
||||
// 1. If controller.[[queueTotalSize]] is 0, return.
|
||||
if (controller.queue_total_size() == 0.0)
|
||||
return {};
|
||||
return;
|
||||
|
||||
// 2. Let readRequest be reader.[[readRequests]][0].
|
||||
// 3. Remove readRequest from reader.[[readRequests]].
|
||||
auto read_request = readable_stream_default_reader->read_requests().take_first();
|
||||
|
||||
// 4. Perform ! ReadableByteStreamControllerFillReadRequestFromQueue(controller, readRequest).
|
||||
TRY(readable_byte_stream_controller_fill_read_request_from_queue(controller, read_request));
|
||||
readable_byte_stream_controller_fill_read_request_from_queue(controller, read_request);
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#readable-byte-stream-controller-enqueue-chunk-to-queue
|
||||
|
@ -3546,10 +3542,9 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> writable_stream_close(Wri
|
|||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#writable-stream-add-write-request
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> writable_stream_add_write_request(WritableStream& stream)
|
||||
JS::NonnullGCPtr<WebIDL::Promise> writable_stream_add_write_request(WritableStream& stream)
|
||||
{
|
||||
auto& realm = stream.realm();
|
||||
auto& vm = stream.vm();
|
||||
|
||||
// 1. Assert: ! IsWritableStreamLocked(stream) is true.
|
||||
VERIFY(is_writable_stream_locked(stream));
|
||||
|
@ -3561,7 +3556,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> writable_stream_add_write
|
|||
auto promise = WebIDL::create_promise(realm);
|
||||
|
||||
// 4. Append promise to stream.[[writeRequests]].
|
||||
TRY_OR_THROW_OOM(vm, stream.write_requests().try_append(promise));
|
||||
stream.write_requests().append(promise);
|
||||
|
||||
// 5. Return promise.
|
||||
return promise;
|
||||
|
|
|
@ -97,7 +97,7 @@ WebIDL::ExceptionOr<void> readable_byte_stream_controller_enqueue(ReadableByteSt
|
|||
WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::ArrayBuffer>> transfer_array_buffer(JS::Realm& realm, JS::ArrayBuffer& buffer);
|
||||
WebIDL::ExceptionOr<void> readable_byte_stream_controller_enqueue_detached_pull_into_queue(ReadableByteStreamController& controller, PullIntoDescriptor& pull_into_descriptor);
|
||||
void readable_byte_stream_controller_commit_pull_into_descriptor(ReadableStream&, PullIntoDescriptor const&);
|
||||
WebIDL::ExceptionOr<void> readable_byte_stream_controller_process_read_requests_using_queue(ReadableByteStreamController& controller);
|
||||
void readable_byte_stream_controller_process_read_requests_using_queue(ReadableByteStreamController& controller);
|
||||
void readable_byte_stream_controller_process_pull_into_descriptors_using_queue(ReadableByteStreamController&);
|
||||
void readable_byte_stream_controller_enqueue_chunk_to_queue(ReadableByteStreamController& controller, JS::NonnullGCPtr<JS::ArrayBuffer> buffer, u32 byte_offset, u32 byte_length);
|
||||
WebIDL::ExceptionOr<void> readable_byte_stream_controller_enqueue_cloned_chunk_to_queue(ReadableByteStreamController& controller, JS::ArrayBuffer& buffer, u64 byte_offset, u64 byte_length);
|
||||
|
@ -108,7 +108,7 @@ void readable_byte_stream_controller_clear_algorithms(ReadableByteStreamControll
|
|||
void readable_byte_stream_controller_clear_pending_pull_intos(ReadableByteStreamController&);
|
||||
WebIDL::ExceptionOr<void> readable_byte_stream_controller_close(ReadableByteStreamController&);
|
||||
void readable_byte_stream_controller_error(ReadableByteStreamController&, JS::Value error);
|
||||
WebIDL::ExceptionOr<void> readable_byte_stream_controller_fill_read_request_from_queue(ReadableByteStreamController&, JS::NonnullGCPtr<ReadRequest>);
|
||||
void readable_byte_stream_controller_fill_read_request_from_queue(ReadableByteStreamController&, JS::NonnullGCPtr<ReadRequest>);
|
||||
bool readable_byte_stream_controller_fill_pull_into_descriptor_from_queue(ReadableByteStreamController&, PullIntoDescriptor&);
|
||||
Optional<double> readable_byte_stream_controller_get_desired_size(ReadableByteStreamController const&);
|
||||
void readable_byte_stream_controller_handle_queue_drain(ReadableByteStreamController&);
|
||||
|
@ -127,7 +127,7 @@ WebIDL::ExceptionOr<void> set_up_writable_stream_default_writer(WritableStreamDe
|
|||
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> writable_stream_abort(WritableStream&, JS::Value reason);
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> writable_stream_close(WritableStream&);
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> writable_stream_add_write_request(WritableStream&);
|
||||
JS::NonnullGCPtr<WebIDL::Promise> writable_stream_add_write_request(WritableStream&);
|
||||
bool writable_stream_close_queued_or_in_flight(WritableStream const&);
|
||||
WebIDL::ExceptionOr<void> writable_stream_deal_with_rejection(WritableStream&, JS::Value error);
|
||||
WebIDL::ExceptionOr<void> writable_stream_finish_erroring(WritableStream&);
|
||||
|
|
|
@ -112,7 +112,6 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> ReadableByteStreamControl
|
|||
// https://streams.spec.whatwg.org/#rbs-controller-private-pull
|
||||
WebIDL::ExceptionOr<void> ReadableByteStreamController::pull_steps(JS::NonnullGCPtr<ReadRequest> read_request)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
auto& realm = this->realm();
|
||||
|
||||
// 1. Let stream be this.[[stream]].
|
||||
|
@ -126,7 +125,8 @@ WebIDL::ExceptionOr<void> ReadableByteStreamController::pull_steps(JS::NonnullGC
|
|||
VERIFY(readable_stream_get_num_read_requests(*m_stream) == 0);
|
||||
|
||||
// 2. Perform ! ReadableByteStreamControllerFillReadRequestFromQueue(this, readRequest).
|
||||
TRY(readable_byte_stream_controller_fill_read_request_from_queue(*this, read_request));
|
||||
readable_byte_stream_controller_fill_read_request_from_queue(*this, read_request);
|
||||
|
||||
// 3. Return.
|
||||
return {};
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ WebIDL::ExceptionOr<void> ReadableByteStreamController::pull_steps(JS::NonnullGC
|
|||
};
|
||||
|
||||
// 4. Append pullIntoDescriptor to this.[[pendingPullIntos]].
|
||||
TRY_OR_THROW_OOM(vm, m_pending_pull_intos.try_append(move(pull_into_descriptor)));
|
||||
m_pending_pull_intos.append(move(pull_into_descriptor));
|
||||
}
|
||||
|
||||
// 6. Perform ! ReadableStreamAddReadRequest(stream, readRequest).
|
||||
|
@ -176,8 +176,6 @@ WebIDL::ExceptionOr<void> ReadableByteStreamController::pull_steps(JS::NonnullGC
|
|||
// https://streams.spec.whatwg.org/#rbs-controller-private-pull
|
||||
WebIDL::ExceptionOr<void> ReadableByteStreamController::release_steps()
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
|
||||
// 1. If this.[[pendingPullIntos]] is not empty,
|
||||
if (!m_pending_pull_intos.is_empty()) {
|
||||
// 1. Let firstPendingPullInto be this.[[pendingPullIntos]][0].
|
||||
|
@ -188,7 +186,7 @@ WebIDL::ExceptionOr<void> ReadableByteStreamController::release_steps()
|
|||
|
||||
// 3. Set this.[[pendingPullIntos]] to the list « firstPendingPullInto ».
|
||||
m_pending_pull_intos.clear();
|
||||
TRY_OR_THROW_OOM(vm, m_pending_pull_intos.try_append(first_pending_pull_into));
|
||||
m_pending_pull_intos.append(first_pending_pull_into);
|
||||
}
|
||||
|
||||
return {};
|
||||
|
|
Loading…
Add table
Reference in a new issue