2023-11-08 13:47:41 -05:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2023, Andrew Kaster <akaster@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/HashMap.h>
|
2024-11-14 10:01:23 -05:00
|
|
|
#include <LibGC/Root.h>
|
2023-11-08 13:47:41 -05:00
|
|
|
#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>
|
2023-12-05 12:15:46 -05:00
|
|
|
#include <WebWorker/PageHost.h>
|
2023-11-08 13:47:41 -05:00
|
|
|
|
|
|
|
namespace WebWorker {
|
|
|
|
|
|
|
|
class ConnectionFromClient final
|
|
|
|
: public IPC::ConnectionFromClient<WebWorkerClientEndpoint, WebWorkerServerEndpoint> {
|
|
|
|
C_OBJECT(ConnectionFromClient);
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~ConnectionFromClient() override;
|
|
|
|
|
|
|
|
virtual void die() override;
|
|
|
|
|
2024-07-09 05:00:06 -04:00
|
|
|
virtual void close_worker() override;
|
|
|
|
|
2023-11-08 13:47:41 -05:00
|
|
|
void request_file(Web::FileRequest);
|
|
|
|
|
|
|
|
PageHost& page_host() { return *m_page_host; }
|
|
|
|
PageHost const& page_host() const { return *m_page_host; }
|
|
|
|
|
|
|
|
private:
|
2024-10-22 17:47:33 -04:00
|
|
|
explicit ConnectionFromClient(IPC::Transport);
|
2023-11-08 13:47:41 -05:00
|
|
|
|
|
|
|
Web::Page& page();
|
|
|
|
Web::Page const& page() const;
|
|
|
|
|
2024-09-10 22:57:48 -04:00
|
|
|
virtual void start_dedicated_worker(URL::URL const& url, Web::Bindings::WorkerType const& type, Web::Bindings::RequestCredentials const& credentials, String const& name, Web::HTML::TransferDataHolder const&, Web::HTML::SerializedEnvironmentSettingsObject const&) override;
|
2023-11-08 13:47:41 -05:00
|
|
|
virtual void handle_file_return(i32 error, Optional<IPC::File> const& file, i32 request_id) override;
|
|
|
|
|
2024-11-14 10:01:23 -05:00
|
|
|
GC::Root<PageHost> m_page_host;
|
2023-11-08 13:47:41 -05:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|