Skip to content

Commit

Permalink
Ladybird: Remove unnecessary RegisterWithProcessManager enum
Browse files Browse the repository at this point in the history
This was only put in place because on SerenityOS, we wanted to use the
pid of the WebContent process, rather than the peer pid for the socket.

When launching with SystemServer, this got annoying. However, now that
we only have the case that the UI process spawns processes, we can
get rid of this hack. This restores the ability to see WebContent
processes' statistics in the task manager widget.
  • Loading branch information
ADKaster committed Jun 26, 2024
1 parent 54aa4e7 commit 60eb614
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions Ladybird/HelperProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,11 @@
#include <LibCore/Process.h>
#include <LibWebView/ProcessManager.h>

enum class RegisterWithProcessManager {
No,
Yes,
};

template<typename ClientType, typename... ClientArguments>
static ErrorOr<NonnullRefPtr<ClientType>> launch_server_process(
StringView server_name,
ReadonlySpan<ByteString> candidate_server_paths,
Vector<ByteString> arguments,
RegisterWithProcessManager register_with_process_manager,
Ladybird::EnableCallgrindProfiling enable_callgrind_profiling,
ClientArguments&&... client_arguments)
{
Expand Down Expand Up @@ -51,8 +45,7 @@ static ErrorOr<NonnullRefPtr<ClientType>> launch_server_process(
if constexpr (requires { process.client->set_pid(pid_t {}); })
process.client->set_pid(process.process.pid());

if (register_with_process_manager == RegisterWithProcessManager::Yes)
WebView::ProcessManager::the().add_process(WebView::process_type_from_name(server_name), process.process.pid());
WebView::ProcessManager::the().add_process(WebView::process_type_from_name(server_name), process.process.pid());

if (enable_callgrind_profiling == Ladybird::EnableCallgrindProfiling::Yes) {
dbgln();
Expand Down Expand Up @@ -117,7 +110,7 @@ ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_process(
arguments.append("--image-decoder-socket"sv);
arguments.append(ByteString::number(image_decoder_socket.fd()));

return launch_server_process<WebView::WebContentClient>("WebContent"sv, candidate_web_content_paths, move(arguments), RegisterWithProcessManager::No, web_content_options.enable_callgrind_profiling, view);
return launch_server_process<WebView::WebContentClient>("WebContent"sv, candidate_web_content_paths, move(arguments), web_content_options.enable_callgrind_profiling, view);
}

ErrorOr<NonnullRefPtr<ImageDecoderClient::Client>> launch_image_decoder_process(ReadonlySpan<ByteString> candidate_image_decoder_paths)
Expand All @@ -128,7 +121,7 @@ ErrorOr<NonnullRefPtr<ImageDecoderClient::Client>> launch_image_decoder_process(
arguments.append(server.value());
}

return launch_server_process<ImageDecoderClient::Client>("ImageDecoder"sv, candidate_image_decoder_paths, arguments, RegisterWithProcessManager::Yes, Ladybird::EnableCallgrindProfiling::No);
return launch_server_process<ImageDecoderClient::Client>("ImageDecoder"sv, candidate_image_decoder_paths, arguments, Ladybird::EnableCallgrindProfiling::No);
}

ErrorOr<NonnullRefPtr<Web::HTML::WebWorkerClient>> launch_web_worker_process(ReadonlySpan<ByteString> candidate_web_worker_paths, NonnullRefPtr<Protocol::RequestClient> request_client)
Expand All @@ -140,7 +133,7 @@ ErrorOr<NonnullRefPtr<Web::HTML::WebWorkerClient>> launch_web_worker_process(Rea
ByteString::number(socket.fd()),
};

return launch_server_process<Web::HTML::WebWorkerClient>("WebWorker"sv, candidate_web_worker_paths, move(arguments), RegisterWithProcessManager::Yes, Ladybird::EnableCallgrindProfiling::No);
return launch_server_process<Web::HTML::WebWorkerClient>("WebWorker"sv, candidate_web_worker_paths, move(arguments), Ladybird::EnableCallgrindProfiling::No);
}

ErrorOr<NonnullRefPtr<Protocol::RequestClient>> launch_request_server_process(ReadonlySpan<ByteString> candidate_request_server_paths, StringView serenity_resource_root, Vector<ByteString> const& certificates)
Expand All @@ -160,7 +153,7 @@ ErrorOr<NonnullRefPtr<Protocol::RequestClient>> launch_request_server_process(Re
arguments.append(server.value());
}

return launch_server_process<Protocol::RequestClient>("RequestServer"sv, candidate_request_server_paths, move(arguments), RegisterWithProcessManager::Yes, Ladybird::EnableCallgrindProfiling::No);
return launch_server_process<Protocol::RequestClient>("RequestServer"sv, candidate_request_server_paths, move(arguments), Ladybird::EnableCallgrindProfiling::No);
}

ErrorOr<IPC::File> connect_new_request_server_client(Protocol::RequestClient& client)
Expand Down

0 comments on commit 60eb614

Please sign in to comment.