ByteLengthQueuingStrategy.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (c) 2023, Shannon Booth <shannon@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Forward.h>
  8. #include <LibJS/Forward.h>
  9. #include <LibWeb/Bindings/PlatformObject.h>
  10. #include <LibWeb/Forward.h>
  11. #include <LibWeb/Streams/QueuingStrategyInit.h>
  12. namespace Web::Streams {
  13. // https://streams.spec.whatwg.org/#bytelengthqueuingstrategy
  14. class ByteLengthQueuingStrategy final : public Bindings::PlatformObject {
  15. WEB_PLATFORM_OBJECT(ByteLengthQueuingStrategy, Bindings::PlatformObject);
  16. JS_DECLARE_ALLOCATOR(ByteLengthQueuingStrategy);
  17. public:
  18. static WebIDL::ExceptionOr<JS::NonnullGCPtr<ByteLengthQueuingStrategy>> construct_impl(JS::Realm&, QueuingStrategyInit const&);
  19. virtual ~ByteLengthQueuingStrategy() override;
  20. // https://streams.spec.whatwg.org/#blqs-high-water-mark
  21. double high_water_mark() const
  22. {
  23. // The highWaterMark getter steps are:
  24. // 1. Return this.[[highWaterMark]].
  25. return m_high_water_mark;
  26. }
  27. WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> size();
  28. private:
  29. explicit ByteLengthQueuingStrategy(JS::Realm&, double high_water_mark);
  30. virtual void initialize(JS::Realm&) override;
  31. // https://streams.spec.whatwg.org/#bytelengthqueuingstrategy-highwatermark
  32. double m_high_water_mark { 0 };
  33. };
  34. }