Everywhere: Make TransportSocket non-movable

Instead of wrapping all non-movable members of TransportSocket in OwnPtr
to keep it movable, make TransportSocket itself non-movable and wrap it
in OwnPtr.
This commit is contained in:
Aliaksandr Kalenik 2025-04-08 22:01:46 +02:00 committed by Alexander Kalenik
commit db8c443392
Notes: github-actions[bot] 2025-04-09 13:28:53 +00:00
42 changed files with 97 additions and 100 deletions

View file

@ -22,7 +22,7 @@ class UIProcessClient final
C_OBJECT(UIProcessClient);
private:
explicit UIProcessClient(IPC::Transport);
explicit UIProcessClient(NonnullOwnPtr<IPC::Transport>);
};
ErrorOr<BrowserProcess::ProcessDisposition> BrowserProcess::connect(Vector<ByteString> const& raw_urls, NewWindow new_window)
@ -49,7 +49,7 @@ ErrorOr<void> BrowserProcess::connect_as_client(ByteString const& socket_path, V
{
// TODO: Mach IPC
auto socket = TRY(Core::LocalSocket::connect(socket_path));
auto client = UIProcessClient::construct(IPC::Transport(move(socket)));
auto client = UIProcessClient::construct(make<IPC::Transport>(move(socket)));
if (new_window == NewWindow::Yes) {
if (!client->send_sync_but_allow_failure<Messages::UIProcessServer::CreateNewWindow>(raw_urls))
@ -98,12 +98,12 @@ BrowserProcess::~BrowserProcess()
MUST(Core::System::unlink(m_socket_path));
}
UIProcessClient::UIProcessClient(IPC::Transport transport)
UIProcessClient::UIProcessClient(NonnullOwnPtr<IPC::Transport> transport)
: IPC::ConnectionToServer<UIProcessClientEndpoint, UIProcessServerEndpoint>(*this, move(transport))
{
}
UIProcessConnectionFromClient::UIProcessConnectionFromClient(IPC::Transport transport, int client_id)
UIProcessConnectionFromClient::UIProcessConnectionFromClient(NonnullOwnPtr<IPC::Transport> transport, int client_id)
: IPC::ConnectionFromClient<UIProcessClientEndpoint, UIProcessServerEndpoint>(*this, move(transport), client_id)
{
s_connections.set(client_id, *this);

View file

@ -32,7 +32,7 @@ public:
Function<void(Vector<URL::URL> const&)> on_new_window;
private:
UIProcessConnectionFromClient(IPC::Transport, int client_id);
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;

View file

@ -47,7 +47,7 @@ ErrorOr<Process::ProcessAndIPCTransport> Process::spawn_and_connect_to_process(C
guard_fd_0.disarm();
TRY(ipc_socket->set_blocking(true));
return ProcessAndIPCTransport { move(process), IPC::Transport(move(ipc_socket)) };
return ProcessAndIPCTransport { move(process), make<IPC::Transport>(move(ipc_socket)) };
}
#ifdef AK_OS_WINDOWS

View file

@ -54,7 +54,7 @@ public:
private:
struct ProcessAndIPCTransport {
Core::Process process;
IPC::Transport transport;
NonnullOwnPtr<IPC::Transport> transport;
};
static ErrorOr<ProcessAndIPCTransport> spawn_and_connect_to_process(Core::ProcessSpawnOptions const& options);

View file

@ -25,14 +25,14 @@ Optional<ViewImplementation&> WebContentClient::view_for_pid_and_page_id(pid_t p
return {};
}
WebContentClient::WebContentClient(IPC::Transport transport, ViewImplementation& view)
WebContentClient::WebContentClient(NonnullOwnPtr<IPC::Transport> transport, ViewImplementation& view)
: IPC::ConnectionToServer<WebContentClientEndpoint, WebContentServerEndpoint>(*this, move(transport))
{
s_clients.set(this);
m_views.set(0, &view);
}
WebContentClient::WebContentClient(IPC::Transport transport)
WebContentClient::WebContentClient(NonnullOwnPtr<IPC::Transport> transport)
: IPC::ConnectionToServer<WebContentClientEndpoint, WebContentServerEndpoint>(*this, move(transport))
{
s_clients.set(this);

View file

@ -39,8 +39,8 @@ public:
static size_t client_count() { return s_clients.size(); }
explicit WebContentClient(IPC::Transport);
WebContentClient(IPC::Transport, ViewImplementation&);
explicit WebContentClient(NonnullOwnPtr<IPC::Transport>);
WebContentClient(NonnullOwnPtr<IPC::Transport>, ViewImplementation&);
~WebContentClient();
void assign_view(Badge<Application>, ViewImplementation&);

View file

@ -27,7 +27,7 @@ static ErrorOr<NonnullRefPtr<WebUIType>> create_web_ui(WebContentClient& client,
return client_socket.release_error();
}
auto web_ui = WebUIType::create(client, IPC::Transport { client_socket.release_value() }, move(host));
auto web_ui = WebUIType::create(client, make<IPC::Transport>(client_socket.release_value()), move(host));
client.async_connect_to_web_ui(0, IPC::File::adopt_fd(socket_fds[1]));
return web_ui;
@ -48,7 +48,7 @@ ErrorOr<RefPtr<WebUI>> WebUI::create(WebContentClient& client, String host)
return web_ui;
}
WebUI::WebUI(WebContentClient& client, IPC::Transport transport, String host)
WebUI::WebUI(WebContentClient& client, NonnullOwnPtr<IPC::Transport> transport, String host)
: IPC::ConnectionToServer<WebUIClientEndpoint, WebUIServerEndpoint>(*this, move(transport))
, m_client(client)
, m_host(move(host))

View file

@ -30,7 +30,7 @@ public:
String const& host() const { return m_host; }
protected:
WebUI(WebContentClient&, IPC::Transport, String host);
WebUI(WebContentClient&, NonnullOwnPtr<IPC::Transport>, String host);
using Interface = Function<void(JsonValue)>;
@ -47,17 +47,17 @@ private:
HashMap<StringView, Interface> m_interfaces;
};
#define WEB_UI(WebUIType) \
public: \
static NonnullRefPtr<WebUIType> create(WebContentClient& client, IPC::Transport transport, String host) \
{ \
return adopt_ref(*new WebUIType(client, move(transport), move(host))); \
} \
\
private: \
WebUIType(WebContentClient& client, IPC::Transport transport, String host) \
: WebView::WebUI(client, move(transport), move(host)) \
{ \
#define WEB_UI(WebUIType) \
public: \
static NonnullRefPtr<WebUIType> create(WebContentClient& client, NonnullOwnPtr<IPC::Transport> transport, String host) \
{ \
return adopt_ref(*new WebUIType(client, move(transport), move(host))); \
} \
\
private: \
WebUIType(WebContentClient& client, NonnullOwnPtr<IPC::Transport> transport, String host) \
: WebView::WebUI(client, move(transport), move(host)) \
{ \
}
}