/* * Copyright (c) 2022, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include namespace Web::Platform { class Timer : public RefCounted { public: static NonnullRefPtr create(); static NonnullRefPtr create_repeating(int interval_ms, Function&& timeout_handler); static NonnullRefPtr create_single_shot(int interval_ms, Function&& timeout_handler); virtual ~Timer(); virtual void start() = 0; virtual void start(int interval_ms) = 0; virtual void restart() = 0; virtual void restart(int interval_ms) = 0; virtual void stop() = 0; virtual void set_active(bool) = 0; virtual bool is_active() const = 0; virtual int interval() const = 0; virtual void set_interval(int interval_ms) = 0; virtual bool is_single_shot() const = 0; virtual void set_single_shot(bool) = 0; Function on_timeout; }; }