From 829186af7d96a76e0a4a34a7b06e737c34a5dc87 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 8 Oct 2022 10:54:52 +0200 Subject: [PATCH] LibWeb+WebContent: Add EventLoopPlugin::quit() virtual This allows you to customize breaking out of the system event loop. --- Userland/Libraries/LibWeb/Platform/EventLoopPlugin.h | 1 + .../Libraries/LibWeb/Platform/EventLoopPluginSerenity.cpp | 5 +++++ Userland/Libraries/LibWeb/Platform/EventLoopPluginSerenity.h | 1 + Userland/Services/WebContent/ConnectionFromClient.cpp | 3 ++- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/Platform/EventLoopPlugin.h b/Userland/Libraries/LibWeb/Platform/EventLoopPlugin.h index de08e14fb9..9824fed4aa 100644 --- a/Userland/Libraries/LibWeb/Platform/EventLoopPlugin.h +++ b/Userland/Libraries/LibWeb/Platform/EventLoopPlugin.h @@ -21,6 +21,7 @@ public: virtual void spin_until(Function goal_condition) = 0; virtual void deferred_invoke(Function) = 0; virtual NonnullRefPtr create_timer() = 0; + virtual void quit() = 0; }; } diff --git a/Userland/Libraries/LibWeb/Platform/EventLoopPluginSerenity.cpp b/Userland/Libraries/LibWeb/Platform/EventLoopPluginSerenity.cpp index db035a1778..7a2246a30c 100644 --- a/Userland/Libraries/LibWeb/Platform/EventLoopPluginSerenity.cpp +++ b/Userland/Libraries/LibWeb/Platform/EventLoopPluginSerenity.cpp @@ -31,4 +31,9 @@ NonnullRefPtr EventLoopPluginSerenity::create_timer() return TimerSerenity::create(); } +void EventLoopPluginSerenity::quit() +{ + Core::EventLoop::current().quit(0); +} + } diff --git a/Userland/Libraries/LibWeb/Platform/EventLoopPluginSerenity.h b/Userland/Libraries/LibWeb/Platform/EventLoopPluginSerenity.h index 9e04e64112..0479b91e5a 100644 --- a/Userland/Libraries/LibWeb/Platform/EventLoopPluginSerenity.h +++ b/Userland/Libraries/LibWeb/Platform/EventLoopPluginSerenity.h @@ -18,6 +18,7 @@ public: virtual void spin_until(Function goal_condition) override; virtual void deferred_invoke(Function) override; virtual NonnullRefPtr create_timer() override; + virtual void quit() override; }; } diff --git a/Userland/Services/WebContent/ConnectionFromClient.cpp b/Userland/Services/WebContent/ConnectionFromClient.cpp index a1f1efa954..5f54a26340 100644 --- a/Userland/Services/WebContent/ConnectionFromClient.cpp +++ b/Userland/Services/WebContent/ConnectionFromClient.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -45,7 +46,7 @@ ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr