mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibWeb+WebContent: Add IPC to re-establish RequestServer connections
This commit is contained in:
parent
6f4be4791a
commit
b1b218596f
Notes:
github-actions[bot]
2025-08-10 09:04:11 +00:00
Author: https://github.com/trflynn89
Commit: b1b218596f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5796
7 changed files with 65 additions and 13 deletions
|
|
@ -47,7 +47,10 @@
|
|||
#endif
|
||||
|
||||
static ErrorOr<void> load_content_filters(StringView config_path);
|
||||
|
||||
static ErrorOr<void> initialize_resource_loader(GC::Heap&, int request_server_socket);
|
||||
static ErrorOr<void> reinitialize_resource_loader(IPC::File const& image_decoder_socket);
|
||||
|
||||
static ErrorOr<void> initialize_image_decoder(int image_decoder_socket);
|
||||
static ErrorOr<void> reinitialize_image_decoder(IPC::File const& image_decoder_socket);
|
||||
|
||||
|
|
@ -219,10 +222,13 @@ ErrorOr<int> ladybird_main(Main::Arguments arguments)
|
|||
auto webcontent_socket = TRY(Core::take_over_socket_from_system_server("WebContent"sv));
|
||||
auto webcontent_client = TRY(WebContent::ConnectionFromClient::try_create(make<IPC::Transport>(move(webcontent_socket))));
|
||||
|
||||
webcontent_client->on_image_decoder_connection = [&](auto& socket_file) {
|
||||
auto maybe_error = reinitialize_image_decoder(socket_file);
|
||||
if (maybe_error.is_error())
|
||||
dbgln("Failed to reinitialize image decoder: {}", maybe_error.error());
|
||||
webcontent_client->on_request_server_connection = [&](auto const& socket_file) {
|
||||
if (auto result = reinitialize_resource_loader(socket_file); result.is_error())
|
||||
dbgln("Failed to reinitialize resource loader: {}", result.error());
|
||||
};
|
||||
webcontent_client->on_image_decoder_connection = [&](auto const& socket_file) {
|
||||
if (auto result = reinitialize_image_decoder(socket_file); result.is_error())
|
||||
dbgln("Failed to reinitialize image decoder: {}", result.error());
|
||||
};
|
||||
|
||||
return event_loop.exec();
|
||||
|
|
@ -255,7 +261,6 @@ static ErrorOr<void> load_content_filters(StringView config_path)
|
|||
ErrorOr<void> initialize_resource_loader(GC::Heap& heap, int request_server_socket)
|
||||
{
|
||||
// TODO: Mach IPC
|
||||
|
||||
auto socket = TRY(Core::LocalSocket::adopt_fd(request_server_socket));
|
||||
TRY(socket->set_blocking(true));
|
||||
|
||||
|
|
@ -264,7 +269,19 @@ ErrorOr<void> initialize_resource_loader(GC::Heap& heap, int request_server_sock
|
|||
auto response = request_client->send_sync<Messages::RequestServer::InitTransport>(Core::System::getpid());
|
||||
request_client->transport().set_peer_pid(response->peer_pid());
|
||||
#endif
|
||||
|
||||
Web::ResourceLoader::initialize(heap, move(request_client));
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void> reinitialize_resource_loader(IPC::File const& request_server_socket)
|
||||
{
|
||||
// TODO: Mach IPC
|
||||
auto socket = TRY(Core::LocalSocket::adopt_fd(request_server_socket.take_fd()));
|
||||
TRY(socket->set_blocking(true));
|
||||
|
||||
auto request_client = TRY(try_make_ref_counted<Requests::RequestClient>(make<IPC::Transport>(move(socket))));
|
||||
Web::ResourceLoader::the().set_client(move(request_client));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
@ -282,19 +299,16 @@ ErrorOr<void> initialize_image_decoder(int image_decoder_socket)
|
|||
#endif
|
||||
|
||||
Web::Platform::ImageCodecPlugin::install(*new WebView::ImageCodecPlugin(move(new_client)));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void> reinitialize_image_decoder(IPC::File const& image_decoder_socket)
|
||||
{
|
||||
// TODO: Mach IPC
|
||||
|
||||
auto socket = TRY(Core::LocalSocket::adopt_fd(image_decoder_socket.take_fd()));
|
||||
TRY(socket->set_blocking(true));
|
||||
|
||||
auto new_client = TRY(try_make_ref_counted<ImageDecoderClient::Client>(make<IPC::Transport>(move(socket))));
|
||||
|
||||
static_cast<WebView::ImageCodecPlugin&>(Web::Platform::ImageCodecPlugin::the()).set_client(move(new_client));
|
||||
|
||||
return {};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue