
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>
39 lines
1.4 KiB
C++
39 lines
1.4 KiB
C++
/*
|
|
* Copyright (c) 2023, Andrew Kaster <akaster@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.h>
|
|
#include <LibWeb/HTML/WorkerGlobalScope.h>
|
|
|
|
namespace Web::HTML {
|
|
|
|
JS::NonnullGCPtr<WorkerEnvironmentSettingsObject> WorkerEnvironmentSettingsObject::setup(NonnullOwnPtr<JS::ExecutionContext> execution_context /* FIXME: null or an environment reservedEnvironment, a URL topLevelCreationURL, and an origin topLevelOrigin */)
|
|
{
|
|
auto realm = execution_context->realm;
|
|
VERIFY(realm);
|
|
|
|
auto& worker = verify_cast<HTML::WorkerGlobalScope>(realm->global_object());
|
|
|
|
auto settings_object = realm->heap().allocate<WorkerEnvironmentSettingsObject>(*realm, move(execution_context), worker);
|
|
settings_object->target_browsing_context = nullptr;
|
|
|
|
auto intrinsics = realm->heap().allocate<Bindings::Intrinsics>(*realm, *realm);
|
|
auto host_defined = make<Bindings::HostDefined>(settings_object, intrinsics);
|
|
realm->set_host_defined(move(host_defined));
|
|
|
|
// Non-Standard: We cannot fully initialize worker object until *after* the we set up
|
|
// the realm's [[HostDefined]] internal slot as the internal slot contains the web platform intrinsics
|
|
worker.initialize_web_interfaces({});
|
|
|
|
return settings_object;
|
|
}
|
|
|
|
void WorkerEnvironmentSettingsObject::visit_edges(JS::Cell::Visitor& visitor)
|
|
{
|
|
Base::visit_edges(visitor);
|
|
visitor.visit(m_global_scope);
|
|
}
|
|
|
|
}
|