Line | Count | Source (jump to first uncovered line) |
1 | /* | |
2 | * Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org> | |
3 | * Copyright (c) 2023, Shannon Booth <shannon@serenityos.org> | |
4 | * | |
5 | * SPDX-License-Identifier: BSD-2-Clause | |
6 | */ | |
7 | ||
8 | #pragma once | |
9 | ||
10 | #include <LibWeb/Bindings/PlatformObject.h> | |
11 | #include <LibWeb/Forward.h> | |
12 | #include <LibWeb/Streams/ReadableByteStreamController.h> | |
13 | #include <LibWeb/WebIDL/Types.h> | |
14 | ||
15 | namespace Web::Streams { | |
16 | ||
17 | // https://streams.spec.whatwg.org/#readablestreambyobrequest | |
18 | class ReadableStreamBYOBRequest : public Bindings::PlatformObject { | |
19 | WEB_PLATFORM_OBJECT(ReadableStreamBYOBRequest, Bindings::PlatformObject); | |
20 | JS_DECLARE_ALLOCATOR(ReadableStreamBYOBRequest); | |
21 | ||
22 | public: | |
23 | virtual ~ReadableStreamBYOBRequest() override = default; | |
24 | ||
25 | JS::GCPtr<WebIDL::ArrayBufferView> view(); | |
26 | ||
27 | 0 | void set_controller(JS::GCPtr<ReadableByteStreamController> value) { m_controller = value; } |
28 | ||
29 | 0 | void set_view(JS::GCPtr<WebIDL::ArrayBufferView> value) { m_view = value; } |
30 | ||
31 | WebIDL::ExceptionOr<void> respond(WebIDL::UnsignedLongLong bytes_written); | |
32 | WebIDL::ExceptionOr<void> respond_with_new_view(JS::Handle<WebIDL::ArrayBufferView> const& view); | |
33 | ||
34 | private: | |
35 | explicit ReadableStreamBYOBRequest(JS::Realm&); | |
36 | ||
37 | virtual void initialize(JS::Realm&) override; | |
38 | ||
39 | virtual void visit_edges(Cell::Visitor&) override; | |
40 | ||
41 | // https://streams.spec.whatwg.org/#readablestreambyobrequest-controller | |
42 | // The parent ReadableByteStreamController instance | |
43 | JS::GCPtr<ReadableByteStreamController> m_controller; | |
44 | ||
45 | // https://streams.spec.whatwg.org/#readablestreambyobrequest-view | |
46 | // A typed array representing the destination region to which the controller can write generated data, or null after the BYOB request has been invalidated. | |
47 | JS::GCPtr<WebIDL::ArrayBufferView> m_view; | |
48 | }; | |
49 | ||
50 | } |