1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:17:44 +00:00

LibWeb: Convert Platform::Timer to JS::SafeFunction

This commit is contained in:
Luke Wilde 2023-02-28 19:55:42 +00:00 committed by Linus Groh
parent 4bc0d8e4c8
commit 90cc45b7ec
2 changed files with 6 additions and 6 deletions

View file

@ -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);

View file

@ -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;
};
}