/* * Copyright (c) 2023, Matthew Olsson * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include namespace Web::Streams { // https://streams.spec.whatwg.org/#writablestreamdefaultwriter class WritableStreamDefaultWriter final : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(WritableStreamDefaultWriter, Bindings::PlatformObject); public: static WebIDL::ExceptionOr> construct_impl(JS::Realm&, JS::NonnullGCPtr); virtual ~WritableStreamDefaultWriter() override = default; JS::GCPtr closed(); WebIDL::ExceptionOr> desired_size() const; JS::GCPtr ready(); WebIDL::ExceptionOr> abort(JS::Value reason); WebIDL::ExceptionOr> close(); WebIDL::ExceptionOr release_lock(); WebIDL::ExceptionOr> write(JS::Value chunk); JS::GCPtr closed_promise() { return m_closed_promise; } void set_closed_promise(JS::GCPtr value) { m_closed_promise = value; } JS::GCPtr ready_promise() { return m_ready_promise; } void set_ready_promise(JS::GCPtr value) { m_ready_promise = value; } JS::GCPtr stream() const { return m_stream; } JS::GCPtr stream() { return m_stream; } void set_stream(JS::GCPtr value) { m_stream = value; } private: explicit WritableStreamDefaultWriter(JS::Realm&); virtual JS::ThrowCompletionOr initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; // https://streams.spec.whatwg.org/#writablestreamdefaultwriter-closedpromise // A promise returned by the writer’s closed getter JS::GCPtr m_closed_promise; // https://streams.spec.whatwg.org/#writablestreamdefaultwriter-readypromise // A promise returned by the writer’s ready getter JS::GCPtr m_ready_promise; // https://streams.spec.whatwg.org/#writablestreamdefaultwriter-stream // A WritableStream instance that owns this reader JS::GCPtr m_stream; }; }