1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-10 10:01:13 +09:00

LibWeb+WebWorker: Add IPC messages to request and communicate shutdown

This commit is contained in:
Andrew Kaster 2024-07-09 03:00:06 -06:00 committed by Andreas Kling
parent 5d8784318d
commit 27ef9ffa8f
Notes: sideshowbarker 2024-07-17 04:01:41 +09:00
6 changed files with 25 additions and 0 deletions

View file

@ -14,6 +14,12 @@ void WebWorkerClient::die()
// FIXME: Notify WorkerAgent that the worker is ded // FIXME: Notify WorkerAgent that the worker is ded
} }
void WebWorkerClient::did_close_worker()
{
if (on_worker_close)
on_worker_close();
}
WebWorkerClient::WebWorkerClient(NonnullOwnPtr<Core::LocalSocket> socket) WebWorkerClient::WebWorkerClient(NonnullOwnPtr<Core::LocalSocket> socket)
: IPC::ConnectionToServer<WebWorkerClientEndpoint, WebWorkerServerEndpoint>(*this, move(socket)) : IPC::ConnectionToServer<WebWorkerClientEndpoint, WebWorkerServerEndpoint>(*this, move(socket))
{ {

View file

@ -21,6 +21,10 @@ class WebWorkerClient final
public: public:
explicit WebWorkerClient(NonnullOwnPtr<Core::LocalSocket>); explicit WebWorkerClient(NonnullOwnPtr<Core::LocalSocket>);
virtual void did_close_worker() override;
Function<void()> on_worker_close;
IPC::File dup_socket(); IPC::File dup_socket();
private: private:

View file

@ -1,2 +1,3 @@
endpoint WebWorkerClient { endpoint WebWorkerClient {
did_close_worker() =|
} }

View file

@ -7,5 +7,7 @@ endpoint WebWorkerServer {
start_dedicated_worker(URL::URL url, String type, String credentials, String name, Web::HTML::TransferDataHolder message_port, Web::HTML::SerializedEnvironmentSettingsObject outside_settings) =| start_dedicated_worker(URL::URL url, String type, String credentials, String name, Web::HTML::TransferDataHolder message_port, Web::HTML::SerializedEnvironmentSettingsObject outside_settings) =|
close_worker() =|
handle_file_return(i32 error, Optional<IPC::File> file, i32 request_id) =| handle_file_return(i32 error, Optional<IPC::File> file, i32 request_id) =|
} }

View file

@ -11,6 +11,16 @@
namespace WebWorker { namespace WebWorker {
void ConnectionFromClient::close_worker()
{
async_did_close_worker();
// FIXME: Invoke a worker shutdown operation that implements the spec
m_worker_host = nullptr;
die();
}
void ConnectionFromClient::die() void ConnectionFromClient::die()
{ {
// FIXME: When handling multiple workers in the same process, // FIXME: When handling multiple workers in the same process,

View file

@ -28,6 +28,8 @@ public:
virtual void die() override; virtual void die() override;
virtual void close_worker() override;
void request_file(Web::FileRequest); void request_file(Web::FileRequest);
PageHost& page_host() { return *m_page_host; } PageHost& page_host() { return *m_page_host; }