mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:58:11 +00:00
LibWeb: Add the WritableStreamDefaultController
This commit is contained in:
parent
83701ec54b
commit
868cd95069
10 changed files with 393 additions and 5 deletions
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Streams/WritableStream.h>
|
||||
#include <LibWeb/Streams/WritableStreamDefaultController.h>
|
||||
|
||||
namespace Web::Streams {
|
||||
|
||||
// https://streams.spec.whatwg.org/#ws-default-controller-error
|
||||
WebIDL::ExceptionOr<void> WritableStreamDefaultController::error(JS::Value error)
|
||||
{
|
||||
// 1. Let state be this.[[stream]].[[state]].
|
||||
auto state = m_stream->state();
|
||||
|
||||
// 2. If state is not "writable", return.
|
||||
if (state != WritableStream::State::Writable)
|
||||
return {};
|
||||
|
||||
// 3. Perform ! WritableStreamDefaultControllerError(this, e).
|
||||
return writable_stream_default_controller_error(*this, error);
|
||||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#ws-default-controller-private-abort
|
||||
WebIDL::ExceptionOr<JS::GCPtr<WebIDL::Promise>> WritableStreamDefaultController::abort_steps(JS::Value reason)
|
||||
{
|
||||
// 1. Let result be the result of performing this.[[abortAlgorithm]], passing reason.
|
||||
auto result = TRY((*m_abort_algorithm)(reason));
|
||||
|
||||
// 2. Perform ! WritableStreamDefaultControllerClearAlgorithms(this).
|
||||
writable_stream_default_controller_clear_algorithms(*this);
|
||||
|
||||
// 3. Return result.
|
||||
return result;
|
||||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#ws-default-controller-private-error
|
||||
void WritableStreamDefaultController::error_steps()
|
||||
{
|
||||
// 1. Perform ! ResetQueue(this).
|
||||
reset_queue(*this);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue