summaryrefslogtreecommitdiff
path: root/Ladybird
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2023-03-12 12:35:06 -0400
committerLinus Groh <mail@linusgroh.de>2023-03-13 07:21:00 +0000
commitadd15a5f04984592121839a27fcb59992ec1b737 (patch)
tree43b0c96d0b8ab20cbeded42dd7433e55a1167e23 /Ladybird
parentbe4da57004ccc9a97e1e2ae1a28d101877b8f164 (diff)
downloadserenity-add15a5f04984592121839a27fcb59992ec1b737.zip
Ladybird+LibWebView: Move WebContent process launcher to LibWebView
This is to allow headless-browser to reuse this code. We have a similar helper for launching SQLServer from Ladybird.
Diffstat (limited to 'Ladybird')
-rw-r--r--Ladybird/WebContentView.cpp49
1 files changed, 2 insertions, 47 deletions
diff --git a/Ladybird/WebContentView.cpp b/Ladybird/WebContentView.cpp
index 26d03ae63c..e16e3f8ad8 100644
--- a/Ladybird/WebContentView.cpp
+++ b/Ladybird/WebContentView.cpp
@@ -568,53 +568,8 @@ void WebContentView::create_client()
{
m_client_state = {};
- int socket_fds[2] {};
- MUST(Core::System::socketpair(AF_LOCAL, SOCK_STREAM, 0, socket_fds));
-
- int ui_fd = socket_fds[0];
- int wc_fd = socket_fds[1];
-
- int fd_passing_socket_fds[2] {};
- MUST(Core::System::socketpair(AF_LOCAL, SOCK_STREAM, 0, fd_passing_socket_fds));
-
- int ui_fd_passing_fd = fd_passing_socket_fds[0];
- int wc_fd_passing_fd = fd_passing_socket_fds[1];
-
- auto child_pid = fork();
- if (!child_pid) {
- MUST(Core::System::close(ui_fd_passing_fd));
- MUST(Core::System::close(ui_fd));
-
- auto takeover_string = DeprecatedString::formatted("WebContent:{}", wc_fd);
- MUST(Core::System::setenv("SOCKET_TAKEOVER"sv, takeover_string, true));
-
- auto webcontent_fd_passing_socket_string = DeprecatedString::number(wc_fd_passing_fd);
-
- Vector<StringView, 5> arguments {
- "WebContent"sv,
- "--webcontent-fd-passing-socket"sv,
- webcontent_fd_passing_socket_string
- };
-
- if (!m_webdriver_content_ipc_path.is_empty()) {
- arguments.append("--webdriver-content-path"sv);
- arguments.append(m_webdriver_content_ipc_path);
- }
-
- auto result = spawn_helper_process("WebContent"sv, arguments, Core::System::SearchInPath::Yes);
- if (result.is_error())
- warnln("Could not launch WebContent: {}", result.error());
- VERIFY_NOT_REACHED();
- }
-
- MUST(Core::System::close(wc_fd_passing_fd));
- MUST(Core::System::close(wc_fd));
-
- auto socket = MUST(Core::LocalSocket::adopt_fd(ui_fd));
- MUST(socket->set_blocking(true));
-
- auto new_client = MUST(adopt_nonnull_ref_or_enomem(new (nothrow) WebView::WebContentClient(std::move(socket), *this)));
- new_client->set_fd_passing_socket(MUST(Core::LocalSocket::adopt_fd(ui_fd_passing_fd)));
+ auto candidate_web_content_paths = get_paths_for_helper_process("WebContent"sv).release_value_but_fixme_should_propagate_errors();
+ auto new_client = launch_web_content_process(candidate_web_content_paths, m_webdriver_content_ipc_path).release_value_but_fixme_should_propagate_errors();
m_web_content_notifier.setSocket(new_client->socket().fd().value());
m_web_content_notifier.setEnabled(true);