mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-19 02:10:26 +00:00
Registering multiple Mach port names with the bootstrap server at runtime is not how macOS expects it to be used — the bootstrap server is meant for static services, and the only reason we used it originally was so child processes could reach back to the UI process. Remove bootstrap_transport_over_socket(), which had both sides register dynamic names with the bootstrap server and exchange them over a socket. Instead, WebDriver and BrowserProcess connections now go through MachPortServer instances directly. When a non-child process contacts a MachPortServer, the server creates a port pair on demand (detected via sysctl ppid check) and returns the local half immediately. This keeps bootstrap server usage limited to the one original case: child processes looking up their parent's MachPortServer. WebDriver Session now runs its own MachPortServer per session. --webdriver-content-path becomes --webdriver-mach-server-name on macOS. Spare WebContent launches are skipped when a WebDriver session is active to avoid bootstrap races.
78 lines
2.2 KiB
C++
78 lines
2.2 KiB
C++
/*
|
|
* Copyright (c) 2024, Andrew Kaster <akaster@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Error.h>
|
|
#include <AK/Function.h>
|
|
#include <AK/OwnPtr.h>
|
|
#include <AK/RefPtr.h>
|
|
#include <AK/Types.h>
|
|
#include <LibCore/LocalServer.h>
|
|
#include <LibIPC/ConnectionFromClient.h>
|
|
#include <LibIPC/Forward.h>
|
|
#include <LibWebView/Forward.h>
|
|
#include <LibWebView/Options.h>
|
|
#include <LibWebView/UIProcessClientEndpoint.h>
|
|
#include <LibWebView/UIProcessServerEndpoint.h>
|
|
|
|
namespace WebView {
|
|
|
|
class WEBVIEW_API UIProcessConnectionFromClient final
|
|
: public IPC::ConnectionFromClient<UIProcessClientEndpoint, UIProcessServerEndpoint> {
|
|
C_OBJECT(UIProcessConnectionFromClient);
|
|
|
|
public:
|
|
virtual ~UIProcessConnectionFromClient() override = default;
|
|
|
|
virtual void die() override;
|
|
|
|
Function<void(Vector<URL::URL> const&)> on_new_tab;
|
|
Function<void(Vector<URL::URL> const&)> on_new_window;
|
|
|
|
private:
|
|
UIProcessConnectionFromClient(NonnullOwnPtr<IPC::Transport>, int client_id);
|
|
|
|
virtual void create_new_tab(Vector<ByteString> urls) override;
|
|
virtual void create_new_window(Vector<ByteString> urls) override;
|
|
};
|
|
|
|
class WEBVIEW_API BrowserProcess {
|
|
AK_MAKE_NONCOPYABLE(BrowserProcess);
|
|
AK_MAKE_DEFAULT_MOVABLE(BrowserProcess);
|
|
|
|
public:
|
|
enum class ProcessDisposition : u8 {
|
|
ContinueMainProcess,
|
|
ExitProcess,
|
|
};
|
|
|
|
BrowserProcess() = default;
|
|
~BrowserProcess();
|
|
|
|
ErrorOr<ProcessDisposition> connect(Vector<ByteString> const& raw_urls, NewWindow new_window);
|
|
|
|
Function<void(Vector<URL::URL> const&)> on_new_tab;
|
|
Function<void(Vector<URL::URL> const&)> on_new_window;
|
|
|
|
private:
|
|
void accept_transport(NonnullOwnPtr<IPC::Transport>);
|
|
#if defined(AK_OS_MACOS)
|
|
ErrorOr<void> connect_as_client(pid_t pid, Vector<ByteString> const& raw_urls, NewWindow new_window);
|
|
ErrorOr<void> connect_as_server();
|
|
#else
|
|
ErrorOr<void> connect_as_client(ByteString const& socket_path, Vector<ByteString> const& raw_urls, NewWindow new_window);
|
|
ErrorOr<void> connect_as_server(ByteString const& socket_path);
|
|
#endif
|
|
|
|
RefPtr<Core::LocalServer> m_local_server;
|
|
OwnPtr<Core::File> m_pid_file;
|
|
ByteString m_pid_path;
|
|
ByteString m_socket_path;
|
|
int m_next_client_id { 0 };
|
|
};
|
|
|
|
}
|