2023-11-08 11:47:41 -07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2023, Andrew Kaster <akaster@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2024-09-10 20:57:48 -06:00
|
|
|
#include <LibWeb/Bindings/RequestPrototype.h>
|
|
|
|
#include <LibWeb/Bindings/WorkerPrototype.h>
|
2023-11-08 11:47:41 -07:00
|
|
|
#include <LibWeb/Forward.h>
|
|
|
|
#include <LibWeb/Worker/WebWorkerClient.h>
|
|
|
|
|
|
|
|
namespace Web::HTML {
|
|
|
|
|
|
|
|
struct WorkerOptions {
|
2024-09-10 20:57:48 -06:00
|
|
|
Bindings::WorkerType type { Bindings::WorkerType::Classic };
|
|
|
|
Bindings::RequestCredentials credentials { Bindings::RequestCredentials::SameOrigin };
|
2023-11-08 11:47:41 -07:00
|
|
|
String name { String {} };
|
|
|
|
};
|
|
|
|
|
2024-01-06 13:13:59 -07:00
|
|
|
class WorkerAgent : public JS::Cell {
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_CELL(WorkerAgent, JS::Cell);
|
|
|
|
GC_DECLARE_ALLOCATOR(WorkerAgent);
|
2023-11-08 11:47:41 -07:00
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
WorkerAgent(URL::URL url, WorkerOptions const& options, GC::Ptr<MessagePort> outside_port, GC::Ref<EnvironmentSettingsObject> outside_settings);
|
2023-11-08 11:47:41 -07:00
|
|
|
|
|
|
|
private:
|
2023-12-20 13:47:01 -07:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
|
2023-11-08 11:47:41 -07:00
|
|
|
WorkerOptions m_worker_options;
|
2024-03-18 16:22:27 +13:00
|
|
|
URL::URL m_url;
|
2023-11-08 11:47:41 -07:00
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ptr<MessagePort> m_message_port;
|
|
|
|
GC::Ptr<MessagePort> m_outside_port;
|
|
|
|
GC::Ref<EnvironmentSettingsObject> m_outside_settings;
|
2024-01-06 13:13:59 -07:00
|
|
|
|
|
|
|
RefPtr<Web::HTML::WebWorkerClient> m_worker_ipc;
|
2023-11-08 11:47:41 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|