CountQueuingStrategy.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/#countqueuingstrategy
  14. class CountQueuingStrategy final : public Bindings::PlatformObject {
  15. WEB_PLATFORM_OBJECT(CountQueuingStrategy, Bindings::PlatformObject);
  16. JS_DECLARE_ALLOCATOR(CountQueuingStrategy);
  17. public:
  18. static WebIDL::ExceptionOr<JS::NonnullGCPtr<CountQueuingStrategy>> construct_impl(JS::Realm&, QueuingStrategyInit const&);
  19. virtual ~CountQueuingStrategy() override;
  20. // https://streams.spec.whatwg.org/#cqs-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 CountQueuingStrategy(JS::Realm&, double high_water_mark);
  30. virtual void initialize(JS::Realm&) override;
  31. // https://streams.spec.whatwg.org/#countqueuingstrategy-highwatermark
  32. double m_high_water_mark { 0 };
  33. };
  34. }