mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-03-23 05:46:06 +00:00
LibWeb: Convert Platform::Timer to JS::SafeFunction
This commit is contained in:
@@ -17,7 +17,7 @@ NonnullRefPtr<Timer> Timer::create()
|
||||
return EventLoopPlugin::the().create_timer();
|
||||
}
|
||||
|
||||
NonnullRefPtr<Timer> Timer::create_repeating(int interval_ms, Function<void()>&& timeout_handler)
|
||||
NonnullRefPtr<Timer> Timer::create_repeating(int interval_ms, JS::SafeFunction<void()>&& timeout_handler)
|
||||
{
|
||||
auto timer = EventLoopPlugin::the().create_timer();
|
||||
timer->set_single_shot(false);
|
||||
@@ -26,7 +26,7 @@ NonnullRefPtr<Timer> Timer::create_repeating(int interval_ms, Function<void()>&&
|
||||
return timer;
|
||||
}
|
||||
|
||||
NonnullRefPtr<Timer> Timer::create_single_shot(int interval_ms, Function<void()>&& timeout_handler)
|
||||
NonnullRefPtr<Timer> Timer::create_single_shot(int interval_ms, JS::SafeFunction<void()>&& timeout_handler)
|
||||
{
|
||||
auto timer = EventLoopPlugin::the().create_timer();
|
||||
timer->set_single_shot(true);
|
||||
|
||||
@@ -6,16 +6,16 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Function.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <LibJS/SafeFunction.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);
|
||||
static NonnullRefPtr<Timer> create_repeating(int interval_ms, JS::SafeFunction<void()>&& timeout_handler);
|
||||
static NonnullRefPtr<Timer> create_single_shot(int interval_ms, JS::SafeFunction<void()>&& timeout_handler);
|
||||
|
||||
virtual ~Timer();
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
virtual bool is_single_shot() const = 0;
|
||||
virtual void set_single_shot(bool) = 0;
|
||||
|
||||
Function<void()> on_timeout;
|
||||
JS::SafeFunction<void()> on_timeout;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user