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
parent 14bac7b287
commit 2295f34135
42 changed files with 97 additions and 100 deletions

View file

@ -16,14 +16,14 @@
namespace IPC {
ConnectionBase::ConnectionBase(IPC::Stub& local_stub, Transport transport, u32 local_endpoint_magic)
ConnectionBase::ConnectionBase(IPC::Stub& local_stub, NonnullOwnPtr<Transport> transport, u32 local_endpoint_magic)
: m_local_stub(local_stub)
, m_transport(move(transport))
, m_local_endpoint_magic(local_endpoint_magic)
{
m_responsiveness_timer = Core::Timer::create_single_shot(3000, [this] { may_have_become_unresponsive(); });
m_transport.set_up_read_hook([this] {
m_transport->set_up_read_hook([this] {
NonnullRefPtr protect = *this;
// FIXME: Do something about errors.
(void)drain_messages_from_peer();
@ -35,7 +35,7 @@ ConnectionBase::~ConnectionBase() = default;
bool ConnectionBase::is_open() const
{
return m_transport.is_open();
return m_transport->is_open();
}
ErrorOr<void> ConnectionBase::post_message(Message const& message)
@ -47,7 +47,7 @@ ErrorOr<void> ConnectionBase::post_message(u32 endpoint_magic, MessageBuffer buf
{
// NOTE: If this connection is being shut down, but has not yet been destroyed,
// the socket will be closed. Don't try to send more messages.
if (!m_transport.is_open())
if (!m_transport->is_open())
return Error::from_string_literal("Trying to post_message during IPC shutdown");
if (buffer.data().size() > TransportSocket::SOCKET_BUFFER_SIZE) {
@ -55,7 +55,7 @@ ErrorOr<void> ConnectionBase::post_message(u32 endpoint_magic, MessageBuffer buf
buffer = MUST(wrapper->encode());
}
MUST(buffer.transfer_message(m_transport));
MUST(buffer.transfer_message(*m_transport));
m_responsiveness_timer->start();
return {};
@ -63,7 +63,7 @@ ErrorOr<void> ConnectionBase::post_message(u32 endpoint_magic, MessageBuffer buf
void ConnectionBase::shutdown()
{
m_transport.close();
m_transport->close();
die();
}
@ -95,12 +95,12 @@ void ConnectionBase::handle_messages()
void ConnectionBase::wait_for_transport_to_become_readable()
{
m_transport.wait_until_readable();
m_transport->wait_until_readable();
}
ErrorOr<void> ConnectionBase::drain_messages_from_peer()
{
auto schedule_shutdown = m_transport.read_as_many_messages_as_possible_without_blocking([&](auto&& unparsed_message) {
auto schedule_shutdown = m_transport->read_as_many_messages_as_possible_without_blocking([&](auto&& unparsed_message) {
auto const& bytes = unparsed_message.bytes;
UnprocessedFileDescriptors unprocessed_fds;
unprocessed_fds.return_fds_to_front_of_queue(move(unparsed_message.fds));

View file

@ -35,10 +35,10 @@ public:
void shutdown();
virtual void die() { }
Transport& transport() { return m_transport; }
Transport& transport() const { return *m_transport; }
protected:
explicit ConnectionBase(IPC::Stub&, Transport, u32 local_endpoint_magic);
explicit ConnectionBase(IPC::Stub&, NonnullOwnPtr<Transport>, u32 local_endpoint_magic);
virtual void may_have_become_unresponsive() { }
virtual void did_become_responsive() { }
@ -53,7 +53,7 @@ protected:
IPC::Stub& m_local_stub;
Transport m_transport;
NonnullOwnPtr<Transport> m_transport;
RefPtr<Core::Timer> m_responsiveness_timer;
@ -65,7 +65,7 @@ protected:
template<typename LocalEndpoint, typename PeerEndpoint>
class Connection : public ConnectionBase {
public:
Connection(IPC::Stub& local_stub, Transport transport)
Connection(IPC::Stub& local_stub, NonnullOwnPtr<Transport> transport)
: ConnectionBase(local_stub, move(transport), LocalEndpoint::static_magic())
{
}

View file

@ -26,7 +26,7 @@ public:
using ServerStub = typename ServerEndpoint::Stub;
using IPCProxy = typename ClientEndpoint::template Proxy<ServerEndpoint>;
ConnectionFromClient(ServerStub& stub, Transport transport, int client_id)
ConnectionFromClient(ServerStub& stub, NonnullOwnPtr<Transport> transport, int client_id)
: IPC::Connection<ServerEndpoint, ClientEndpoint>(stub, move(transport))
, ClientEndpoint::template Proxy<ServerEndpoint>(*this, {})
, m_client_id(client_id)

View file

@ -18,7 +18,7 @@ public:
using ClientStub = typename ClientEndpoint::Stub;
using IPCProxy = typename ServerEndpoint::template Proxy<ClientEndpoint>;
ConnectionToServer(ClientStub& local_endpoint, Transport transport)
ConnectionToServer(ClientStub& local_endpoint, NonnullOwnPtr<Transport> transport)
: Connection<ClientEndpoint, ServerEndpoint>(local_endpoint, move(transport))
, ServerEndpoint::template Proxy<ClientEndpoint>(*this, {})
{

View file

@ -30,7 +30,7 @@ private:
m_server->on_accept = [&](auto client_socket) {
auto client_id = ++m_next_client_id;
auto client = IPC::new_client_connection<ConnectionFromClientType>(IPC::Transport(move(client_socket)), client_id);
auto client = IPC::new_client_connection<ConnectionFromClientType>(make<IPC::Transport>(move(client_socket)), client_id);
if (on_new_client)
on_new_client(*client);
};

View file

@ -16,7 +16,7 @@ template<typename ConnectionFromClientType>
ErrorOr<NonnullRefPtr<ConnectionFromClientType>> take_over_accepted_client_from_system_server()
{
auto socket = TRY(Core::take_over_socket_from_system_server());
return IPC::new_client_connection<ConnectionFromClientType>(IPC::Transport(move(socket)));
return IPC::new_client_connection<ConnectionFromClientType>(make<IPC::Transport>(move(socket)));
}
}

View file

@ -15,10 +15,9 @@ namespace IPC {
TransportSocket::TransportSocket(NonnullOwnPtr<Core::LocalSocket> socket)
: m_socket(move(socket))
, m_fds_retained_until_received_by_peer(make<Queue<NonnullRefPtr<AutoCloseFileDescriptor>>>())
{
m_send_queue = adopt_ref(*new SendQueue);
m_send_thread = Threading::Thread::construct([&socket = *m_socket, send_queue = m_send_queue]() -> intptr_t {
m_send_thread = Threading::Thread::construct([this, send_queue = m_send_queue]() -> intptr_t {
for (;;) {
send_queue->mutex.lock();
while (send_queue->messages.is_empty() && send_queue->running)
@ -32,7 +31,7 @@ TransportSocket::TransportSocket(NonnullOwnPtr<Core::LocalSocket> socket)
auto [bytes, fds] = send_queue->messages.take_first();
send_queue->mutex.unlock();
if (auto result = send_message(socket, bytes, fds); result.is_error()) {
if (auto result = send_message(*m_socket, bytes, fds); result.is_error()) {
dbgln("TransportSocket::send_thread: {}", result.error());
}
}
@ -46,14 +45,12 @@ TransportSocket::TransportSocket(NonnullOwnPtr<Core::LocalSocket> socket)
TransportSocket::~TransportSocket()
{
if (m_send_thread) {
{
Threading::MutexLocker locker(m_send_queue->mutex);
m_send_queue->running = false;
m_send_queue->condition.signal();
}
(void)m_send_thread->join();
{
Threading::MutexLocker locker(m_send_queue->mutex);
m_send_queue->running = false;
m_send_queue->condition.signal();
}
(void)m_send_thread->join();
}
void TransportSocket::set_up_read_hook(Function<void()> hook)
@ -94,7 +91,7 @@ struct MessageHeader {
u32 fd_count { 0 };
};
void TransportSocket::post_message(Vector<u8> const& bytes_to_write, Vector<NonnullRefPtr<AutoCloseFileDescriptor>> const& fds) const
void TransportSocket::post_message(Vector<u8> const& bytes_to_write, Vector<NonnullRefPtr<AutoCloseFileDescriptor>> const& fds)
{
Vector<u8> message_buffer;
message_buffer.resize(sizeof(MessageHeader) + bytes_to_write.size());
@ -106,7 +103,7 @@ void TransportSocket::post_message(Vector<u8> const& bytes_to_write, Vector<Nonn
memcpy(message_buffer.data() + sizeof(MessageHeader), bytes_to_write.data(), bytes_to_write.size());
for (auto const& fd : fds)
m_fds_retained_until_received_by_peer->enqueue(fd);
m_fds_retained_until_received_by_peer.enqueue(fd);
auto raw_fds = Vector<int, 1> {};
auto num_fds_to_transfer = fds.size();
@ -242,7 +239,7 @@ TransportSocket::ShouldShutdown TransportSocket::read_as_many_messages_as_possib
if (acknowledged_fd_count > 0) {
while (acknowledged_fd_count > 0) {
(void)m_fds_retained_until_received_by_peer->dequeue();
(void)m_fds_retained_until_received_by_peer.dequeue();
--acknowledged_fd_count;
}
}

View file

@ -44,7 +44,7 @@ private:
class TransportSocket {
AK_MAKE_NONCOPYABLE(TransportSocket);
AK_MAKE_DEFAULT_MOVABLE(TransportSocket);
AK_MAKE_NONMOVABLE(TransportSocket);
public:
static constexpr socklen_t SOCKET_BUFFER_SIZE = 128 * KiB;
@ -58,7 +58,7 @@ public:
void wait_until_readable();
void post_message(Vector<u8> const&, Vector<NonnullRefPtr<AutoCloseFileDescriptor>> const&) const;
void post_message(Vector<u8> const&, Vector<NonnullRefPtr<AutoCloseFileDescriptor>> const&);
enum class ShouldShutdown {
No,
@ -85,7 +85,7 @@ private:
// After file descriptor is sent, it is moved to the wait queue until an acknowledgement is received from the peer.
// This is necessary to handle a specific behavior of the macOS kernel, which may prematurely garbage-collect the file
// descriptor contained in the message before the peer receives it. https://openradar.me/9477351
NonnullOwnPtr<Queue<NonnullRefPtr<AutoCloseFileDescriptor>>> m_fds_retained_until_received_by_peer;
Queue<NonnullRefPtr<AutoCloseFileDescriptor>> m_fds_retained_until_received_by_peer;
struct MessageToSend {
Vector<u8> bytes;

View file

@ -9,7 +9,7 @@
namespace ImageDecoderClient {
Client::Client(IPC::Transport transport)
Client::Client(NonnullOwnPtr<IPC::Transport> transport)
: IPC::ConnectionToServer<ImageDecoderClientEndpoint, ImageDecoderServerEndpoint>(*this, move(transport))
{
}

View file

@ -36,7 +36,7 @@ class Client final
public:
using InitTransport = Messages::ImageDecoderServer::InitTransport;
Client(IPC::Transport);
Client(NonnullOwnPtr<IPC::Transport>);
NonnullRefPtr<Core::Promise<DecodedImage>> decode_image(ReadonlyBytes, Function<ErrorOr<void>(DecodedImage&)> on_resolved, Function<void(Error&)> on_rejected, Optional<Gfx::IntSize> ideal_size = {}, Optional<ByteString> mime_type = {});

View file

@ -10,7 +10,7 @@
namespace Requests {
RequestClient::RequestClient(IPC::Transport transport)
RequestClient::RequestClient(NonnullOwnPtr<IPC::Transport> transport)
: IPC::ConnectionToServer<RequestClientEndpoint, RequestServerEndpoint>(*this, move(transport))
{
}

View file

@ -27,7 +27,7 @@ class RequestClient final
public:
using InitTransport = Messages::RequestServer::InitTransport;
explicit RequestClient(IPC::Transport);
explicit RequestClient(NonnullOwnPtr<IPC::Transport>);
virtual ~RequestClient() override;
RefPtr<Request> start_request(ByteString const& method, URL::URL const&, HTTP::HeaderMap const& request_headers = {}, ReadonlyBytes request_body = {}, Core::ProxyData const& = {});

View file

@ -78,7 +78,7 @@ void MessagePort::visit_edges(Cell::Visitor& visitor)
bool MessagePort::is_entangled() const
{
return m_transport.has_value();
return m_transport;
}
void MessagePort::set_worker_event_target(GC::Ref<DOM::EventTarget> target)
@ -103,7 +103,7 @@ WebIDL::ExceptionOr<void> MessagePort::transfer_steps(HTML::TransferDataHolder&
// 2. Set dataHolder.[[RemotePort]] to remotePort.
// TODO: Mach IPC
auto fd = MUST(m_transport->release_underlying_transport_for_transfer());
m_transport = {};
m_transport.clear();
data_holder.fds.append(IPC::File::adopt_fd(fd));
data_holder.data.append(IPC_FILE_TAG);
}
@ -131,7 +131,7 @@ WebIDL::ExceptionOr<void> MessagePort::transfer_receiving_steps(HTML::TransferDa
if (fd_tag == IPC_FILE_TAG) {
// TODO: Mach IPC
auto fd = data_holder.fds.take_first();
m_transport = IPC::Transport(MUST(Core::LocalSocket::adopt_fd(fd.take_fd())));
m_transport = make<IPC::Transport>(MUST(Core::LocalSocket::adopt_fd(fd.take_fd())));
m_transport->set_up_read_hook([strong_this = GC::make_root(this)]() {
strong_this->read_from_transport();
@ -150,7 +150,7 @@ void MessagePort::disentangle()
m_remote_port->m_remote_port = nullptr;
m_remote_port = nullptr;
m_transport = {};
m_transport.clear();
m_worker_event_target = nullptr;
}
@ -187,8 +187,8 @@ void MessagePort::entangle_with(MessagePort& remote_port)
};
auto sockets = create_paired_sockets();
m_transport = IPC::Transport(move(sockets[0]));
m_remote_port->m_transport = IPC::Transport(move(sockets[1]));
m_transport = make<IPC::Transport>(move(sockets[0]));
m_remote_port->m_transport = make<IPC::Transport>(move(sockets[1]));
m_transport->set_up_read_hook([strong_this = GC::make_root(this)]() {
strong_this->read_from_transport();
@ -256,7 +256,7 @@ WebIDL::ExceptionOr<void> MessagePort::message_port_post_message_steps(GC::Ptr<M
// 6. If targetPort is null, or if doomed is true, then return.
// IMPLEMENTATION DEFINED: Actually check the socket here, not the target port.
// If there's no target message port in the same realm, we still want to send the message over IPC
if (!m_transport.has_value() || doomed) {
if (!m_transport || doomed) {
return {};
}
@ -278,7 +278,7 @@ ErrorOr<void> MessagePort::send_message_on_transport(SerializedTransferRecord co
void MessagePort::post_port_message(SerializedTransferRecord serialize_with_transfer_result)
{
if (!m_transport.has_value() || !m_transport->is_open())
if (!m_transport || !m_transport->is_open())
return;
if (auto result = send_message_on_transport(serialize_with_transfer_result); result.is_error()) {
dbgln("Failed to post message: {}", result.error());
@ -369,7 +369,7 @@ void MessagePort::start()
if (!is_entangled())
return;
VERIFY(m_transport.has_value());
VERIFY(m_transport);
// TODO: The start() method steps are to enable this's port message queue, if it is not already enabled.
}

View file

@ -86,7 +86,7 @@ private:
// https://html.spec.whatwg.org/multipage/web-messaging.html#has-been-shipped
bool m_has_been_shipped { false };
Optional<IPC::Transport> m_transport;
OwnPtr<IPC::Transport> m_transport;
GC::Ptr<DOM::EventTarget> m_worker_event_target;
};

View file

@ -40,7 +40,7 @@ void WorkerAgent::initialize(JS::Realm& realm)
MUST(worker_socket->set_blocking(true));
// TODO: Mach IPC
auto transport = IPC::Transport(move(worker_socket));
auto transport = make<IPC::Transport>(move(worker_socket));
m_worker_ipc = make_ref_counted<WebWorkerClient>(move(transport));

View file

@ -20,14 +20,14 @@ void WebWorkerClient::did_close_worker()
on_worker_close();
}
WebWorkerClient::WebWorkerClient(IPC::Transport transport)
WebWorkerClient::WebWorkerClient(NonnullOwnPtr<IPC::Transport> transport)
: IPC::ConnectionToServer<WebWorkerClientEndpoint, WebWorkerServerEndpoint>(*this, move(transport))
{
}
IPC::File WebWorkerClient::clone_transport()
{
return MUST(m_transport.clone_for_transfer());
return MUST(m_transport->clone_for_transfer());
}
}

View file

@ -18,7 +18,7 @@ class WebWorkerClient final
C_OBJECT_ABSTRACT(WebWorkerClient);
public:
explicit WebWorkerClient(IPC::Transport);
explicit WebWorkerClient(NonnullOwnPtr<IPC::Transport>);
virtual void did_close_worker() override;

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)) \
{ \
}
}

View file

@ -17,7 +17,7 @@ namespace ImageDecoder {
static HashMap<int, RefPtr<ConnectionFromClient>> s_connections;
static IDAllocator s_client_ids;
ConnectionFromClient::ConnectionFromClient(IPC::Transport transport)
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<IPC::Transport> transport)
: IPC::ConnectionFromClient<ImageDecoderClientEndpoint, ImageDecoderServerEndpoint>(*this, move(transport), s_client_ids.allocate())
{
s_connections.set(client_id(), *this);
@ -64,7 +64,7 @@ ErrorOr<IPC::File> ConnectionFromClient::connect_new_client()
auto client_socket = client_socket_or_error.release_value();
// Note: A ref is stored in the static s_connections map
auto client = adopt_ref(*new ConnectionFromClient(IPC::Transport(move(client_socket))));
auto client = adopt_ref(*new ConnectionFromClient(make<IPC::Transport>(move(client_socket))));
return IPC::File::adopt_fd(socket_fds[1]);
}

View file

@ -38,7 +38,7 @@ public:
private:
using Job = Threading::BackgroundAction<DecodeResult>;
explicit ConnectionFromClient(IPC::Transport);
explicit ConnectionFromClient(NonnullOwnPtr<IPC::Transport>);
virtual Messages::ImageDecoderServer::DecodeImageResponse decode_image(Core::AnonymousBuffer, Optional<Gfx::IntSize> ideal_size, Optional<ByteString> mime_type) override;
virtual void cancel_decoding(i64 image_id) override;

View file

@ -264,7 +264,7 @@ int ConnectionFromClient::on_timeout_callback(void*, long timeout_ms, void* user
return 0;
}
ConnectionFromClient::ConnectionFromClient(IPC::Transport transport)
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<IPC::Transport> transport)
: IPC::ConnectionFromClient<RequestClientEndpoint, RequestServerEndpoint>(*this, move(transport), s_client_ids.allocate())
, m_resolver(default_resolver())
{
@ -335,7 +335,7 @@ Messages::RequestServer::ConnectNewClientResponse ConnectionFromClient::connect_
}
auto client_socket = client_socket_or_error.release_value();
// Note: A ref is stored in the static s_connections map
auto client = adopt_ref(*new ConnectionFromClient(IPC::Transport(move(client_socket))));
auto client = adopt_ref(*new ConnectionFromClient(make<IPC::Transport>(move(client_socket))));
return IPC::File::adopt_fd(socket_fds[1]);
}

View file

@ -35,7 +35,7 @@ public:
virtual void die() override;
private:
explicit ConnectionFromClient(IPC::Transport);
explicit ConnectionFromClient(NonnullOwnPtr<IPC::Transport>);
virtual Messages::RequestServer::InitTransportResponse init_transport(int peer_pid) override;
virtual Messages::RequestServer::ConnectNewClientResponse connect_new_client() override;

View file

@ -56,7 +56,7 @@
namespace WebContent {
ConnectionFromClient::ConnectionFromClient(IPC::Transport transport)
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<IPC::Transport> transport)
: IPC::ConnectionFromClient<WebContentClientEndpoint, WebContentServerEndpoint>(*this, move(transport), 1)
, m_page_host(PageHost::create(*this))
{

View file

@ -51,7 +51,7 @@ public:
Queue<Web::QueuedInputEvent>& input_event_queue() { return m_input_event_queue; }
private:
explicit ConnectionFromClient(IPC::Transport);
explicit ConnectionFromClient(NonnullOwnPtr<IPC::Transport>);
Optional<PageClient&> page(u64 index, SourceLocation = SourceLocation::current());
Optional<PageClient const&> page(u64 index, SourceLocation = SourceLocation::current()) const;

View file

@ -197,10 +197,10 @@ ErrorOr<NonnullRefPtr<WebDriverConnection>> WebDriverConnection::connect(Web::Pa
page_client.page().set_should_block_pop_ups(false);
dbgln_if(WEBDRIVER_DEBUG, "Connected to WebDriver");
return adopt_nonnull_ref_or_enomem(new (nothrow) WebDriverConnection(IPC::Transport(move(socket)), page_client));
return adopt_nonnull_ref_or_enomem(new (nothrow) WebDriverConnection(make<IPC::Transport>(move(socket)), page_client));
}
WebDriverConnection::WebDriverConnection(IPC::Transport transport, Web::PageClient& page_client)
WebDriverConnection::WebDriverConnection(NonnullOwnPtr<IPC::Transport> transport, Web::PageClient& page_client)
: IPC::ConnectionToServer<WebDriverClientEndpoint, WebDriverServerEndpoint>(*this, move(transport))
{
set_current_top_level_browsing_context(page_client.page().top_level_browsing_context());

View file

@ -42,7 +42,7 @@ public:
void page_did_open_dialog(Badge<PageClient>);
private:
WebDriverConnection(IPC::Transport transport, Web::PageClient& page_client);
WebDriverConnection(NonnullOwnPtr<IPC::Transport> transport, Web::PageClient& page_client);
virtual void die() override { }

View file

@ -26,10 +26,10 @@ ErrorOr<NonnullRefPtr<WebUIConnection>> WebUIConnection::connect(IPC::File web_u
auto socket = TRY(Core::LocalSocket::adopt_fd(web_ui_socket.take_fd()));
TRY(socket->set_blocking(true));
return adopt_ref(*new WebUIConnection(IPC::Transport { move(socket) }, document));
return adopt_ref(*new WebUIConnection(make<IPC::Transport>(move(socket)), document));
}
WebUIConnection::WebUIConnection(IPC::Transport transport, Web::DOM::Document& document)
WebUIConnection::WebUIConnection(NonnullOwnPtr<IPC::Transport> transport, Web::DOM::Document& document)
: IPC::ConnectionFromClient<WebUIClientEndpoint, WebUIServerEndpoint>(*this, move(transport), 1)
, m_document(document)
{

View file

@ -28,7 +28,7 @@ public:
void received_message_from_web_ui(String const& name, JS::Value data);
private:
WebUIConnection(IPC::Transport, Web::DOM::Document&);
WebUIConnection(NonnullOwnPtr<IPC::Transport>, Web::DOM::Document&);
virtual void die() override { }
virtual void send_message(String name, JsonValue data) override;

View file

@ -213,7 +213,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
static_assert(IsSame<IPC::Transport, IPC::TransportSocket>, "Need to handle other IPC transports here");
auto webcontent_socket = TRY(Core::take_over_socket_from_system_server("WebContent"sv));
auto webcontent_client = TRY(WebContent::ConnectionFromClient::try_create(IPC::Transport(move(webcontent_socket))));
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);
@ -255,7 +255,7 @@ ErrorOr<void> initialize_resource_loader(GC::Heap& heap, int request_server_sock
auto socket = TRY(Core::LocalSocket::adopt_fd(request_server_socket));
TRY(socket->set_blocking(true));
auto request_client = TRY(try_make_ref_counted<Requests::RequestClient>(IPC::Transport(move(socket))));
auto request_client = TRY(try_make_ref_counted<Requests::RequestClient>(make<IPC::Transport>(move(socket))));
#ifdef AK_OS_WINDOWS
auto response = request_client->send_sync<Messages::RequestServer::InitTransport>(Core::System::getpid());
request_client->transport().set_peer_pid(response->peer_pid());
@ -271,7 +271,7 @@ ErrorOr<void> initialize_image_decoder(int image_decoder_socket)
auto socket = TRY(Core::LocalSocket::adopt_fd(image_decoder_socket));
TRY(socket->set_blocking(true));
auto new_client = TRY(try_make_ref_counted<ImageDecoderClient::Client>(IPC::Transport(move(socket))));
auto new_client = TRY(try_make_ref_counted<ImageDecoderClient::Client>(make<IPC::Transport>(move(socket))));
#ifdef AK_OS_WINDOWS
auto response = new_client->send_sync<Messages::ImageDecoderServer::InitTransport>(Core::System::getpid());
new_client->transport().set_peer_pid(response->peer_pid());
@ -289,7 +289,7 @@ ErrorOr<void> reinitialize_image_decoder(IPC::File const& image_decoder_socket)
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>(IPC::Transport(move(socket))));
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));

View file

@ -206,7 +206,7 @@ ErrorOr<NonnullRefPtr<Core::LocalServer>> Session::create_server(NonnullRefPtr<S
server->listen(*m_web_content_socket_path);
server->on_accept = [this, promise](auto client_socket) {
auto maybe_connection = adopt_nonnull_ref_or_enomem(new (nothrow) WebContentConnection(IPC::Transport(move(client_socket))));
auto maybe_connection = adopt_nonnull_ref_or_enomem(new (nothrow) WebContentConnection(make<IPC::Transport>(move(client_socket))));
if (maybe_connection.is_error()) {
promise->resolve(maybe_connection.release_error());
return;

View file

@ -9,7 +9,7 @@
namespace WebDriver {
WebContentConnection::WebContentConnection(IPC::Transport transport)
WebContentConnection::WebContentConnection(NonnullOwnPtr<IPC::Transport> transport)
: IPC::ConnectionFromClient<WebDriverClientEndpoint, WebDriverServerEndpoint>(*this, move(transport), 1)
{
}

View file

@ -19,7 +19,7 @@ class WebContentConnection
: public IPC::ConnectionFromClient<WebDriverClientEndpoint, WebDriverServerEndpoint> {
C_OBJECT_ABSTRACT(WebContentConnection)
public:
explicit WebContentConnection(IPC::Transport transport);
explicit WebContentConnection(NonnullOwnPtr<IPC::Transport> transport);
Function<void()> on_close;
Function<void(Web::WebDriver::Response)> on_driver_execution_complete;

View file

@ -45,7 +45,7 @@ void ConnectionFromClient::request_file(Web::FileRequest request)
handle_file_return(0, IPC::File::adopt_file(file.release_value()), request_id);
}
ConnectionFromClient::ConnectionFromClient(IPC::Transport transport)
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<IPC::Transport> transport)
: IPC::ConnectionFromClient<WebWorkerClientEndpoint, WebWorkerServerEndpoint>(*this, move(transport), 1)
, m_page_host(PageHost::create(Web::Bindings::main_thread_vm(), *this))
{

View file

@ -36,7 +36,7 @@ public:
PageHost const& page_host() const { return *m_page_host; }
private:
explicit ConnectionFromClient(IPC::Transport);
explicit ConnectionFromClient(NonnullOwnPtr<IPC::Transport>);
Web::Page& page();
Web::Page const& page() const;

View file

@ -83,7 +83,7 @@ static ErrorOr<void> initialize_image_decoder(int image_decoder_socket)
auto socket = TRY(Core::LocalSocket::adopt_fd(image_decoder_socket));
TRY(socket->set_blocking(true));
auto new_client = TRY(try_make_ref_counted<ImageDecoderClient::Client>(IPC::Transport(move(socket))));
auto new_client = TRY(try_make_ref_counted<ImageDecoderClient::Client>(make<IPC::Transport>(move(socket))));
#ifdef AK_OS_WINDOWS
auto response = new_client->send_sync<Messages::ImageDecoderServer::InitTransport>(Core::System::getpid());
new_client->transport().set_peer_pid(response->peer_pid());
@ -101,7 +101,7 @@ static ErrorOr<void> initialize_resource_loader(GC::Heap& heap, int request_serv
auto socket = TRY(Core::LocalSocket::adopt_fd(request_server_socket));
TRY(socket->set_blocking(true));
auto request_client = TRY(try_make_ref_counted<Requests::RequestClient>(IPC::Transport(move(socket))));
auto request_client = TRY(try_make_ref_counted<Requests::RequestClient>(make<IPC::Transport>(move(socket))));
#ifdef AK_OS_WINDOWS
auto response = request_client->send_sync<Messages::RequestServer::InitTransport>(Core::System::getpid());
request_client->transport().set_peer_pid(response->peer_pid());