mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 04:39:06 +00:00
Everywhere: Hoist the Services folder to the top-level
This commit is contained in:
parent
a7dc40eff3
commit
22e0eeada2
Notes:
github-actions[bot]
2024-11-10 11:52:06 +00:00
Author: https://github.com/trflynn89
Commit: 22e0eeada2
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256
Reviewed-by: https://github.com/sideshowbarker
68 changed files with 41 additions and 41 deletions
85
Services/WebWorker/main.cpp
Normal file
85
Services/WebWorker/main.cpp
Normal file
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Andrew Kaster <akaster@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <Ladybird/FontPlugin.h>
|
||||
#include <Ladybird/HelperProcess.h>
|
||||
#include <Ladybird/Utilities.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/LocalServer.h>
|
||||
#include <LibCore/Process.h>
|
||||
#include <LibCore/StandardPaths.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibFileSystem/FileSystem.h>
|
||||
#include <LibIPC/SingleServer.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <LibWeb/Bindings/MainThreadVM.h>
|
||||
#include <LibWeb/Loader/GeneratedPagesLoader.h>
|
||||
#include <LibWeb/Loader/ResourceLoader.h>
|
||||
#include <LibWeb/Platform/EventLoopPlugin.h>
|
||||
#include <LibWeb/Platform/EventLoopPluginSerenity.h>
|
||||
#include <LibWeb/WebSockets/WebSocket.h>
|
||||
#include <WebWorker/ConnectionFromClient.h>
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
# include <Ladybird/Qt/EventLoopImplementationQt.h>
|
||||
# include <QCoreApplication>
|
||||
#endif
|
||||
|
||||
static ErrorOr<void> initialize_resource_loader(JS::Heap&, int request_server_socket);
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
AK::set_rich_debug_enabled(true);
|
||||
|
||||
int request_server_socket { -1 };
|
||||
StringView serenity_resource_root;
|
||||
Vector<ByteString> certificates;
|
||||
bool wait_for_debugger = false;
|
||||
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_option(request_server_socket, "File descriptor of the request server socket", "request-server-socket", 's', "request-server-socket");
|
||||
args_parser.add_option(serenity_resource_root, "Absolute path to directory for serenity resources", "serenity-resource-root", 'r', "serenity-resource-root");
|
||||
args_parser.add_option(certificates, "Path to a certificate file", "certificate", 'C', "certificate");
|
||||
args_parser.add_option(wait_for_debugger, "Wait for debugger", "wait-for-debugger");
|
||||
args_parser.parse(arguments);
|
||||
|
||||
if (wait_for_debugger)
|
||||
Core::Process::wait_for_debugger_and_break();
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
QCoreApplication app(arguments.argc, arguments.argv);
|
||||
Core::EventLoopManager::install(*new Ladybird::EventLoopManagerQt);
|
||||
#endif
|
||||
Core::EventLoop event_loop;
|
||||
|
||||
platform_init();
|
||||
|
||||
Web::Platform::EventLoopPlugin::install(*new Web::Platform::EventLoopPluginSerenity);
|
||||
|
||||
Web::Platform::FontPlugin::install(*new Ladybird::FontPlugin(false));
|
||||
|
||||
TRY(Web::Bindings::initialize_main_thread_vm(Web::HTML::EventLoop::Type::Worker));
|
||||
|
||||
TRY(initialize_resource_loader(Web::Bindings::main_thread_vm().heap(), request_server_socket));
|
||||
|
||||
auto client = TRY(IPC::take_over_accepted_client_from_system_server<WebWorker::ConnectionFromClient>());
|
||||
|
||||
return event_loop.exec();
|
||||
}
|
||||
|
||||
static ErrorOr<void> initialize_resource_loader(JS::Heap& heap, int request_server_socket)
|
||||
{
|
||||
static_assert(IsSame<IPC::Transport, IPC::TransportSocket>, "Need to handle other IPC transports here");
|
||||
|
||||
auto socket = TRY(Core::LocalSocket::adopt_fd(request_server_socket));
|
||||
TRY(socket->set_blocking(true));
|
||||
|
||||
auto request_client = TRY(try_make_ref_counted<Requests::RequestClient>(IPC::Transport(move(socket))));
|
||||
Web::ResourceLoader::initialize(heap, move(request_client));
|
||||
|
||||
return {};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue