mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-06 17:11:51 +00:00
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:
parent
2fc1cafb8a
commit
939bb10828
Notes:
github-actions[bot]
2025-04-25 14:46:02 +00:00
Author: https://github.com/shannonbooth
Commit: 939bb10828
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4453
6 changed files with 17 additions and 16 deletions
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Andrew Kaster <akaster@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/PrincipalHostDefined.h>
|
||||
#include <LibWeb/HTML/MessagePort.h>
|
||||
#include <LibWeb/HTML/WorkerAgent.h>
|
||||
#include <LibWeb/Page/Page.h>
|
||||
#include <LibWeb/Worker/WebWorkerClient.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
GC_DEFINE_ALLOCATOR(WorkerAgent);
|
||||
|
||||
WorkerAgent::WorkerAgent(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)
|
||||
, m_outside_settings(outside_settings)
|
||||
{
|
||||
}
|
||||
|
||||
void WorkerAgent::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
|
||||
m_message_port = MessagePort::create(realm);
|
||||
m_message_port->entangle_with(*m_outside_port);
|
||||
|
||||
TransferDataHolder data_holder;
|
||||
MUST(m_message_port->transfer_steps(data_holder));
|
||||
|
||||
// NOTE: This blocking IPC call may launch another process.
|
||||
// If spinning the event loop for this can cause other javascript to execute, we're in trouble.
|
||||
auto worker_socket_file = Bindings::principal_host_defined_page(realm).client().request_worker_agent();
|
||||
|
||||
auto worker_socket = MUST(Core::LocalSocket::adopt_fd(worker_socket_file.take_fd()));
|
||||
MUST(worker_socket->set_blocking(true));
|
||||
|
||||
// TODO: Mach IPC
|
||||
auto transport = make<IPC::Transport>(move(worker_socket));
|
||||
|
||||
m_worker_ipc = make_ref_counted<WebWorkerClient>(move(transport));
|
||||
|
||||
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)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_message_port);
|
||||
visitor.visit(m_outside_port);
|
||||
visitor.visit(m_outside_settings);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue