LibWeb/HTML: Rename WorkerAgent to WorkerAgentParent

This is to differentiate the agent representation for the parent
process for the WorkerAgent in the child process which is actually
hooked up to the javascript VM.

I am not sure if this is a good name, but I can't really think of
anything better which is consistent with the names used by the rest
of the codebase.
This commit is contained in:
Shannon Booth 2025-04-24 14:08:39 +12:00 committed by Andreas Kling
commit 939bb10828
Notes: github-actions[bot] 2025-04-25 14:46:02 +00:00
6 changed files with 17 additions and 16 deletions

View file

@ -545,7 +545,7 @@ set(SOURCES
HTML/WindowOrWorkerGlobalScope.cpp
HTML/WindowProxy.cpp
HTML/Worker.cpp
HTML/WorkerAgent.cpp
HTML/WorkerAgentParent.cpp
HTML/WorkerDebugConsoleClient.cpp
HTML/WorkerGlobalScope.cpp
HTML/WorkerLocation.cpp

View file

@ -579,7 +579,7 @@ class Window;
class WindowEnvironmentSettingsObject;
class WindowProxy;
class Worker;
class WorkerAgent;
class WorkerAgentParent;
class WorkerDebugConsoleClient;
class WorkerEnvironmentSettingsObject;
class WorkerGlobalScope;

View file

@ -110,7 +110,7 @@ void Worker::run_a_worker(URL::URL& url, EnvironmentSettingsObject& outside_sett
// and is shared. Run the rest of these steps in that agent.
// Note: This spawns a new process to act as the 'agent' for the worker.
m_agent = outside_settings.realm().create<WorkerAgent>(url, options, port, outside_settings);
m_agent = outside_settings.realm().create<WorkerAgentParent>(url, options, port, outside_settings);
}
// https://html.spec.whatwg.org/multipage/workers.html#dom-worker-terminate

View file

@ -9,7 +9,7 @@
#include <LibWeb/Forward.h>
#include <LibWeb/HTML/AbstractWorker.h>
#include <LibWeb/HTML/Window.h>
#include <LibWeb/HTML/WorkerAgent.h>
#include <LibWeb/HTML/WorkerAgentParent.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
#define ENUMERATE_WORKER_EVENT_HANDLERS(E) \
@ -65,7 +65,7 @@ private:
GC::Ptr<DOM::Document> m_document;
GC::Ptr<MessagePort> m_outside_port;
GC::Ptr<WorkerAgent> m_agent;
GC::Ptr<WorkerAgentParent> m_agent;
void run_a_worker(URL::URL& url, EnvironmentSettingsObject& outside_settings, GC::Ptr<MessagePort> outside_port, WorkerOptions const& options);
};

View file

@ -6,15 +6,15 @@
#include <LibWeb/Bindings/PrincipalHostDefined.h>
#include <LibWeb/HTML/MessagePort.h>
#include <LibWeb/HTML/WorkerAgent.h>
#include <LibWeb/HTML/WorkerAgentParent.h>
#include <LibWeb/Page/Page.h>
#include <LibWeb/Worker/WebWorkerClient.h>
namespace Web::HTML {
GC_DEFINE_ALLOCATOR(WorkerAgent);
GC_DEFINE_ALLOCATOR(WorkerAgentParent);
WorkerAgent::WorkerAgent(URL::URL url, WorkerOptions const& options, GC::Ptr<MessagePort> outside_port, GC::Ref<EnvironmentSettingsObject> outside_settings)
WorkerAgentParent::WorkerAgentParent(URL::URL url, WorkerOptions const& options, GC::Ptr<MessagePort> outside_port, GC::Ref<EnvironmentSettingsObject> outside_settings)
: m_worker_options(options)
, m_url(move(url))
, m_outside_port(outside_port)
@ -22,7 +22,7 @@ WorkerAgent::WorkerAgent(URL::URL url, WorkerOptions const& options, GC::Ptr<Mes
{
}
void WorkerAgent::initialize(JS::Realm& realm)
void WorkerAgentParent::initialize(JS::Realm& realm)
{
Base::initialize(realm);
@ -47,7 +47,7 @@ void WorkerAgent::initialize(JS::Realm& realm)
m_worker_ipc->async_start_dedicated_worker(m_url, m_worker_options.type, m_worker_options.credentials, m_worker_options.name, move(data_holder), m_outside_settings->serialize());
}
void WorkerAgent::visit_edges(Cell::Visitor& visitor)
void WorkerAgentParent::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_message_port);

View file

@ -19,16 +19,17 @@ struct WorkerOptions {
String name { String {} };
};
class WorkerAgent : public JS::Cell {
GC_CELL(WorkerAgent, JS::Cell);
GC_DECLARE_ALLOCATOR(WorkerAgent);
// FIXME: Figure out a better naming convention for this type of parent/child process pattern.
class WorkerAgentParent : public JS::Cell {
GC_CELL(WorkerAgentParent, JS::Cell);
GC_DECLARE_ALLOCATOR(WorkerAgentParent);
WorkerAgent(URL::URL url, WorkerOptions const& options, GC::Ptr<MessagePort> outside_port, GC::Ref<EnvironmentSettingsObject> outside_settings);
private:
protected:
WorkerAgentParent(URL::URL url, WorkerOptions const& options, GC::Ptr<MessagePort> outside_port, GC::Ref<EnvironmentSettingsObject> outside_settings);
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
private:
WorkerOptions m_worker_options;
URL::URL m_url;