mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:57:35 +00:00
LibWeb+WebWorker: Move worker execution into a new WebWorker process
We now create a WorkerAgent for the parent context, which is currently only a Window. Note that Workers can have Workers per the spec. The WorkerAgent spawns a WebWorker process to hold the actual script execution of the Worker. This is modeled with the DedicatedWorkerHost object in the WebWorker process. A start_dedicated_worker IPC method in the WebWorker IPC creates the WorkerHost object. Future different worker types may use different IPC messages to create their WorkerHost instance. This implementation cannot yet postMessage between the parent and the child processes. Co-Authored-By: Andreas Kling <kling@serenityos.org>
This commit is contained in:
parent
3dbbb5b263
commit
124c378472
31 changed files with 998 additions and 267 deletions
53
Userland/Services/WebWorker/ConnectionFromClient.h
Normal file
53
Userland/Services/WebWorker/ConnectionFromClient.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Andrew Kaster <akaster@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/HashMap.h>
|
||||
#include <LibIPC/ConnectionFromClient.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/Loader/FileRequest.h>
|
||||
#include <LibWeb/Worker/WebWorkerClientEndpoint.h>
|
||||
#include <LibWeb/Worker/WebWorkerServerEndpoint.h>
|
||||
#include <WebWorker/Forward.h>
|
||||
|
||||
namespace WebWorker {
|
||||
|
||||
class ConnectionFromClient final
|
||||
: public IPC::ConnectionFromClient<WebWorkerClientEndpoint, WebWorkerServerEndpoint> {
|
||||
C_OBJECT(ConnectionFromClient);
|
||||
|
||||
public:
|
||||
virtual ~ConnectionFromClient() override;
|
||||
|
||||
virtual void die() override;
|
||||
|
||||
void request_file(Web::FileRequest);
|
||||
|
||||
PageHost& page_host() { return *m_page_host; }
|
||||
PageHost const& page_host() const { return *m_page_host; }
|
||||
|
||||
private:
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>);
|
||||
|
||||
Web::Page& page();
|
||||
Web::Page const& page() const;
|
||||
|
||||
virtual void start_dedicated_worker(AK::URL const& url, String const&, String const&, String const&, IPC::File const&) override;
|
||||
virtual void handle_file_return(i32 error, Optional<IPC::File> const& file, i32 request_id) override;
|
||||
|
||||
NonnullOwnPtr<PageHost> m_page_host;
|
||||
|
||||
// FIXME: Route console messages to the Browser UI using a ConsoleClient
|
||||
|
||||
HashMap<int, Web::FileRequest> m_requested_files {};
|
||||
int last_id { 0 };
|
||||
|
||||
RefPtr<DedicatedWorkerHost> m_worker_host;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue