ByteLengthQueuingStrategy.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. public:
  17. static WebIDL::ExceptionOr<JS::NonnullGCPtr<ByteLengthQueuingStrategy>> construct_impl(JS::Realm&, QueuingStrategyInit const&);
  18. virtual ~ByteLengthQueuingStrategy() override;
  19. // https://streams.spec.whatwg.org/#blqs-high-water-mark
  20. double high_water_mark() const
  21. {
  22. // The highWaterMark getter steps are:
  23. // 1. Return this.[[highWaterMark]].
  24. return m_high_water_mark;
  25. }
  26. WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> size();
  27. private:
  28. explicit ByteLengthQueuingStrategy(JS::Realm&, double high_water_mark);
  29. virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
  30. // https://streams.spec.whatwg.org/#bytelengthqueuingstrategy-highwatermark
  31. double m_high_water_mark { 0 };
  32. };
  33. }