/* * Copyright (c) 2023, Shannon Booth * Copyright (c) 2023, Matthew Olsson * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include #include #include namespace Web::Streams { JS_DEFINE_ALLOCATOR(CountQueuingStrategy); // https://streams.spec.whatwg.org/#blqs-constructor WebIDL::ExceptionOr> CountQueuingStrategy::construct_impl(JS::Realm& realm, QueuingStrategyInit const& init) { // The new CountQueuingStrategy(init) constructor steps are: // 1. Set this.[[highWaterMark]] to init["highWaterMark"]. return realm.heap().allocate(realm, realm, init.high_water_mark); } CountQueuingStrategy::CountQueuingStrategy(JS::Realm& realm, double high_water_mark) : PlatformObject(realm) , m_high_water_mark(high_water_mark) { } CountQueuingStrategy::~CountQueuingStrategy() = default; // https://streams.spec.whatwg.org/#cqs-size WebIDL::ExceptionOr> CountQueuingStrategy::size() { // 1. Return this's relevant global object's count queuing strategy size function. return global_object().count_queuing_strategy_size_function(); } void CountQueuingStrategy::initialize(JS::Realm& realm) { Base::initialize(realm); set_prototype(&Bindings::ensure_web_prototype(realm, "CountQueuingStrategy"_fly_string)); } }