Truly independent web browser
LibCore+Everywhere: Take AK::Duration in Core::Timer
Shannon Boothc6f97cd185b5
diff --git a/Libraries/LibCore/Timer.cpp b/Libraries/LibCore/Timer.cppindex 107203650cb..b78b32cebd2 100644--- a/Libraries/LibCore/Timer.cpp+++ b/Libraries/LibCore/Timer.cpp@@ -5,7 +5,6 @@* SPDX-License-Identifier: BSD-2-Clause*/-#include <AK/Time.h>#include <LibCore/Timer.h>namespace Core {@@ -15,14 +14,14 @@ NonnullRefPtr<Timer> Timer::create()return adopt_ref(*new Timer);}-NonnullRefPtr<Timer> Timer::create_repeating(int interval_ms, Function<void()>&& timeout_handler)+NonnullRefPtr<Timer> Timer::create_repeating(AK::Duration interval, Function<void()>&& timeout_handler){- return adopt_ref(*new Timer(interval_ms, move(timeout_handler)));+ return adopt_ref(*new Timer(interval, move(timeout_handler)));}-NonnullRefPtr<Timer> Timer::create_single_shot(int interval_ms, Function<void()>&& timeout_handler)+NonnullRefPtr<Timer> Timer::create_single_shot(AK::Duration interval, Function<void()>&& timeout_handler){- auto timer = adopt_ref(*new Timer(interval_ms, move(timeout_handler)));+ auto timer = adopt_ref(*new Timer(interval, move(timeout_handler)));timer->set_single_shot(true);return timer;}@@ -31,36 +30,36 @@ Timer::~Timer() = default;Timer::Timer() = default;-Timer::Timer(int interval_ms, Function<void()>&& timeout_handler)+Timer::Timer(AK::Duration interval, Function<void()>&& timeout_handler): on_timeout(move(timeout_handler))- , m_interval_ms(interval_ms)+ , m_interval(interval){}void Timer::start(){- start(m_interval_ms);+ start(m_interval);}-void Timer::start(int interval_ms)+void Timer::start(AK::Duration interval){if (m_active)return;- m_interval_ms = interval_ms;- start_timer(AK::Duration::from_milliseconds(interval_ms));+ m_interval = interval;+ start_timer(interval);m_active = true;}void Timer::restart(){- restart(m_interval_ms);+ restart(m_interval);}-void Timer::restart(int interval_ms)+void Timer::restart(AK::Duration interval){if (m_active)stop();- start(interval_ms);+ start(interval);}void Timer::stop()@@ -86,7 +85,7 @@ void Timer::timer_event(TimerEvent&)else {if (m_interval_dirty) {stop();- start(m_interval_ms);+ start(m_interval);m_interval_dirty = false;}}diff --git a/Libraries/LibCore/Timer.h b/Libraries/LibCore/Timer.hindex 9d6cd3faeca..60f1cd1d2a0 100644--- a/Libraries/LibCore/Timer.h+++ b/Libraries/LibCore/Timer.h@@ -8,6 +8,7 @@#pragma once#include <AK/Function.h>+#include <AK/Time.h>#include <LibCore/EventReceiver.h>#include <LibCore/Export.h>@@ -18,26 +19,26 @@ class CORE_API Timer final : public EventReceiver {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(AK::Duration interval, Function<void()>&& timeout_handler);+ static NonnullRefPtr<Timer> create_single_shot(AK::Duration interval, Function<void()>&& timeout_handler);virtual ~Timer() override;void start();- void start(int interval_ms);+ void start(AK::Duration interval);void restart();- void restart(int interval_ms);+ void restart(AK::Duration interval);void stop();void set_active(bool);bool is_active() const { return m_active; }- int interval() const { return m_interval_ms; }- void set_interval(int interval_ms)+ AK::Duration interval() const { return m_interval; }+ void set_interval(AK::Duration interval){- if (m_interval_ms == interval_ms)+ if (m_interval == interval)return;- m_interval_ms = interval_ms;+ m_interval = interval;m_interval_dirty = true;}@@ -48,14 +49,14 @@ public:private:Timer();- Timer(int interval_ms, Function<void()>&& timeout_handler);+ Timer(AK::Duration interval, Function<void()>&& timeout_handler);virtual void timer_event(TimerEvent&) override;bool m_active { false };bool m_single_shot { false };bool m_interval_dirty { false };- int m_interval_ms { 0 };+ AK::Duration m_interval;};}diff --git a/Libraries/LibDNS/Resolver.h b/Libraries/LibDNS/Resolver.hindex 4132e82fda0..f1c7e55a26f 100644--- a/Libraries/LibDNS/Resolver.h+++ b/Libraries/LibDNS/Resolver.h@@ -595,7 +595,7 @@ public:in_flight->question = { name, type, class_ };in_flight->dnssec_ok = dnssec_ok;in_flight->waiters.append(promise);- in_flight->retry_timer = Core::Timer::create_single_shot(query_retry_interval_ms, [this, id] { retry_query(id); });+ in_flight->retry_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(query_retry_interval_ms), [this, id] { retry_query(id); });auto* raw = in_flight.ptr();m_in_flight.set(key, move(in_flight));m_in_flight_by_id.set(id, key);@@ -930,7 +930,7 @@ private:return;constexpr int RESOLUTION_DELAY_MS = 50;auto weak_state = state.make_weak_ptr();- state.grace_timer = Core::Timer::create_single_shot(RESOLUTION_DELAY_MS, [weak_state] {+ state.grace_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(RESOLUTION_DELAY_MS), [weak_state] {if (auto state = weak_state.strong_ref())try_finalize_pending_system_resolution(*state);});diff --git a/Libraries/LibGC/Heap.cpp b/Libraries/LibGC/Heap.cppindex 9c517899bcd..4b3a3d7332a 100644--- a/Libraries/LibGC/Heap.cpp+++ b/Libraries/LibGC/Heap.cpp@@ -1502,7 +1502,7 @@ void Heap::finish_pending_incremental_sweep()void Heap::start_incremental_sweep_timer(){if (!m_incremental_sweep_timer) {- m_incremental_sweep_timer = Core::Timer::create_repeating(GC_INCREMENTAL_SWEEP_INTERVAL_MS, [this] {+ m_incremental_sweep_timer = Core::Timer::create_repeating(AK::Duration::from_milliseconds(GC_INCREMENTAL_SWEEP_INTERVAL_MS), [this] {sweep_on_timer();});}@@ -1549,7 +1549,7 @@ void Heap::sweep_on_timer()void Heap::start_idle_gc_timer(){if (!m_idle_gc_timer) {- m_idle_gc_timer = Core::Timer::create_repeating(GC_IDLE_GC_INTERVAL_MS, [this] {+ m_idle_gc_timer = Core::Timer::create_repeating(AK::Duration::from_milliseconds(GC_IDLE_GC_INTERVAL_MS), [this] {idle_gc_on_timer();});}diff --git a/Libraries/LibGC/Timer.cpp b/Libraries/LibGC/Timer.cppindex b508e6671d4..6447d5b4875 100644--- a/Libraries/LibGC/Timer.cpp+++ b/Libraries/LibGC/Timer.cpp@@ -43,7 +43,7 @@ void Timer::start(u64 timeout_ms, GC::Ref<GC::Function<void()>> on_timeout)}};- m_timer->set_interval(static_cast<int>(timeout_ms));+ m_timer->set_interval(AK::Duration::from_milliseconds(static_cast<int>(timeout_ms)));m_timer->set_single_shot(true);m_timer->start();}@@ -57,7 +57,7 @@ void Timer::start_repeating(u64 interval_ms, GC::Ref<GC::Function<void()>> on_tim_on_timeout->function()();};- m_timer->set_interval(static_cast<int>(interval_ms));+ m_timer->set_interval(AK::Duration::from_milliseconds(static_cast<int>(interval_ms)));m_timer->set_single_shot(false);m_timer->start();}diff --git a/Libraries/LibMedia/PlaybackStates/PlayingStateHandler.cpp b/Libraries/LibMedia/PlaybackStates/PlayingStateHandler.cppindex caa13e45987..01577d32db6 100644--- a/Libraries/LibMedia/PlaybackStates/PlayingStateHandler.cpp+++ b/Libraries/LibMedia/PlaybackStates/PlayingStateHandler.cpp@@ -74,13 +74,13 @@ void PlayingStateHandler::update_unticked_end_of_stream_timer()}if (m_unticked_end_of_stream_timer == nullptr) {- m_unticked_end_of_stream_timer = Core::Timer::create_single_shot(0, [&manager = manager()] {+ m_unticked_end_of_stream_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(0), [&manager = manager()] {manager.update_pipeline_state();});}auto delay_seconds = (latest_verified_end_time - now).to_seconds_f64() / playback_rate;- m_unticked_end_of_stream_timer->restart(max(1, AK::clamp_to<int>(AK::ceil(delay_seconds * 1'000.0))));+ m_unticked_end_of_stream_timer->restart(AK::Duration::from_milliseconds(max(1, AK::clamp_to<int>(AK::ceil(delay_seconds * 1'000.0)))));}}diff --git a/Libraries/LibMedia/Sinks/AudioPlaybackSink.cpp b/Libraries/LibMedia/Sinks/AudioPlaybackSink.cppindex 61f2d774d35..27adf6f02ca 100644--- a/Libraries/LibMedia/Sinks/AudioPlaybackSink.cpp+++ b/Libraries/LibMedia/Sinks/AudioPlaybackSink.cpp@@ -249,7 +249,7 @@ AudioPlaybackSink::AudioPlaybackSink(NonnullRefPtr<OutputThreadData> output_thre, m_output_thread_data(move(output_thread_data)), m_time_reader(move(time_reader)){- m_played_out_timer = Core::Timer::create_single_shot(0, [this] {+ m_played_out_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(0), [this] {dispatch_waiting_status_once_played_out();});}@@ -526,7 +526,7 @@ void AudioPlaybackSink::dispatch_waiting_status_once_played_out()// Timers are imprecise, so this may fire early, in which case it waits for the remainder.if (m_stream_state == StreamState::Playing) {auto delay = AK::Duration::from_time_units(frames_until_played_out, 1, sample_specification.sample_rate());- m_played_out_timer->start(max(1, AK::clamp_to<int>(delay.to_milliseconds())));+ m_played_out_timer->start(AK::Duration::from_milliseconds(max(1, AK::clamp_to<int>(delay.to_milliseconds()))));}return;}diff --git a/Libraries/LibMediaClient/Client.cpp b/Libraries/LibMediaClient/Client.cppindex 10f01a80077..e3fa01e6aa3 100644--- a/Libraries/LibMediaClient/Client.cpp+++ b/Libraries/LibMediaClient/Client.cpp@@ -226,7 +226,7 @@ void Client::update_idle_timer()return;}if (!m_idle_timer) {- m_idle_timer = Core::Timer::create_single_shot(IDLE_EXIT_DELAY_MS, [this] {+ m_idle_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(IDLE_EXIT_DELAY_MS), [this] {// Clearing the client reference closes the connection and causes the server to exit.if (*s_client == this)*s_client = nullptr;diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cppindex 9a7b02fed2c..def9e590531 100644--- a/Libraries/LibWeb/DOM/Document.cpp+++ b/Libraries/LibWeb/DOM/Document.cpp@@ -2795,7 +2795,7 @@ void Document::arm_compositor_animation_timers_for_testing(Badge<Internals::Inte{stop_compositor_animation_timers();schedule_compositor_animation_wakeup(NumericLimits<int>::max());- m_compositor_animation_observation_timer = Core::Timer::create_single_shot(NumericLimits<int>::max(), GC::weak_callback(*this, [](auto&) { }));+ m_compositor_animation_observation_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(NumericLimits<int>::max()), GC::weak_callback(*this, [](auto&) { }));m_compositor_animation_observation_timer->start();}@@ -7587,7 +7587,7 @@ void Document::shared_declarative_refresh_steps(Utf16View input, GC::Ptr<HTML::H// given, document's active sandboxing flag set does not have the sandboxed automatic features browsing context// flag set, then navigate document's node navigable to urlRecord using document, with historyHandling set to// "replace".- m_active_refresh_timer = Core::Timer::create_single_shot(time * 1000, [this, has_meta_element = !!meta_element, url_record = move(url_record)]() {+ m_active_refresh_timer = Core::Timer::create_single_shot(AK::Duration::from_seconds(time), [this, has_meta_element = !!meta_element, url_record = move(url_record)]() {if (has_meta_element && has_flag(active_sandboxing_flag_set(), HTML::SandboxingFlagSet::SandboxedAutomaticFeatures))return;@@ -8178,7 +8178,7 @@ void Document::schedule_compositor_animation_wakeup(double delay_ms)m_compositor_animation_wakeup_deadline = deadline;if (!m_compositor_animation_wakeup_timer) {- m_compositor_animation_wakeup_timer = Core::Timer::create_single_shot(static_cast<int>(timer_delay_ms), GC::weak_callback(*this, [](auto& document) {+ m_compositor_animation_wakeup_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(static_cast<int>(timer_delay_ms)), GC::weak_callback(*this, [](auto& document) {// Cancelling a finite effect can leave this deadline armed. The single wake-up is harmless: it finds// nothing due and leaves the timer idle unless another effect supplies a deadline.document.m_compositor_animation_wakeup_deadline.clear();@@ -8187,7 +8187,7 @@ void Document::schedule_compositor_animation_wakeup(double delay_ms)document.service_compositor_animation_wakeup(timestamp);}));}- m_compositor_animation_wakeup_timer->restart(static_cast<int>(timer_delay_ms));+ m_compositor_animation_wakeup_timer->restart(AK::Duration::from_milliseconds(static_cast<int>(timer_delay_ms)));}void Document::service_compositor_animation_wakeup(double timestamp)@@ -8978,7 +8978,7 @@ void Document::update_compositor_animations(Layout::BegunRead const& read)m_compositor_animation_observation_timer->stop();} else {if (!m_compositor_animation_observation_timer) {- m_compositor_animation_observation_timer = Core::Timer::create_single_shot(100, GC::weak_callback(*this, [](auto& document) {+ m_compositor_animation_observation_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(100), GC::weak_callback(*this, [](auto& document) {++document.m_style_invalidation_counters.animation_frame_pump_requests;document.page().client().request_frame();document.m_compositor_animation_observation_timer->start();diff --git a/Libraries/LibWeb/HTML/HTMLImageElement.cpp b/Libraries/LibWeb/HTML/HTMLImageElement.cppindex 76c9d02cefe..5d3470a217d 100644--- a/Libraries/LibWeb/HTML/HTMLImageElement.cpp+++ b/Libraries/LibWeb/HTML/HTMLImageElement.cpp@@ -64,7 +64,7 @@ namespace Web::HTML {struct BatchingDispatcher {public:BatchingDispatcher()- : m_timer(Core::Timer::create_single_shot(1, [this] { process(); }))+ : m_timer(Core::Timer::create_single_shot(AK::Duration::from_milliseconds(1), [this] { process(); })){}diff --git a/Libraries/LibWeb/HTML/HTMLMediaElement.cpp b/Libraries/LibWeb/HTML/HTMLMediaElement.cppindex a7582d4ff75..3d7367f3167 100644--- a/Libraries/LibWeb/HTML/HTMLMediaElement.cpp+++ b/Libraries/LibWeb/HTML/HTMLMediaElement.cpp@@ -1975,7 +1975,7 @@ void HTMLMediaElement::start_or_stop_playback_position_update_timer()}if (!m_playback_position_update_timer) {- m_playback_position_update_timer = Core::Timer::create_repeating(playback_position_update_interval_ms, GC::weak_callback(*this, [](auto& self) {+ m_playback_position_update_timer = Core::Timer::create_repeating(AK::Duration::from_milliseconds(playback_position_update_interval_ms), GC::weak_callback(*this, [](auto& self) {self.upon_current_playback_position_possibly_changed();}));}@@ -2737,7 +2737,7 @@ void HTMLMediaElement::note_frame_captured() conststatic constexpr int capture_keepalive_timeout_ms = 5000;m_video_frame_was_recently_captured = true;if (!m_video_frame_capture_keepalive_timer) {- m_video_frame_capture_keepalive_timer = Core::Timer::create_single_shot(capture_keepalive_timeout_ms, GC::weak_callback(*this, [](auto& self) {+ m_video_frame_capture_keepalive_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(capture_keepalive_timeout_ms), GC::weak_callback(*this, [](auto& self) {self.m_video_frame_was_recently_captured = false;}));}diff --git a/Libraries/LibWeb/HTML/LocalNavigable.cpp b/Libraries/LibWeb/HTML/LocalNavigable.cppindex 55a0c78c7a9..2eb2a631460 100644--- a/Libraries/LibWeb/HTML/LocalNavigable.cpp+++ b/Libraries/LibWeb/HTML/LocalNavigable.cpp@@ -5086,7 +5086,7 @@ void LocalNavigable::queue_scrollend_event_after_user_scroll(GC::Ref<DOM::EventT}if (!m_user_scroll_settle_timer) {- m_user_scroll_settle_timer = Core::Timer::create_single_shot(static_cast<int>(Compositing::user_scroll_settle_delay.to_milliseconds()), [this] {+ m_user_scroll_settle_timer = Core::Timer::create_single_shot(Compositing::user_scroll_settle_delay, [this] {user_scroll_did_settle();});}@@ -5710,14 +5710,14 @@ void LocalNavigable::schedule_hover_update_after_async_scroll()static constexpr int hover_update_after_async_scroll_delay_ms = 100;if (!m_async_scroll_hover_update_timer) {- m_async_scroll_hover_update_timer = Core::Timer::create_single_shot(hover_update_after_async_scroll_delay_ms, [this] {+ m_async_scroll_hover_update_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(hover_update_after_async_scroll_delay_ms), [this] {update_hover_after_async_scroll_stops();});m_async_scroll_hover_update_timer->start();return;}- m_async_scroll_hover_update_timer->restart(hover_update_after_async_scroll_delay_ms);+ m_async_scroll_hover_update_timer->restart(AK::Duration::from_milliseconds(hover_update_after_async_scroll_delay_ms));}void LocalNavigable::update_hover_after_async_scroll_stops()diff --git a/Libraries/LibWeb/HTML/MediaControls.cpp b/Libraries/LibWeb/HTML/MediaControls.cppindex fc445c613c5..b2f32c2e273 100644--- a/Libraries/LibWeb/HTML/MediaControls.cpp+++ b/Libraries/LibWeb/HTML/MediaControls.cpp@@ -518,7 +518,7 @@ void MediaControls::submit_pending_scrub_seek()if (!m_scrub_seek_preemption_timer) {constexpr int scrub_seek_preemption_timeout_ms = 500;- m_scrub_seek_preemption_timer = Core::Timer::create_single_shot(scrub_seek_preemption_timeout_ms, [this] {+ m_scrub_seek_preemption_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(scrub_seek_preemption_timeout_ms), [this] {submit_pending_scrub_seek();});m_scrub_seek_preemption_timer->start();@@ -822,7 +822,7 @@ void MediaControls::show_controls()if (!m_hover_timer) {constexpr int hover_timeout_ms = 1000;- m_hover_timer = Core::Timer::create_single_shot(hover_timeout_ms, [&] {+ m_hover_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(hover_timeout_ms), [&] {hide_controls();});m_hover_timer->start();diff --git a/Libraries/LibWeb/HTML/Timer.cpp b/Libraries/LibWeb/HTML/Timer.cppindex 6450aee4069..cc481687adb 100644--- a/Libraries/LibWeb/HTML/Timer.cpp+++ b/Libraries/LibWeb/HTML/Timer.cpp@@ -24,9 +24,9 @@ Timer::Timer(i32 milliseconds, Function<void()> callback, i32 id, Repeating repe, m_earliest_firing(MonotonicTime::now() + AK::Duration::from_milliseconds(milliseconds)){if (repeating == Repeating::Yes)- m_timer = Core::Timer::create_repeating(milliseconds, move(callback));+ m_timer = Core::Timer::create_repeating(AK::Duration::from_milliseconds(milliseconds), move(callback));else- m_timer = Core::Timer::create_single_shot(milliseconds, move(callback));+ m_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(milliseconds), move(callback));}void Timer::visit_edges(Cell::Visitor& visitor)@@ -54,7 +54,7 @@ void Timer::stop()void Timer::restart(i32 milliseconds){m_earliest_firing = MonotonicTime::now() + AK::Duration::from_milliseconds(milliseconds);- m_timer->restart(milliseconds);+ m_timer->restart(AK::Duration::from_milliseconds(milliseconds));}bool Timer::claim_firing()@@ -81,7 +81,7 @@ void Timer::set_callback(Function<void()> callback)void Timer::set_interval(i32 milliseconds){- if (m_timer->interval() != milliseconds)+ if (m_timer->interval() != AK::Duration::from_milliseconds(milliseconds))restart(milliseconds);}diff --git a/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp b/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cppindex 924d577b77f..d6deab48bbb 100644--- a/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp+++ b/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp@@ -1475,7 +1475,7 @@ void WindowOrWorkerGlobalScopeMixin::document_visibility_state_changed(Badge<DOMm_chained_timers_intensively_throttled = false;if (document_is_hidden()) {if (!m_intensive_timer_throttling_grace_timer) {- m_intensive_timer_throttling_grace_timer = Core::Timer::create_single_shot(0, [this] {+ m_intensive_timer_throttling_grace_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(0), [this] {m_chained_timers_intensively_throttled = true;realign_timers();});@@ -1484,7 +1484,7 @@ void WindowOrWorkerGlobalScopeMixin::document_visibility_state_changed(Badge<DOMauto grace_period = document.readiness() == DocumentReadyState::Complete? m_intensive_timer_throttling_grace_period_once_loaded: m_intensive_timer_throttling_grace_period_while_loading;- m_intensive_timer_throttling_grace_timer->restart(timer_delay_from(grace_period));+ m_intensive_timer_throttling_grace_timer->restart(AK::Duration::from_milliseconds(timer_delay_from(grace_period)));} else if (m_intensive_timer_throttling_grace_timer) {m_intensive_timer_throttling_grace_timer->stop();}diff --git a/Libraries/LibWeb/Platform/Timer.cpp b/Libraries/LibWeb/Platform/Timer.cppindex ce0779a6e48..9a204960e8f 100644--- a/Libraries/LibWeb/Platform/Timer.cpp+++ b/Libraries/LibWeb/Platform/Timer.cpp@@ -70,7 +70,7 @@ void Timer::start()void Timer::start(int interval_ms){- m_timer->start(interval_ms);+ m_timer->start(AK::Duration::from_milliseconds(interval_ms));m_activity_root.take(*this);}@@ -82,7 +82,7 @@ void Timer::restart()void Timer::restart(int interval_ms){- m_timer->restart(interval_ms);+ m_timer->restart(AK::Duration::from_milliseconds(interval_ms));m_activity_root.take(*this);}@@ -108,12 +108,12 @@ bool Timer::is_active() constint Timer::interval() const{- return m_timer->interval();+ return m_timer->interval().to_milliseconds();}void Timer::set_interval(int interval_ms){- m_timer->set_interval(interval_ms);+ m_timer->set_interval(AK::Duration::from_milliseconds(interval_ms));}bool Timer::is_single_shot() constdiff --git a/Libraries/LibWeb/WebDriver/Actions.cpp b/Libraries/LibWeb/WebDriver/Actions.cppindex 6a70877fb0a..de39eef60d2 100644--- a/Libraries/LibWeb/WebDriver/Actions.cpp+++ b/Libraries/LibWeb/WebDriver/Actions.cpp@@ -1461,7 +1461,7 @@ public:// NB: The pointer input of the tick is the only asynchronous wait. Key and wheel input fire their events// synchronously. Once both it and the tick duration have passed, the event loop spins a single time.- m_timer = Core::Timer::create_single_shot(static_cast<int>(tick_duration.to_milliseconds()), [this]() {+ m_timer = Core::Timer::create_single_shot(tick_duration, [this]() {m_timer = nullptr;m_tick_duration_has_passed = true;process_next_tick_once_the_tick_is_over();diff --git a/Libraries/LibWebSocket/WebSocket.cpp b/Libraries/LibWebSocket/WebSocket.cppindex ce8af9380ef..f33b9e9533f 100644--- a/Libraries/LibWebSocket/WebSocket.cpp+++ b/Libraries/LibWebSocket/WebSocket.cpp@@ -755,13 +755,13 @@ void WebSocket::set_state(InternalState state)if (state == InternalState::Closing) {if (!m_closing_handshake_timer) {- m_closing_handshake_timer = Core::Timer::create_single_shot(s_closing_handshake_timeout_ms, [this] {+ m_closing_handshake_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(s_closing_handshake_timeout_ms), [this] {if (m_state != InternalState::Closing)return;fail_connection(to_underlying(CloseStatusCode::AbnormalClosure), WebSocket::Error::ServerClosedSocket, "Timed out waiting for the peer's close frame");});} else {- m_closing_handshake_timer->restart(s_closing_handshake_timeout_ms);+ m_closing_handshake_timer->restart(AK::Duration::from_milliseconds(s_closing_handshake_timeout_ms));}} else if (m_closing_handshake_timer) {m_closing_handshake_timer->stop();diff --git a/Libraries/LibWebView/Application.cpp b/Libraries/LibWebView/Application.cppindex 9169b05a7f6..12aebddcd56 100644--- a/Libraries/LibWebView/Application.cpp+++ b/Libraries/LibWebView/Application.cpp@@ -730,7 +730,7 @@ ErrorOr<void> Application::initialize(Main::Arguments const& arguments)TRY(launch_services());if (m_web_content_options.is_test_mode == IsTestMode::No && m_browser_options.enable_content_blocker == EnableContentBlocker::Yes) {- m_content_blocker_list_update_timer = Core::Timer::create_repeating(24 * 60 * 60 * 1000, [this] {+ m_content_blocker_list_update_timer = Core::Timer::create_repeating(AK::Duration::from_seconds(24 * 60 * 60), [this] {start_content_blocker_list_update(ContentBlockerListUpdateTrigger::Automatic);});m_content_blocker_list_update_timer->start();@@ -880,7 +880,7 @@ void Application::start_next_content_blocker_list_update()return 30 * 1000;}();- auto timeout = Core::Timer::create_single_shot(timeout_ms, [this] {+ auto timeout = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(timeout_ms), [this] {warnln("Content blocker list download timed out");stop_current_content_blocker_list_update_and_continue();});@@ -2003,7 +2003,7 @@ static NonnullRefPtr<Core::Timer> load_page_for_screenshot_and_exit(Core::EventLoutln("Taking screenshot after {} seconds", screenshot_timeout);auto timer = Core::Timer::create_single_shot(- screenshot_timeout * 1000,+ AK::Duration::from_seconds(screenshot_timeout),[&]() {view.take_screenshot(ViewImplementation::ScreenshotType::Full)->when_resolved([&event_loop](auto const& path) {diff --git a/Libraries/LibWebView/Autocomplete.cpp b/Libraries/LibWebView/Autocomplete.cppindex a038551bb85..441fa8b636d 100644--- a/Libraries/LibWebView/Autocomplete.cpp+++ b/Libraries/LibWebView/Autocomplete.cpp@@ -339,7 +339,7 @@ void Autocomplete::query_autocomplete_engine(AutocompleteQueryID query_id, Strindbgln_if(WEBVIEW_HISTORY_DEBUG, "[History] Scheduling remote autocomplete suggestions from {} for '{}'", engine->name, m_query);static constexpr auto remote_query_debounce_delay_ms = 100;- m_remote_query_timer = Core::Timer::create_single_shot(remote_query_debounce_delay_ms, [this, query_id, engine = engine.release_value(), query = m_query] {+ m_remote_query_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(remote_query_debounce_delay_ms), [this, query_id, engine = engine.release_value(), query = m_query] {if (m_query_id != query_id)return;start_remote_query(query_id, engine, move(query));diff --git a/Libraries/LibWebView/CookieJar.cpp b/Libraries/LibWebView/CookieJar.cppindex fd777336889..93ecc3f3903 100644--- a/Libraries/LibWebView/CookieJar.cpp+++ b/Libraries/LibWebView/CookieJar.cpp@@ -141,7 +141,7 @@ CookieJar::CookieJar(Optional<PersistedStorage> persisted_storage, IsPrivate is_m_transient_storage.set_cookies(move(cookies));m_persisted_storage->synchronization_timer = Core::Timer::create_repeating(- static_cast<int>(DATABASE_SYNCHRONIZATION_TIMER.to_milliseconds()),+ DATABASE_SYNCHRONIZATION_TIMER,[this]() {for (auto const& it : m_transient_storage.take_dirty_cookies())m_persisted_storage->insert_cookie(it.value);diff --git a/Libraries/LibWebView/CrashReportSubmission.cpp b/Libraries/LibWebView/CrashReportSubmission.cppindex 77284823ecf..7cb2cc3ee19 100644--- a/Libraries/LibWebView/CrashReportSubmission.cpp+++ b/Libraries/LibWebView/CrashReportSubmission.cpp@@ -361,7 +361,7 @@ void CrashReportSubmission::post(StringView path, StringView activity, StringViereturn;}- m_request_timeout = Core::Timer::create_single_shot(request_timeout_ms,+ m_request_timeout = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(request_timeout_ms),[weak_this = make_weak_ptr<CrashReportSubmission>()] {auto self = weak_this.strong_ref();if (!self)@@ -447,7 +447,7 @@ void CrashReportSubmission::fail(String reason, ShouldRetry should_retry, Optionif (on_retry)on_retry(move(reason), retry_number, static_cast<u32>(delay_ms / 1000));- m_retry_timer = Core::Timer::create_single_shot(delay_ms,+ m_retry_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(delay_ms),[weak_this = make_weak_ptr<CrashReportSubmission>()] {if (auto self = weak_this.strong_ref())self->begin_attempt();diff --git a/Libraries/LibWebView/FileDownloader.cpp b/Libraries/LibWebView/FileDownloader.cppindex 5f3d9313092..2e7d4776042 100644--- a/Libraries/LibWebView/FileDownloader.cpp+++ b/Libraries/LibWebView/FileDownloader.cpp@@ -648,7 +648,7 @@ void FileDownloader::start_stall_watchdog(u64 download_id)return;if (!active->stall_timer) {- active->stall_timer = Core::Timer::create_repeating(stall_check_interval_ms, [this, download_id] {+ active->stall_timer = Core::Timer::create_repeating(AK::Duration::from_milliseconds(stall_check_interval_ms), [this, download_id] {check_for_stalled_segments(download_id);});}@@ -718,7 +718,7 @@ void FileDownloader::restart_stalled_segment(u64 download_id, size_t segment_indreturn;}- segment.retry_timer = Core::Timer::create_single_shot(delay_seconds * 1000, [this, download_id, segment_index] {+ segment.retry_timer = Core::Timer::create_single_shot(AK::Duration::from_seconds(delay_seconds), [this, download_id, segment_index] {auto* active = active_download(download_id);if (!active || active->stopped || segment_index >= active->segments.size())return;@@ -756,7 +756,7 @@ bool FileDownloader::retry_segment_request(u64 download_id, size_t segment_indexreturn true;}- segment.retry_timer = Core::Timer::create_single_shot(static_cast<int>(delay.to_milliseconds()), [this, download_id, segment_index, is_initial_request] {+ segment.retry_timer = Core::Timer::create_single_shot(delay, [this, download_id, segment_index, is_initial_request] {auto* active = active_download(download_id);if (!active || active->stopped || segment_index >= active->segments.size())return;diff --git a/Libraries/LibWebView/GamepadManager.cpp b/Libraries/LibWebView/GamepadManager.cppindex f87489ed1c0..e3f2ced2dae 100644--- a/Libraries/LibWebView/GamepadManager.cpp+++ b/Libraries/LibWebView/GamepadManager.cpp@@ -156,7 +156,7 @@ void GamepadManager::update_polling_state()}if (!m_poll_timer) {- m_poll_timer = Core::Timer::create_repeating(GAMEPAD_POLL_INTERVAL_MS, [this] {+ m_poll_timer = Core::Timer::create_repeating(AK::Duration::from_milliseconds(GAMEPAD_POLL_INTERVAL_MS), [this] {drain_sdl_events();publish_changed_input_states();});diff --git a/Libraries/LibWebView/HSTSStore.cpp b/Libraries/LibWebView/HSTSStore.cppindex d511755ed34..d6353f003a8 100644--- a/Libraries/LibWebView/HSTSStore.cpp+++ b/Libraries/LibWebView/HSTSStore.cpp@@ -61,7 +61,7 @@ HSTSStore::HSTSStore(Optional<PersistedStorage> persisted_storage)m_transient_storage.set_policies(move(policies));m_persisted_storage->synchronization_timer = Core::Timer::create_repeating(- static_cast<int>(DATABASE_SYNCHRONIZATION_TIMER.to_milliseconds()),+ DATABASE_SYNCHRONIZATION_TIMER,[this]() {for (auto const& it : m_transient_storage.take_dirty_policies())m_persisted_storage->insert_policy(it.key, it.value);diff --git a/Libraries/LibWebView/HeadlessWebView.cpp b/Libraries/LibWebView/HeadlessWebView.cppindex 8e4b016a024..efcbc47f181 100644--- a/Libraries/LibWebView/HeadlessWebView.cpp+++ b/Libraries/LibWebView/HeadlessWebView.cpp@@ -252,7 +252,7 @@ void HeadlessWebView::discard_child_web_view(HeadlessWebView& child_web_view)void HeadlessWebView::schedule_forced_close(){if (!m_forced_close_timer) {- m_forced_close_timer = Core::Timer::create_single_shot(child_close_timeout_ms, [weak_this = make_weak_ptr<HeadlessWebView>()] {+ m_forced_close_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(child_close_timeout_ms), [weak_this = make_weak_ptr<HeadlessWebView>()] {if (!weak_this || weak_this->handle().is_empty() || !weak_this->page().is_open())return;weak_this->force_close();diff --git a/Libraries/LibWebView/ProcessManager.cpp b/Libraries/LibWebView/ProcessManager.cppindex 795e2518043..bf6a1ae941b 100644--- a/Libraries/LibWebView/ProcessManager.cpp+++ b/Libraries/LibWebView/ProcessManager.cpp@@ -180,7 +180,7 @@ void ProcessManager::force_exit_after_timeout(pid_t pid, int timeout_ms)if (m_forced_exit_timers.contains(pid))return;- auto timer = Core::Timer::create_single_shot(timeout_ms, [this, pid] {+ auto timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(timeout_ms), [this, pid] {m_forced_exit_timers.remove(pid);auto process = m_processes.get(pid);if (!process.has_value())diff --git a/Libraries/LibWebView/RequestServerManager.cpp b/Libraries/LibWebView/RequestServerManager.cppindex 0681072ee53..2d2b691327e 100644--- a/Libraries/LibWebView/RequestServerManager.cpp+++ b/Libraries/LibWebView/RequestServerManager.cpp@@ -209,7 +209,7 @@ void RequestServerManager::client_disconnected(RequestServerInstance& instance,return;auto weak_instance = instance.make_weak_ptr();- instance.m_idle_timer = Core::Timer::create_single_shot(idle_request_server_timeout_ms, [weak_instance] {+ instance.m_idle_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(idle_request_server_timeout_ms), [weak_instance] {auto instance = weak_instance.strong_ref();if (instance && instance->m_client_ids.is_empty())the().retire(*instance);diff --git a/Libraries/LibWebView/SessionStore.cpp b/Libraries/LibWebView/SessionStore.cppindex 3ff68b83030..a5f6d939d22 100644--- a/Libraries/LibWebView/SessionStore.cpp+++ b/Libraries/LibWebView/SessionStore.cpp@@ -262,7 +262,7 @@ ErrorOr<NonnullOwnPtr<SessionStore>> SessionStore::create(Database::Database& daauto store = adopt_own(*new SessionStore(move(persisted_storage)));TRY(store->run_startup_recovery(UnixDateTime::now()));- store->m_flush_timer = Core::Timer::create_repeating(FLUSH_TIMER_INTERVAL_MILLISECONDS, [store = store.ptr()]() {+ store->m_flush_timer = Core::Timer::create_repeating(AK::Duration::from_milliseconds(FLUSH_TIMER_INTERVAL_MILLISECONDS), [store = store.ptr()]() {store->flush_dirty_state();});store->m_flush_timer->start();diff --git a/Libraries/LibWebView/TabPerformanceMonitor.cpp b/Libraries/LibWebView/TabPerformanceMonitor.cppindex 4fee55ab536..fae1f9f9f1e 100644--- a/Libraries/LibWebView/TabPerformanceMonitor.cpp+++ b/Libraries/LibWebView/TabPerformanceMonitor.cpp@@ -84,7 +84,7 @@ void TabPerformanceMonitor::config_variable_changed(ConfigVariableID id)});if (!m_enabled)return;- m_timer = Core::Timer::create_repeating(500, [this] { sample(); });+ m_timer = Core::Timer::create_repeating(AK::Duration::from_milliseconds(500), [this] { sample(); });m_timer->start();sample();}diff --git a/Libraries/LibWebView/ViewImplementation.cpp b/Libraries/LibWebView/ViewImplementation.cppindex c0f5f0f6169..8b422f80fd8 100644--- a/Libraries/LibWebView/ViewImplementation.cpp+++ b/Libraries/LibWebView/ViewImplementation.cpp@@ -83,7 +83,7 @@ ViewImplementation::ViewImplementation(IsPrivate is_private)initialize_context_menus();- m_repeated_crash_timer = Core::Timer::create_single_shot(1000, [this] {+ m_repeated_crash_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(1000), [this] {// Reset the "crashing a lot" counter after 1 second in case we just// happen to be visiting crashy websites a lot.this->m_crash_count = 0;@@ -1842,7 +1842,7 @@ void ViewImplementation::enable_picture_in_picture_controls()// The same delay as the page's media controls.static constexpr int hide_delay_ms = 1000;- m_picture_in_picture_controls_hide_timer = Core::Timer::create_single_shot(hide_delay_ms, [this] {+ m_picture_in_picture_controls_hide_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(hide_delay_ms), [this] {if (!m_picture_in_picture_controls_pointer_state.hovered_action().has_value())set_picture_in_picture_controls_shown(false);});@@ -3223,7 +3223,7 @@ void ViewImplementation::wait_for_webdriver_navigation_completion(Optional<u64>if (page_load_timeout.has_value()) {auto timer_interval = *page_load_timeout > NumericLimits<int>::max() ? NumericLimits<int>::max() : static_cast<int>(*page_load_timeout);- auto timer = Core::Timer::create_single_shot(timer_interval, [this, request_id] {+ auto timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(timer_interval), [this, request_id] {complete_webdriver_navigation_completion(request_id, Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::Timeout, "Navigation timed out"sv));});timer->start();diff --git a/Libraries/LibWebView/WebContentClient.cpp b/Libraries/LibWebView/WebContentClient.cppindex b9cd693054a..3d26afe4518 100644--- a/Libraries/LibWebView/WebContentClient.cpp+++ b/Libraries/LibWebView/WebContentClient.cpp@@ -425,7 +425,7 @@ void WebContentClient::close_server_if_unused()Application::process_manager().force_exit_after_timeout(pid(), detached_page_forced_exit_timeout_ms);if (!m_detached_page_close_timer) {- m_detached_page_close_timer = Core::Timer::create_single_shot(detached_page_close_timeout_ms, [this] {+ m_detached_page_close_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(detached_page_close_timeout_ms), [this] {dbgln("Timed out waiting for detached WebContent page close acknowledgement");for (auto& page : m_pages)page.value->set_detached_close_pending(false);diff --git a/Libraries/LibWebView/WorkerProcessManager.cpp b/Libraries/LibWebView/WorkerProcessManager.cppindex a3593e43e80..6baf1a4c3f7 100644--- a/Libraries/LibWebView/WorkerProcessManager.cpp+++ b/Libraries/LibWebView/WorkerProcessManager.cpp@@ -670,7 +670,7 @@ void WorkerProcessManager::remove_agent(Web::HTML::WorkerAgentId agent_id, Agent// NB: A worker busy running script handles no request to close, so its process is terminated if it has not exited// in time. Until it exits, it counts toward the workers of its top-level site.- auto termination_timer = Core::Timer::create_single_shot(static_cast<int>(worker_exit_grace_period.to_milliseconds()), [client = agent.client] {+ auto termination_timer = Core::Timer::create_single_shot(worker_exit_grace_period, [client = agent.client] {if (client->is_open())client->terminate_process();});diff --git a/Services/AudioServer/PlaybackStreamMixer.cpp b/Services/AudioServer/PlaybackStreamMixer.cppindex e7be162d0a4..9b5901eb720 100644--- a/Services/AudioServer/PlaybackStreamMixer.cpp+++ b/Services/AudioServer/PlaybackStreamMixer.cpp@@ -214,7 +214,7 @@ void PlaybackStreamMixer::finish_drain_once_played(MixerClientId id, i64 played_finish_drain(id);return;}- auto timer = Core::Timer::create_single_shot(max(1, AK::clamp_to<int>(remaining.to_milliseconds() + 1)), [this, id] {+ auto timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(max(1, AK::clamp_to<int>(remaining.to_milliseconds() + 1))), [this, id] {m_drain_timers.remove(id);finish_drain(id);});diff --git a/Services/Compositor/CaretBlinkTimer.cpp b/Services/Compositor/CaretBlinkTimer.cppindex 993bcb619f6..0201ba8c97d 100644--- a/Services/Compositor/CaretBlinkTimer.cpp+++ b/Services/Compositor/CaretBlinkTimer.cpp@@ -42,7 +42,7 @@ void CaretBlinkTimer::did_install_display_list(Compositing::DisplayList const& dreturn;if (!m_timer) {- m_timer = Core::Timer::create_single_shot(500, [this] {+ m_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(500), [this] {auto damage_rect = m_damage_rect_of_blinking_carets();if (!damage_rect.is_empty())m_schedule_repaint(damage_rect);@@ -63,7 +63,7 @@ void CaretBlinkTimer::schedule_next_blink(): 0;auto delay_ns = Compositing::caret_blink_interval_ns - elapsed_ns % Compositing::caret_blink_interval_ns;auto delay_ms = max(static_cast<int>((delay_ns + 999'999) / 1'000'000), 1);- m_timer->restart(delay_ms);+ m_timer->restart(AK::Duration::from_milliseconds(delay_ms));}}diff --git a/Services/Compositor/CompositorState.cpp b/Services/Compositor/CompositorState.cppindex df1e213e90c..a4284315418 100644--- a/Services/Compositor/CompositorState.cpp+++ b/Services/Compositor/CompositorState.cpp@@ -403,7 +403,7 @@ int CompositorState::unpainted_video_update_interval_ms() constvoid CompositorState::schedule_unpainted_video_updates(){if (!m_unpainted_video_update_timer) {- m_unpainted_video_update_timer = Core::Timer::create_repeating(unpainted_video_update_interval_ms(), [this] {+ m_unpainted_video_update_timer = Core::Timer::create_repeating(AK::Duration::from_milliseconds(unpainted_video_update_interval_ms()), [this] {update_unpainted_video_sinks();});}@@ -747,7 +747,7 @@ void CompositorState::set_display_metadata(Web::CompositorContextId context_id,if (context->set_display_metadata(display_id, refresh_rate)) {schedule_pending_present_frame(context_id, *context);if (m_unpainted_video_update_timer)- m_unpainted_video_update_timer->set_interval(unpainted_video_update_interval_ms());+ m_unpainted_video_update_timer->set_interval(AK::Duration::from_milliseconds(unpainted_video_update_interval_ms()));}if (context->display_tick_requested() && context_is_effectively_visible(*context))@@ -1114,7 +1114,7 @@ void CompositorState::schedule_gpu_completion_check()VERIFY(!m_pending_async_presents.is_empty());if (!m_gpu_completion_timer) {- m_gpu_completion_timer = Core::Timer::create_repeating(gpu_completion_check_interval_ms, [this] {+ m_gpu_completion_timer = Core::Timer::create_repeating(AK::Duration::from_milliseconds(gpu_completion_check_interval_ms), [this] {check_gpu_completions();});}diff --git a/Services/Compositor/ContextPresenter.cpp b/Services/Compositor/ContextPresenter.cppindex c957f6a7a5e..d6d60e31619 100644--- a/Services/Compositor/ContextPresenter.cpp+++ b/Services/Compositor/ContextPresenter.cpp@@ -68,7 +68,7 @@ bool ContextPresenter::should_shrink_backing_stores_after_resize() constvoid ContextPresenter::schedule_backing_store_shrink(Function<void()> on_timeout){if (!m_backing_store_shrink_timer)- m_backing_store_shrink_timer = Core::Timer::create_single_shot(3000, move(on_timeout));+ m_backing_store_shrink_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(3000), move(on_timeout));m_backing_store_shrink_timer->restart();}@@ -148,7 +148,7 @@ Optional<BackingStoreManager::Publication> ContextPresenter::add_backing_store_fvoid ContextPresenter::schedule_surplus_backing_store_retirement(Function<void()> on_timeout){if (!m_surplus_backing_store_retirement_timer)- m_surplus_backing_store_retirement_timer = Core::Timer::create_single_shot(3000, move(on_timeout));+ m_surplus_backing_store_retirement_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(3000), move(on_timeout));if (!m_surplus_backing_store_retirement_timer->is_active())m_surplus_backing_store_retirement_timer->start();}diff --git a/Services/Compositor/ContextState.cpp b/Services/Compositor/ContextState.cppindex bf3ad114ddf..d550e8bdaf6 100644--- a/Services/Compositor/ContextState.cpp+++ b/Services/Compositor/ContextState.cpp@@ -1589,13 +1589,13 @@ void ContextState::schedule_end_of_scroll_step_gestures(MonotonicTime now)return;}if (!m_scroll_step_gesture_input_timer) {- m_scroll_step_gesture_input_timer = Core::Timer::create_single_shot(0, [this] {+ m_scroll_step_gesture_input_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(0), [this] {end_scroll_step_gestures_whose_input_ran_out(MonotonicTime::now());});}// The gesture has run out of input once the clock reads past the deadline.auto delay = max(*deadline - now, AK::Duration::zero()).to_milliseconds() + 1;- m_scroll_step_gesture_input_timer->restart(static_cast<int>(delay));+ m_scroll_step_gesture_input_timer->restart(AK::Duration::from_milliseconds(static_cast<int>(delay)));}void ContextState::end_scroll_step_gestures_whose_input_ran_out(MonotonicTime now)diff --git a/Services/Compositor/VSyncScheduler.cpp b/Services/Compositor/VSyncScheduler.cppindex 678116526c0..51df7c36a76 100644--- a/Services/Compositor/VSyncScheduler.cpp+++ b/Services/Compositor/VSyncScheduler.cpp@@ -28,7 +28,7 @@ public:explicit TimerVSyncScheduler(Function<void(MonotonicTime)>&& tick_callback): m_tick_callback(move(tick_callback))- , m_timer(Core::Timer::create_single_shot(0, [this] {+ , m_timer(Core::Timer::create_single_shot(AK::Duration::from_milliseconds(0), [this] {fire();})){@@ -104,7 +104,7 @@ private:// point, and advancing by whole intervals keeps request and update latency from shifting later ticks.auto delay_nanoseconds = (*m_next_tick_time - now).to_nanoseconds();auto delay_milliseconds = (delay_nanoseconds + 999'999) / 1'000'000;- m_timer->restart(static_cast<int>(max<i64>(delay_milliseconds, 1)));+ m_timer->restart(AK::Duration::from_milliseconds(static_cast<int>(max<i64>(delay_milliseconds, 1))));}Function<void(MonotonicTime)> m_tick_callback;@@ -172,7 +172,7 @@ private:DisplayLinkState(Core::EventLoop& event_loop, CVDisplayLinkRef display_link): event_loop(event_loop), display_link(display_link)- , idle_stop_timer(Core::Timer::create_single_shot(display_link_idle_stop_delay_ms, [this] {+ , idle_stop_timer(Core::Timer::create_single_shot(AK::Duration::from_milliseconds(display_link_idle_stop_delay_ms), [this] {stop_display_link_if_idle();})){@@ -230,7 +230,7 @@ void DisplayLinkState::schedule_display_link_stop_if_idle()if (invalidated.load() || tick_requested.load() || !display_link)return;- idle_stop_timer->restart(display_link_idle_stop_delay_ms);+ idle_stop_timer->restart(AK::Duration::from_milliseconds(display_link_idle_stop_delay_ms));}void DisplayLinkState::stop_display_link_if_idle()diff --git a/Services/RequestServer/ConnectionFromClient.cpp b/Services/RequestServer/ConnectionFromClient.cppindex 0024753cfdb..4bf65e0f95a 100644--- a/Services/RequestServer/ConnectionFromClient.cpp+++ b/Services/RequestServer/ConnectionFromClient.cpp@@ -120,11 +120,11 @@ ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<IPC::Transport> transpo// https://curl.se/libcurl/c/CURLMOPT_TIMERFUNCTION.html// Your callback function timer_callback should install a single non-repeating timer with an expire time of// timeout_ms milliseconds.- m_timer = Core::Timer::create_single_shot(0, [this] {+ m_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(0), [this] {auto now = MonotonicTime::now();if (m_curl_timer_due_at.has_value() && now < *m_curl_timer_due_at) {auto remaining_ms = (*m_curl_timer_due_at - now).to_milliseconds();- m_timer->restart(AK::clamp_to<int>(remaining_ms));+ m_timer->restart(AK::Duration::from_milliseconds(AK::clamp_to<int>(remaining_ms)));return;}@@ -513,7 +513,7 @@ int ConnectionFromClient::on_timeout_callback(void*, long timeout_ms, void* user//// Core::Timer intervals are ints, so wait for longer valid timeouts in chunks without calling libcurl before its// requested expire time.- client->m_timer->restart(AK::clamp_to<int>(timeout_ms));+ client->m_timer->restart(AK::Duration::from_milliseconds(AK::clamp_to<int>(timeout_ms)));}// The timer callback should return 0 on success, and -1 on error.diff --git a/Services/RequestServer/ControlConnectionFromClient.cpp b/Services/RequestServer/ControlConnectionFromClient.cppindex 5dbc5f33291..e4415a4eb13 100644--- a/Services/RequestServer/ControlConnectionFromClient.cpp+++ b/Services/RequestServer/ControlConnectionFromClient.cpp@@ -171,7 +171,7 @@ void ControlConnectionFromClient::set_performance_monitor_enabled(bool enabled)request.value->sample_network_usage();}m_last_performance_push = MonotonicTime::now();- m_performance_timer = Core::Timer::create_repeating(500, [this] { push_network_usage(); });+ m_performance_timer = Core::Timer::create_repeating(AK::Duration::from_milliseconds(500), [this] { push_network_usage(); });m_performance_timer->start();}} else {diff --git a/Services/RequestServer/Request.cpp b/Services/RequestServer/Request.cppindex 34dc3323e76..1ba20ac42b6 100644--- a/Services/RequestServer/Request.cpp+++ b/Services/RequestServer/Request.cpp@@ -1098,7 +1098,7 @@ void Request::handle_wait_for_cache_state()if (!m_started_waiting_for_cache_at.has_value())m_started_waiting_for_cache_at = MonotonicTime::now();- m_wait_for_cache_timer = Core::Timer::create_single_shot(static_cast<int>(s_wait_for_cache_timeout.to_milliseconds()), [this] {+ m_wait_for_cache_timer = Core::Timer::create_single_shot(s_wait_for_cache_timeout, [this] {wait_for_cache_timed_out();});m_wait_for_cache_timer->start();@@ -1116,7 +1116,7 @@ void Request::wait_for_cache_timed_out()auto idle_time = MonotonicTime::now() - *last_activity_time;if (idle_time < s_wait_for_cache_timeout) {auto time_until_stalled = min(s_wait_for_cache_timeout - idle_time, s_maximum_wait_for_cache - time_waited);- m_wait_for_cache_timer->start(max(static_cast<int>(time_until_stalled.to_milliseconds()), 1));+ m_wait_for_cache_timer->start(AK::Duration::from_milliseconds(max(static_cast<int>(time_until_stalled.to_milliseconds()), 1)));return;}}diff --git a/Services/WasmCompiler/Compiler.cpp b/Services/WasmCompiler/Compiler.cppindex 3df44a2125d..4ba7053d78d 100644--- a/Services/WasmCompiler/Compiler.cpp+++ b/Services/WasmCompiler/Compiler.cpp@@ -130,8 +130,7 @@ void Compiler::start_pending_jobs()dbgln_if(WASM_CRANELIFT_DEBUG, "WasmCompiler: Compiling a {}-byte batch", job.value()->input.size());++m_active_jobs;- auto watchdog_interval = static_cast<int>(MAXIMUM_JOB_DURATION.to_milliseconds());- job.value()->watchdog = Core::Timer::create_single_shot(watchdog_interval, [this, job_id] {+ job.value()->watchdog = Core::Timer::create_single_shot(MAXIMUM_JOB_DURATION, [this, job_id] {Core::EventLoop::current().deferred_invoke([this, job_id] {if (!m_jobs.contains(job_id))return;diff --git a/Services/WebContent/PageClient.cpp b/Services/WebContent/PageClient.cppindex d1a1f3a95b5..29d7d9d2f63 100644--- a/Services/WebContent/PageClient.cpp+++ b/Services/WebContent/PageClient.cpp@@ -150,7 +150,7 @@ PageClient::PageClient(PageHost& owner, Web::PageId id, Optional<Web::HTML::Crosclient.async_did_request_cursor_change(id, cursor);});- m_frame_timer = Core::Timer::create_single_shot(0, [this] {+ m_frame_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(0), [this] {if (m_is_closed)return;frame_timer_fired();@@ -693,7 +693,7 @@ void PageClient::schedule_local_rendering_opportunity()}m_frame_timer_purpose = FrameTimerPurpose::LocalFallback;- m_frame_timer->restart(static_cast<int>(AK::ceil(delay)));+ m_frame_timer->restart(AK::Duration::from_milliseconds(static_cast<int>(AK::ceil(delay))));}void PageClient::schedule_compositor_watchdog()@@ -702,7 +702,7 @@ void PageClient::schedule_compositor_watchdog()auto delay = 4.0 * m_last_rendering_opportunity_frame_interval;m_compositor_watchdog_deadline = Web::HighResolutionTime::unsafe_shared_current_time() + delay;m_frame_timer_purpose = FrameTimerPurpose::CompositorWatchdog;- m_frame_timer->restart(static_cast<int>(AK::ceil(delay)));+ m_frame_timer->restart(AK::Duration::from_milliseconds(static_cast<int>(AK::ceil(delay))));}void PageClient::frame_timer_fired()@@ -728,7 +728,7 @@ void PageClient::frame_timer_fired()// an earlier request satisfy the current request before its own watchdog deadline.if (now < m_compositor_watchdog_deadline) {m_frame_timer_purpose = FrameTimerPurpose::CompositorWatchdog;- m_frame_timer->restart(static_cast<int>(AK::ceil(m_compositor_watchdog_deadline - now)));+ m_frame_timer->restart(AK::Duration::from_milliseconds(static_cast<int>(AK::ceil(m_compositor_watchdog_deadline - now))));return;}// An opportunity IPC may already be waiting behind a long main-thread task when this timer becomes runnable.@@ -1082,7 +1082,7 @@ void PageClient::page_did_change_accessibility_focus(Web::UniqueNodeID node_id)// (Document::setFocusedElement hands AXObjectCache::onFocusChange the old and the new element together).m_pending_accessibility_focus = static_cast<i64>(node_id.value());if (!m_accessibility_focus_timer) {- m_accessibility_focus_timer = Core::Timer::create_single_shot(0, [this] {+ m_accessibility_focus_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(0), [this] {if (m_is_closed)return;if (auto pending = exchange(m_pending_accessibility_focus, {}); pending.has_value())@@ -1104,7 +1104,7 @@ void PageClient::schedule_accessibility_tree_update()return;if (!m_accessibility_update_timer) {- m_accessibility_update_timer = Core::Timer::create_single_shot(200, [this] {+ m_accessibility_update_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(200), [this] {if (m_is_closed)return;if (auto doc = page().local_traversable()->active_document()) {diff --git a/Services/WebDriver/Client.cpp b/Services/WebDriver/Client.cppindex c9a742523ef..00bffcadbce 100644--- a/Services/WebDriver/Client.cpp+++ b/Services/WebDriver/Client.cpp@@ -468,7 +468,7 @@ ResponsePromise Client::new_window(Web::WebDriver::Parameters parameters, JsonVabool settled { false };};auto wait_state = adopt_ref(*new WaitState);- wait_state->timer = Core::Timer::create_single_shot(CONNECTION_TIMEOUT_MS, [promise, session, handle, wait_state] {+ wait_state->timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(CONNECTION_TIMEOUT_MS), [promise, session, handle, wait_state] {if (wait_state->settled)return;wait_state->settled = true;diff --git a/Services/WebDriver/Session.cpp b/Services/WebDriver/Session.cppindex bb63dfb4cc4..5fde184145d 100644--- a/Services/WebDriver/Session.cpp+++ b/Services/WebDriver/Session.cpp@@ -311,7 +311,7 @@ void Session::arm_browser_startup_timeout(NonnullRefPtr<ServerPromise> promise){m_start_promise = move(promise);static constexpr u32 BROWSER_STARTUP_TIMEOUT_MS = 30'000;- m_start_timer = Core::Timer::create_single_shot(BROWSER_STARTUP_TIMEOUT_MS, [this] {+ m_start_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(BROWSER_STARTUP_TIMEOUT_MS), [this] {[[maybe_unused]] auto timer_lifetime_guard = move(m_start_timer);reject_start_promise(Error::from_string_literal("Timed out waiting for browser startup"));close();diff --git a/Tests/AudioServer/TestPlatformPlaybackStream.cpp b/Tests/AudioServer/TestPlatformPlaybackStream.cppindex 4dd4e04baf9..17403829f49 100644--- a/Tests/AudioServer/TestPlatformPlaybackStream.cpp+++ b/Tests/AudioServer/TestPlatformPlaybackStream.cpp@@ -41,7 +41,7 @@ TEST_CASE(platform_playback_stream_can_be_created_and_suspended)->when_resolved([&] { resumed.store(true); }).when_rejected([](Error const&) { VERIFY_NOT_REACHED(); });- auto poll_timer = Core::Timer::create_repeating(1, [] { });+ auto poll_timer = Core::Timer::create_repeating(AK::Duration::from_milliseconds(1), [] { });poll_timer->start();event_loop->spin_until([&] { return resumed.load() && request_count.load() > 0; });diff --git a/Tests/Compositor/TestVSyncScheduler.cpp b/Tests/Compositor/TestVSyncScheduler.cppindex 1b0c5b10e62..b529b41d09c 100644--- a/Tests/Compositor/TestVSyncScheduler.cpp+++ b/Tests/Compositor/TestVSyncScheduler.cpp@@ -13,8 +13,8 @@ TEST_CASE(requests_before_a_tick_are_coalesced){Core::EventLoop event_loop;int tick_count = 0;- auto timeout = Core::Timer::create_single_shot(1000, [&] { event_loop.quit(0); });- auto after_tick = Core::Timer::create_single_shot(50, [&] { event_loop.quit(0); });+ auto timeout = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(1000), [&] { event_loop.quit(0); });+ auto after_tick = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(50), [&] { event_loop.quit(0); });auto scheduler = Compositor::create_vsync_scheduler({}, [&](MonotonicTime) {++tick_count;if (tick_count == 1)@@ -34,7 +34,7 @@ TEST_CASE(a_tick_callback_can_request_the_next_tick){Core::EventLoop event_loop;int tick_count = 0;- auto timeout = Core::Timer::create_single_shot(1000, [&] { event_loop.quit(0); });+ auto timeout = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(1000), [&] { event_loop.quit(0); });OwnPtr<Compositor::VSyncScheduler> scheduler;scheduler = Compositor::create_vsync_scheduler({}, [&](MonotonicTime) {if (++tick_count == 1)@@ -54,7 +54,7 @@ TEST_CASE(a_refresh_rate_change_rearms_the_pending_tick){Core::EventLoop event_loop;int tick_count = 0;- auto timeout = Core::Timer::create_single_shot(1000, [&] { event_loop.quit(0); });+ auto timeout = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(1000), [&] { event_loop.quit(0); });auto scheduler = Compositor::create_vsync_scheduler({}, [&](MonotonicTime) {++tick_count;event_loop.quit(0);diff --git a/Tests/LibAudio/TestPlaybackStream.cpp b/Tests/LibAudio/TestPlaybackStream.cppindex 83a3510caa4..a26b025a91d 100644--- a/Tests/LibAudio/TestPlaybackStream.cpp+++ b/Tests/LibAudio/TestPlaybackStream.cpp@@ -76,7 +76,7 @@ TEST_CASE(null_playback_stream_pulls_only_while_playing)EXPECT_EQ(stream->sample_specification().channel_map(), Audio::ChannelMap::stereo());stream->resume()->when_rejected([](Error const&) { VERIFY_NOT_REACHED(); });- auto poll_timer = Core::Timer::create_repeating(1, [] { });+ auto poll_timer = Core::Timer::create_repeating(AK::Duration::from_milliseconds(1), [] { });poll_timer->start();event_loop.spin_until([&] { return request_count.load() > 0; });@@ -89,7 +89,7 @@ TEST_CASE(null_playback_stream_pulls_only_while_playing)auto request_count_when_suspended = request_count.load();bool checked_suspension = false;- auto timer = Core::Timer::create_single_shot(20, [&] {+ auto timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(20), [&] {EXPECT_EQ(request_count.load(), request_count_when_suspended);checked_suspension = true;});@@ -118,7 +118,7 @@ TEST_CASE(null_playback_stream_dates_each_buffer_by_what_it_holds)});stream->resume()->when_rejected([](Error const&) { VERIFY_NOT_REACHED(); });- auto poll_timer = Core::Timer::create_repeating(1, [] { });+ auto poll_timer = Core::Timer::create_repeating(AK::Duration::from_milliseconds(1), [] { });poll_timer->start();event_loop.spin_until([&] { return request_count.load() > 2; });EXPECT(every_buffer_dated_by_what_it_holds.load());@@ -138,7 +138,7 @@ TEST_CASE(null_playback_stream_recovers_from_underrun)});stream->resume()->when_rejected([](Error const&) { VERIFY_NOT_REACHED(); });- auto poll_timer = Core::Timer::create_repeating(1, [&] {+ auto poll_timer = Core::Timer::create_repeating(AK::Duration::from_milliseconds(1), [&] {stream->notify_data_available();});poll_timer->start();@@ -157,7 +157,7 @@ TEST_CASE(null_playback_stream_resume_completes_pending_drain)});stream->resume()->when_rejected([](Error const&) { VERIFY_NOT_REACHED(); });- auto poll_timer = Core::Timer::create_repeating(1, [] { });+ auto poll_timer = Core::Timer::create_repeating(AK::Duration::from_milliseconds(1), [] { });poll_timer->start();event_loop.spin_until([&] { return request_count.load() > 0; });@@ -168,7 +168,7 @@ TEST_CASE(null_playback_stream_resume_completes_pending_drain)stream->resume()->when_rejected([](Error const&) { VERIFY_NOT_REACHED(); });bool checked_drain = false;- auto timer = Core::Timer::create_single_shot(50, [&] {+ auto timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(50), [&] {EXPECT(drained.load());checked_drain = true;});diff --git a/Tests/LibCore/TestLibCoreDeferredInvoke.cpp b/Tests/LibCore/TestLibCoreDeferredInvoke.cppindex 7e6e9001ed1..b39b35d96fb 100644--- a/Tests/LibCore/TestLibCoreDeferredInvoke.cpp+++ b/Tests/LibCore/TestLibCoreDeferredInvoke.cpp@@ -12,7 +12,7 @@TEST_CASE(deferred_invoke){IGNORE_USE_IN_ESCAPING_LAMBDA Core::EventLoop event_loop;- auto reaper = Core::Timer::create_single_shot(250, [] {+ auto reaper = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(250), [] {warnln("I waited for the deferred_invoke to happen, but it never did!");VERIFY_NOT_REACHED();});diff --git a/Tests/LibCore/TestLibCoreEventLoop.cpp b/Tests/LibCore/TestLibCoreEventLoop.cppindex 4e33218fb11..afb6344b0d4 100644--- a/Tests/LibCore/TestLibCoreEventLoop.cpp+++ b/Tests/LibCore/TestLibCoreEventLoop.cpp@@ -101,7 +101,7 @@ TEST_CASE(single_shot_timer_fires_once){Core::EventLoop loop;int count = 0;- auto timer = Core::Timer::create_single_shot(10, [&] {+ auto timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(10), [&] {++count;loop.quit(0);});@@ -116,7 +116,7 @@ TEST_CASE(zero_interval_repeating_timer){Core::EventLoop loop;int count = 0;- auto timer = Core::Timer::create_repeating(0, [&] {+ auto timer = Core::Timer::create_repeating(AK::Duration::from_milliseconds(0), [&] {if (++count == 5)loop.quit(0);});@@ -130,7 +130,7 @@ TEST_CASE(repeating_timer_keeps_cadence)Core::EventLoop loop;int count = 0;auto start = MonotonicTime::now();- auto timer = Core::Timer::create_repeating(10, [&] {+ auto timer = Core::Timer::create_repeating(AK::Duration::from_milliseconds(10), [&] {if (++count == 20)loop.quit(0);});@@ -150,7 +150,7 @@ TEST_CASE(equal_deadlines_fire_in_registration_order)Vector<int> order;Vector<NonnullRefPtr<Core::Timer>> timers;for (int i = 0; i < 8; ++i) {- timers.append(Core::Timer::create_single_shot(20, [&order, &loop, i] {+ timers.append(Core::Timer::create_single_shot(AK::Duration::from_milliseconds(20), [&order, &loop, i] {order.append(i);if (order.size() == 8)loop.quit(0);@@ -168,10 +168,10 @@ TEST_CASE(stopped_timer_does_not_fire){Core::EventLoop loop;int stopped_count = 0;- auto stopped_timer = Core::Timer::create_single_shot(10, [&] { ++stopped_count; });+ auto stopped_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(10), [&] { ++stopped_count; });stopped_timer->start();stopped_timer->stop();- auto quit_timer = Core::Timer::create_single_shot(50, [&] { loop.quit(0); });+ auto quit_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(50), [&] { loop.quit(0); });quit_timer->start();loop.exec();EXPECT_EQ(stopped_count, 0);@@ -196,7 +196,7 @@ TEST_CASE(timer_does_not_fire_before_its_interval)while (MonotonicTime::now() < busy_until);};- timer = Core::Timer::create_single_shot(interval_ms, [&] {+ timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(interval_ms), [&] {auto elapsed = MonotonicTime::now() - started_at;auto interval = AK::Duration::from_milliseconds(interval_ms);if (elapsed < interval)diff --git a/Tests/LibCore/TestLibCoreFileWatcher.cpp b/Tests/LibCore/TestLibCoreFileWatcher.cppindex f011e6dee5e..caef72647d2 100644--- a/Tests/LibCore/TestLibCoreFileWatcher.cpp+++ b/Tests/LibCore/TestLibCoreFileWatcher.cpp@@ -55,18 +55,18 @@ TEST_CASE(file_watcher_child_events)event_count++;};- auto timer1 = Core::Timer::create_single_shot(1 * TIMEOUT_PER_STEP_IN_MS, [&] {+ auto timer1 = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(1 * TIMEOUT_PER_STEP_IN_MS), [&] {int rc = creat("/tmp/testfile", 0777);EXPECT_NE(rc, -1);});timer1->start();- auto timer2 = Core::Timer::create_single_shot(2 * TIMEOUT_PER_STEP_IN_MS, [&] {+ auto timer2 = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(2 * TIMEOUT_PER_STEP_IN_MS), [&] {MUST(Core::System::unlink("/tmp/testfile"sv));});timer2->start();- auto catchall_timer = Core::Timer::create_single_shot(3 * TIMEOUT_PER_STEP_IN_MS, [&] {+ auto catchall_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(3 * TIMEOUT_PER_STEP_IN_MS), [&] {VERIFY_NOT_REACHED();});catchall_timer->start();@@ -102,13 +102,13 @@ TEST_CASE(contents_changed)}};- auto timer1 = Core::Timer::create_single_shot(1 * TIMEOUT_PER_STEP_IN_MS, [&] { write_file("line2\n"sv); });+ auto timer1 = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(1 * TIMEOUT_PER_STEP_IN_MS), [&] { write_file("line2\n"sv); });timer1->start();- auto timer2 = Core::Timer::create_single_shot(2 * TIMEOUT_PER_STEP_IN_MS, [&] { write_file("line3\n"sv); });+ auto timer2 = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(2 * TIMEOUT_PER_STEP_IN_MS), [&] { write_file("line3\n"sv); });timer2->start();- auto catchall_timer = Core::Timer::create_single_shot(3 * TIMEOUT_PER_STEP_IN_MS, [&] {+ auto catchall_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(3 * TIMEOUT_PER_STEP_IN_MS), [&] {VERIFY_NOT_REACHED();});catchall_timer->start();@@ -147,19 +147,19 @@ TEST_CASE(symbolic_link)}};- auto timer1 = Core::Timer::create_single_shot(1 * TIMEOUT_PER_STEP_IN_MS, [&] {+ auto timer1 = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(1 * TIMEOUT_PER_STEP_IN_MS), [&] {MUST(Core::System::unlink(test_file.string()));MUST(Core::System::symlink(test_link1.string(), test_file.string()));});timer1->start();- auto timer2 = Core::Timer::create_single_shot(2 * TIMEOUT_PER_STEP_IN_MS, [&] {+ auto timer2 = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(2 * TIMEOUT_PER_STEP_IN_MS), [&] {MUST(Core::System::unlink(test_file.string()));MUST(Core::System::symlink(test_link2.string(), test_file.string()));});timer2->start();- auto catchall_timer = Core::Timer::create_single_shot(3 * TIMEOUT_PER_STEP_IN_MS, [&] {+ auto catchall_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(3 * TIMEOUT_PER_STEP_IN_MS), [&] {VERIFY_NOT_REACHED();});catchall_timer->start();diff --git a/Tests/LibDNS/TestDNSResolver.cpp b/Tests/LibDNS/TestDNSResolver.cppindex c9a23e36b78..93cfc960856 100644--- a/Tests/LibDNS/TestDNSResolver.cpp+++ b/Tests/LibDNS/TestDNSResolver.cpp@@ -309,7 +309,7 @@ TEST_CASE(test_dnssec_response_rejects_unknown_key_tag).when_rejected([&](auto&) {loop.quit(0);});- auto deadline = Core::Timer::create_single_shot(1000, [&] { loop.quit(2); });+ auto deadline = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(1000), [&] { loop.quit(2); });deadline->start();EXPECT_EQ(0, loop.exec());}@@ -346,7 +346,7 @@ TEST_CASE(test_dnssec_response_rejects_unhandled_algorithm).when_rejected([&](auto&) {loop.quit(0);});- auto deadline = Core::Timer::create_single_shot(1000, [&] { loop.quit(3); });+ auto deadline = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(1000), [&] { loop.quit(3); });deadline->start();EXPECT_EQ(0, loop.exec());}@@ -547,7 +547,7 @@ TEST_CASE(test_validated_lookup_settles_on_a_negative_response)}).when_rejected([&](auto&) { settled = true; });- auto deadline = Core::Timer::create_single_shot(2000, [&] { loop.quit(1); });+ auto deadline = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(2000), [&] { loop.quit(1); });deadline->start();loop.spin_until([&] { return settled || loop.was_exit_requested(); });EXPECT(settled);@@ -641,7 +641,7 @@ TEST_CASE(test_partial_tcp_frame_does_not_block_the_event_loop)// The event loop must keep running while the frame is incomplete.bool timer_fired = false;- auto timer = Core::Timer::create_single_shot(100, [&] { timer_fired = true; });+ auto timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(100), [&] { timer_fired = true; });timer->start();loop.spin_until([&] { return timer_fired; });EXPECT(!promise->is_resolved());@@ -849,7 +849,7 @@ TEST_CASE(test_expired_addresses_are_not_mistaken_for_a_negative_answer)EXPECT_EQ(first->cached_addresses().size(), 1u);auto queries_for_first_lookup = queries;- auto timer = Core::Timer::create_single_shot(2100, [&] { loop.quit(0); });+ auto timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(2100), [&] { loop.quit(0); });timer->start();loop.exec();diff --git a/Tests/LibMedia/TestBufferedRanges.cpp b/Tests/LibMedia/TestBufferedRanges.cppindex e1dbd739665..e0f2379b990 100644--- a/Tests/LibMedia/TestBufferedRanges.cpp+++ b/Tests/LibMedia/TestBufferedRanges.cpp@@ -79,7 +79,7 @@ static Media::TimeRanges wait_for_buffered_ranges(Core::EventLoop& loop, Media::ScopeGuard remove_handler = [&] { demuxer.set_scan_state_change_handler(nullptr); };bool deadline_expired = false;- auto deadline_timer = Core::Timer::create_single_shot(1'000, [&] { deadline_expired = true; });+ auto deadline_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(1'000), [&] { deadline_expired = true; });deadline_timer->start();loop.spin_until([&] { return condition(source_buffered_ranges(demuxer)) || deadline_expired; });diff --git a/Tests/LibMedia/TestParseMatroska.cpp b/Tests/LibMedia/TestParseMatroska.cppindex a591229f93a..c80f178b13c 100644--- a/Tests/LibMedia/TestParseMatroska.cpp+++ b/Tests/LibMedia/TestParseMatroska.cpp@@ -879,7 +879,7 @@ Media::TimeRanges wait_for_buffered_ranges(Core::EventLoop& loop, Media::DemuxerScopeGuard remove_handler = [&] { demuxer.set_scan_state_change_handler(nullptr); };bool deadline_expired = false;- auto deadline_timer = Core::Timer::create_single_shot(1'000, [&] { deadline_expired = true; });+ auto deadline_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(1'000), [&] { deadline_expired = true; });deadline_timer->start();loop.spin_until([&] { return condition(source_buffered_ranges(demuxer)) || deadline_expired; });diff --git a/Tests/LibTLS/TestTLSHandshake.cpp b/Tests/LibTLS/TestTLSHandshake.cppindex b29e5e13a87..10329138e09 100644--- a/Tests/LibTLS/TestTLSHandshake.cpp+++ b/Tests/LibTLS/TestTLSHandshake.cpp@@ -68,7 +68,7 @@ TEST_CASE(test_TLS_hello_handshake)};tls->set_notifications_enabled(true);- auto timeout = Core::Timer::create_single_shot(10'000, [&loop] {+ auto timeout = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(10'000), [&loop] {loop.quit(1);});diff --git a/Tests/LibWeb/TestAudioWorkletPipe.cpp b/Tests/LibWeb/TestAudioWorkletPipe.cppindex f4e549684b9..1ce3d7ffc84 100644--- a/Tests/LibWeb/TestAudioWorkletPipe.cpp+++ b/Tests/LibWeb/TestAudioWorkletPipe.cpp@@ -311,7 +311,7 @@ TEST_CASE(two_thread_stress)producer->start();IGNORE_USE_IN_ESCAPING_LAMBDA Core::EventLoop& loop = event_loop;- auto quit_timer = Core::Timer::create_repeating(25, [&] {+ auto quit_timer = Core::Timer::create_repeating(AK::Duration::from_milliseconds(25), [&] {if (producer_done.load())loop.quit(0);});@@ -391,7 +391,7 @@ TEST_CASE(teardown_when_producer_drops_its_reference_mid_run)producer->start();IGNORE_USE_IN_ESCAPING_LAMBDA Core::EventLoop& loop = event_loop;- auto quit_timer = Core::Timer::create_repeating(10, [&] {+ auto quit_timer = Core::Timer::create_repeating(AK::Duration::from_milliseconds(10), [&] {if (producer_done.load())loop.quit(0);});diff --git a/Tests/LibWeb/test-web/Display.cpp b/Tests/LibWeb/test-web/Display.cppindex e50c6d01a68..50bebabbb6d 100644--- a/Tests/LibWeb/test-web/Display.cpp+++ b/Tests/LibWeb/test-web/Display.cpp@@ -71,7 +71,7 @@ void Display::begin_run()});#endif- display_timer = Core::Timer::create_repeating(1000, [this] { render_live_display(); });+ display_timer = Core::Timer::create_repeating(AK::Duration::from_milliseconds(1000), [this] { render_live_display(); });display_timer->start();}diff --git a/Tests/LibWeb/test-web/main.cpp b/Tests/LibWeb/test-web/main.cppindex 6e792fc90b5..f717a289dfe 100644--- a/Tests/LibWeb/test-web/main.cpp+++ b/Tests/LibWeb/test-web/main.cpp@@ -917,7 +917,7 @@ static void run_test(TestWebView& view, TestRunContext& context, size_t test_indtest_run_capture.begin_test_output_capture(view, test);auto timeout_in_milliseconds = app.per_test_timeout_in_seconds * 1000;- test.timeout_timer = Core::Timer::create_single_shot(timeout_in_milliseconds, [&view, &context, test_index]() {+ test.timeout_timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(timeout_in_milliseconds), [&view, &context, test_index]() {auto& test = context.tests[test_index];if (!test.did_start_test)dbgln("Timeout during pre-navigation for {}, WebContent process may be unresponsive", test.relative_path);@@ -930,7 +930,7 @@ static void run_test(TestWebView& view, TestRunContext& context, size_t test_indauto& test = context.tests[test_index];if (milliseconds <= 0)return;- test.timeout_timer->restart(AK::clamp_to<int>(milliseconds));+ test.timeout_timer->restart(AK::Duration::from_milliseconds(AK::clamp_to<int>(milliseconds)));};// Clear the current document.@@ -1185,7 +1185,7 @@ static ErrorOr<int> run_tests(Core::AnonymousBuffer const& theme, Web::DevicePix// test URL before the about:blank load completes. WebContent currently cannot handle this, and will drop the test URL.// Nothing else bounds this wait, so it gets the per-test timeout.bool initial_load_timed_out = false;- auto initial_load_timer = Core::Timer::create_single_shot(app.per_test_timeout_in_seconds * 1000, [&] {+ auto initial_load_timer = Core::Timer::create_single_shot(AK::Duration::from_seconds(app.per_test_timeout_in_seconds), [&] {initial_load_timed_out = true;});initial_load_timer->start();diff --git a/Tests/LibWebView/TestBrowserHistoryTraversal.cpp b/Tests/LibWebView/TestBrowserHistoryTraversal.cppindex 9f6c83ba859..01ddafb7dbd 100644--- a/Tests/LibWebView/TestBrowserHistoryTraversal.cpp+++ b/Tests/LibWebView/TestBrowserHistoryTraversal.cpp@@ -395,7 +395,7 @@ ErrorOr<int> ladybird_main(Main::Arguments arguments)// The displayed document is still unloading, after its successor's history job was found ready.view->load(activated_url);bool unloading = false;- auto timer = Core::Timer::create_single_shot(300, [&] { unloading = true; });+ auto timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(300), [&] { unloading = true; });timer->start();Core::EventLoop::current().spin_until([&] { return unloading; });view->load(newer_url);diff --git a/Tests/LibWebView/TestFileDownloader.cpp b/Tests/LibWebView/TestFileDownloader.cppindex 0eb6f07b97c..46315a15a87 100644--- a/Tests/LibWebView/TestFileDownloader.cpp+++ b/Tests/LibWebView/TestFileDownloader.cpp@@ -469,7 +469,7 @@ void expect_request_can_be_exported_from_headers_callback(TestHttpServer& server});bool timed_out = false;- auto timeout = Core::Timer::create_single_shot(10'000, [&] { timed_out = true; });+ auto timeout = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(10'000), [&] { timed_out = true; });timeout->start();Core::EventLoop::current().spin_until([&] { return finished || timed_out; });VERIFY(!timed_out);@@ -536,7 +536,7 @@ void expect_leased_request_is_torn_down_when_transferred_after_finishing(TestHtt});bool timed_out = false;- auto timeout = Core::Timer::create_single_shot(10'000, [&] {+ auto timeout = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(10'000), [&] {timed_out = true;});timeout->start();diff --git a/Tests/LibWebView/TestPictureInPictureWindowControls.cpp b/Tests/LibWebView/TestPictureInPictureWindowControls.cppindex 7bb8377daa7..e8b1de1227f 100644--- a/Tests/LibWebView/TestPictureInPictureWindowControls.cpp+++ b/Tests/LibWebView/TestPictureInPictureWindowControls.cpp@@ -76,7 +76,7 @@ constexpr auto video_url = "data:video/webm;base64,"void wait_for(int milliseconds){bool elapsed = false;- auto timer = Core::Timer::create_single_shot(milliseconds, [&] { elapsed = true; });+ auto timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(milliseconds), [&] { elapsed = true; });timer->start();Core::EventLoop::current().spin_until([&] { return elapsed; });}diff --git a/Tests/LibWebView/TestPictureInPictureWindowLifetime.cpp b/Tests/LibWebView/TestPictureInPictureWindowLifetime.cppindex 93b52c9380e..884fc1fafa8 100644--- a/Tests/LibWebView/TestPictureInPictureWindowLifetime.cpp+++ b/Tests/LibWebView/TestPictureInPictureWindowLifetime.cpp@@ -80,7 +80,7 @@ constexpr auto video_url = "data:video/webm;base64,"bool spin_until_or_timeout(Function<bool()> condition, int timeout_ms){bool timed_out = false;- auto timer = Core::Timer::create_single_shot(timeout_ms, [&] { timed_out = true; });+ auto timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(timeout_ms), [&] { timed_out = true; });timer->start();Core::EventLoop::current().spin_until([&] { return condition() || timed_out; });return condition();diff --git a/Tests/LibWebView/TestTabPerformanceMonitor.cpp b/Tests/LibWebView/TestTabPerformanceMonitor.cppindex 9c03d483d3e..e7555e7ed89 100644--- a/Tests/LibWebView/TestTabPerformanceMonitor.cpp+++ b/Tests/LibWebView/TestTabPerformanceMonitor.cpp@@ -82,7 +82,7 @@ ErrorOr<int> ladybird_main(Main::Arguments arguments)};auto wait_for_samples = [&](u64 minimum_samples) -> ErrorOr<void> {bool timed_out = false;- auto watchdog = Core::Timer::create_single_shot(20'000, [&] { timed_out = true; });+ auto watchdog = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(20'000), [&] { timed_out = true; });watchdog->start();Core::EventLoop::current().spin_until([&] { return timed_out || (samples >= minimum_samples && pushes >= 2 && cpu.has_value()); });if (timed_out)diff --git a/Tests/RequestServer/TestCookieResponses.cpp b/Tests/RequestServer/TestCookieResponses.cppindex 482823fdf62..c67dc8cfd17 100644--- a/Tests/RequestServer/TestCookieResponses.cpp+++ b/Tests/RequestServer/TestCookieResponses.cpp@@ -88,7 +88,7 @@ public:NonnullOwnPtr<Messages::RequestServerControlClient::StoreResponseCookiesAndHstsPolicy> wait_for_storage_request(Core::EventLoop& event_loop){// The control transport is not part of the event loop here, so keep the loop from sleeping until it has news.- auto wake_timer = Core::Timer::create_repeating(10, [] { });+ auto wake_timer = Core::Timer::create_repeating(AK::Duration::from_milliseconds(10), [] { });wake_timer->start();OwnPtr<Messages::RequestServerControlClient::StoreResponseCookiesAndHstsPolicy> storage_request;@@ -105,7 +105,7 @@ public:NonnullOwnPtr<Messages::RequestServerControlClient::RetrieveHttpCookie> wait_for_cookie_request(Core::EventLoop& event_loop){- auto wake_timer = Core::Timer::create_repeating(10, [] { });+ auto wake_timer = Core::Timer::create_repeating(AK::Duration::from_milliseconds(10), [] { });wake_timer->start();OwnPtr<Messages::RequestServerControlClient::RetrieveHttpCookie> cookie_request;@@ -211,7 +211,7 @@ public:NonnullOwnPtr<MessageType> take_client_message(Core::EventLoop& event_loop){// The client transport is outside the event loop, so prevent the loop from sleeping.- auto wake_timer = Core::Timer::create_repeating(10, [] { });+ auto wake_timer = Core::Timer::create_repeating(AK::Duration::from_milliseconds(10), [] { });wake_timer->start();OwnPtr<MessageType> result;@@ -791,7 +791,7 @@ TEST_CASE(disconnected_client_requests_stop_while_a_transferred_request_lives_oncookie_request = control.take_cookie_request();control.retrieve_http_cookie(source_connection.client_id(), 0, RequestServer::RequestType::WebSocket, cookie_request->cookie_request_id());- auto wake_timer = Core::Timer::create_repeating(10, [] { });+ auto wake_timer = Core::Timer::create_repeating(AK::Duration::from_milliseconds(10), [] { });wake_timer->start();server.event_loop.spin_until([&] { return transferred_server.received_requests() == 1 && websocket_server.received_requests() == 1; });diff --git a/Tests/RequestServer/TestDiskCacheWaiters.cpp b/Tests/RequestServer/TestDiskCacheWaiters.cppindex 083abd8bbd8..28115795e7d 100644--- a/Tests/RequestServer/TestDiskCacheWaiters.cpp+++ b/Tests/RequestServer/TestDiskCacheWaiters.cpp@@ -144,7 +144,7 @@ private:MUST(connection.socket->write_until_depleted(response.pieces[connection.next_piece_index++].bytes()));if (connection.next_piece_index < response.pieces.size()) {- connection.piece_timer = Core::Timer::create_single_shot(static_cast<int>(response.interval.to_milliseconds()), [this, connection_index] {+ connection.piece_timer = Core::Timer::create_single_shot(response.interval, [this, connection_index] {write_next_piece(connection_index);});connection.piece_timer->start();diff --git a/Tests/RequestServer/TestExportImport.cpp b/Tests/RequestServer/TestExportImport.cppindex 33939dbce3d..fe1bd1c317c 100644--- a/Tests/RequestServer/TestExportImport.cpp+++ b/Tests/RequestServer/TestExportImport.cpp@@ -137,7 +137,7 @@ public:template<typename MessageType>NonnullOwnPtr<MessageType> wait_for(Core::EventLoop& event_loop, u64 request_id){- auto wake_timer = Core::Timer::create_repeating(5, [] { });+ auto wake_timer = Core::Timer::create_repeating(AK::Duration::from_milliseconds(5), [] { });wake_timer->start();OwnPtr<MessageType> result;@@ -160,7 +160,7 @@ public:ByteBuffer read_whole_body(Core::EventLoop& event_loop, u64 request_id){- auto wake_timer = Core::Timer::create_repeating(5, [] { });+ auto wake_timer = Core::Timer::create_repeating(AK::Duration::from_milliseconds(5), [] { });wake_timer->start();event_loop.spin_until([&] {@@ -271,7 +271,7 @@ public:auto head = ByteString::formatted("HTTP/1.1 200 OK\r\nCache-Control: max-age=600\r\nContent-Length: {}\r\nConnection: close\r\n\r\n", m_body.size());MUST(connection.socket->write_until_depleted(head.bytes()));MUST(connection.socket->set_blocking(false));- connection.piece_timer = Core::Timer::create_repeating(static_cast<int>(m_interval.to_milliseconds()), [this, &connection] { write_piece(connection); });+ connection.piece_timer = Core::Timer::create_repeating(m_interval, [this, &connection] { write_piece(connection); });write_piece(connection);connection.piece_timer->start();};@@ -423,7 +423,7 @@ TEST_CASE(stopping_an_imported_request_aborts_the_transfer)});target.stop_request(30);- auto wake_timer = Core::Timer::create_repeating(5, [] { });+ auto wake_timer = Core::Timer::create_repeating(AK::Duration::from_milliseconds(5), [] { });wake_timer->start();event_loop.spin_until([&] { return http_server.peer_closed(0); });EXPECT(!http_server.finished(0));diff --git a/Tests/RequestServer/TestSiteBinding.cpp b/Tests/RequestServer/TestSiteBinding.cppindex 193f83117c2..1a6a347ef43 100644--- a/Tests/RequestServer/TestSiteBinding.cpp+++ b/Tests/RequestServer/TestSiteBinding.cpp@@ -110,7 +110,7 @@ struct TestServer {Optional<Requests::NetworkError> wait_for_request_finished(u64 request_id){// The client transport is not part of the event loop here, so keep the loop from sleeping until it has news.- auto wake_timer = Core::Timer::create_repeating(10, [] { });+ auto wake_timer = Core::Timer::create_repeating(AK::Duration::from_milliseconds(10), [] { });wake_timer->start();Optional<Optional<Requests::NetworkError>> network_error;