mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-11 01:06:01 +03:00
9567e211e7
Instead of using Core::EventLoop and Core::Timer directly, LibWeb now goes through a Web::Platform abstraction layer instead. This will allow us to plug in Qt's event loop (and QTimer) over in Ladybird, to avoid having to deal with multiple event loops.
41 lines
1013 B
C++
41 lines
1013 B
C++
/*
|
|
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Function.h>
|
|
#include <AK/RefCounted.h>
|
|
|
|
namespace Web::Platform {
|
|
|
|
class Timer : public RefCounted<Timer> {
|
|
public:
|
|
static NonnullRefPtr<Timer> create();
|
|
static NonnullRefPtr<Timer> create_repeating(int interval_ms, Function<void()>&& timeout_handler);
|
|
static NonnullRefPtr<Timer> create_single_shot(int interval_ms, Function<void()>&& 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<void()> on_timeout;
|
|
};
|
|
|
|
}
|