/* * Copyright (c) 2022, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include namespace Web::Platform { Timer::~Timer() = default; void Timer::visit_edges(JS::Cell::Visitor& visitor) { Base::visit_edges(visitor); visitor.visit(on_timeout); } JS::NonnullGCPtr Timer::create(JS::Heap& heap) { return EventLoopPlugin::the().create_timer(heap); } JS::NonnullGCPtr Timer::create_repeating(JS::Heap& heap, int interval_ms, JS::GCPtr> timeout_handler) { auto timer = EventLoopPlugin::the().create_timer(heap); timer->set_single_shot(false); timer->set_interval(interval_ms); timer->on_timeout = move(timeout_handler); return timer; } JS::NonnullGCPtr Timer::create_single_shot(JS::Heap& heap, int interval_ms, JS::GCPtr> timeout_handler) { auto timer = EventLoopPlugin::the().create_timer(heap); timer->set_single_shot(true); timer->set_interval(interval_ms); timer->on_timeout = move(timeout_handler); return timer; } }