ReadableStreamBYOBRequest.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibJS/Runtime/TypedArray.h>
  8. #include <LibWeb/Bindings/PlatformObject.h>
  9. #include <LibWeb/Forward.h>
  10. #include <LibWeb/Streams/ReadableByteStreamController.h>
  11. namespace Web::Streams {
  12. // https://streams.spec.whatwg.org/#readablestreambyobrequest
  13. class ReadableStreamBYOBRequest : public Bindings::PlatformObject {
  14. WEB_PLATFORM_OBJECT(ReadableStreamBYOBRequest, Bindings::PlatformObject);
  15. public:
  16. virtual ~ReadableStreamBYOBRequest() override = default;
  17. JS::GCPtr<JS::TypedArrayBase> view();
  18. void set_controller(JS::GCPtr<ReadableByteStreamController> value) { m_controller = value; }
  19. void set_view(JS::GCPtr<JS::TypedArrayBase> value) { m_view = value; }
  20. private:
  21. explicit ReadableStreamBYOBRequest(JS::Realm&);
  22. virtual void visit_edges(Cell::Visitor&) override;
  23. // https://streams.spec.whatwg.org/#readablestreambyobrequest-controller
  24. // The parent ReadableByteStreamController instance
  25. JS::GCPtr<ReadableByteStreamController> m_controller;
  26. // https://streams.spec.whatwg.org/#readablestreambyobrequest-view
  27. // A typed array representing the destination region to which the controller can write generated data, or null after the BYOB request has been invalidated.
  28. JS::GCPtr<JS::TypedArrayBase> m_view;
  29. };
  30. }