mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 11:37:45 +00:00
LibCore: Move Stream-based sockets into the Core
namespace
This commit is contained in:
parent
d43a7eae54
commit
a96339b72b
123 changed files with 1157 additions and 1100 deletions
|
@ -22,7 +22,7 @@ void ConnectionFromClient::for_each(Function<void(ConnectionFromClient&)> callba
|
|||
callback(connection);
|
||||
}
|
||||
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> client_socket, int client_id, Mixer& mixer)
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket> client_socket, int client_id, Mixer& mixer)
|
||||
: IPC::ConnectionFromClient<AudioClientEndpoint, AudioServerEndpoint>(*this, move(client_socket), client_id)
|
||||
, m_mixer(mixer)
|
||||
{
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
static void for_each(Function<void(ConnectionFromClient&)>);
|
||||
|
||||
private:
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>, int client_id, Mixer& mixer);
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>, int client_id, Mixer& mixer);
|
||||
|
||||
virtual Messages::AudioServer::GetMainMixVolumeResponse get_main_mix_volume() override;
|
||||
virtual void set_main_mix_volume(double) override;
|
||||
|
|
|
@ -25,7 +25,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
|
|||
auto server = TRY(Core::LocalServer::try_create());
|
||||
TRY(server->take_over_from_system_server());
|
||||
|
||||
server->on_accept = [&](NonnullOwnPtr<Core::Stream::LocalSocket> client_socket) {
|
||||
server->on_accept = [&](NonnullOwnPtr<Core::LocalSocket> client_socket) {
|
||||
static int s_next_client_id = 0;
|
||||
int client_id = ++s_next_client_id;
|
||||
(void)IPC::new_client_connection<AudioServer::ConnectionFromClient>(move(client_socket), client_id, *mixer);
|
||||
|
|
|
@ -19,7 +19,7 @@ void ConnectionFromClient::for_each_client(Function<void(ConnectionFromClient&)>
|
|||
}
|
||||
}
|
||||
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> socket, int client_id)
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket> socket, int client_id)
|
||||
: IPC::ConnectionFromClient<ClipboardClientEndpoint, ClipboardServerEndpoint>(*this, move(socket), client_id)
|
||||
{
|
||||
s_connections.set(client_id, *this);
|
||||
|
|
|
@ -27,7 +27,7 @@ public:
|
|||
void notify_about_clipboard_change();
|
||||
|
||||
private:
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>, int client_id);
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>, int client_id);
|
||||
|
||||
virtual Messages::ClipboardServer::GetClipboardDataResponse get_clipboard_data() override;
|
||||
virtual void set_clipboard_data(Core::AnonymousBuffer const&, DeprecatedString const&, IPC::Dictionary const&) override;
|
||||
|
|
|
@ -74,7 +74,7 @@ static Core::ConfigFile& ensure_domain_config(DeprecatedString const& domain)
|
|||
return *config;
|
||||
}
|
||||
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> client_socket, int client_id)
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket> client_socket, int client_id)
|
||||
: IPC::ConnectionFromClient<ConfigClientEndpoint, ConfigServerEndpoint>(*this, move(client_socket), client_id)
|
||||
, m_sync_timer(Core::Timer::create_single_shot(s_disk_sync_delay_ms, [this]() { sync_dirty_domains_to_disk(); }).release_value_but_fixme_should_propagate_errors())
|
||||
{
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
bool is_monitoring_domain(DeprecatedString const& domain) const { return m_monitored_domains.contains(domain); }
|
||||
|
||||
private:
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>, int client_id);
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>, int client_id);
|
||||
|
||||
virtual void pledge_domains(Vector<DeprecatedString> const&) override;
|
||||
virtual void monitor_domain(DeprecatedString const&) override;
|
||||
|
|
|
@ -6,8 +6,9 @@
|
|||
|
||||
#include "Client.h"
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/Socket.h>
|
||||
|
||||
Client::Client(int id, NonnullOwnPtr<Core::Stream::TCPSocket> socket)
|
||||
Client::Client(int id, NonnullOwnPtr<Core::TCPSocket> socket)
|
||||
: m_id(id)
|
||||
, m_socket(move(socket))
|
||||
{
|
||||
|
|
|
@ -6,11 +6,12 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibCore/Socket.h>
|
||||
#include <LibCore/Stream.h>
|
||||
|
||||
class Client : public RefCounted<Client> {
|
||||
public:
|
||||
static NonnullRefPtr<Client> create(int id, NonnullOwnPtr<Core::Stream::TCPSocket> socket)
|
||||
static NonnullRefPtr<Client> create(int id, NonnullOwnPtr<Core::TCPSocket> socket)
|
||||
{
|
||||
return adopt_ref(*new Client(id, move(socket)));
|
||||
}
|
||||
|
@ -18,12 +19,12 @@ public:
|
|||
Function<void()> on_exit;
|
||||
|
||||
protected:
|
||||
Client(int id, NonnullOwnPtr<Core::Stream::TCPSocket> socket);
|
||||
Client(int id, NonnullOwnPtr<Core::TCPSocket> socket);
|
||||
|
||||
ErrorOr<void> drain_socket();
|
||||
void quit();
|
||||
|
||||
private:
|
||||
int m_id { 0 };
|
||||
NonnullOwnPtr<Core::Stream::TCPSocket> m_socket;
|
||||
NonnullOwnPtr<Core::TCPSocket> m_socket;
|
||||
};
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace FileSystemAccessServer {
|
|||
|
||||
static HashMap<int, NonnullRefPtr<ConnectionFromClient>> s_connections;
|
||||
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> socket)
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket> socket)
|
||||
: IPC::ConnectionFromClient<FileSystemAccessClientEndpoint, FileSystemAccessServerEndpoint>(*this, move(socket), 1)
|
||||
{
|
||||
s_connections.set(1, *this);
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
virtual void die() override;
|
||||
|
||||
private:
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>);
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>);
|
||||
|
||||
virtual void request_file_read_only_approved(i32, i32, i32, DeprecatedString const&) override;
|
||||
virtual void request_file(i32, i32, i32, DeprecatedString const&, Core::Stream::OpenMode) override;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
namespace ImageDecoder {
|
||||
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> socket)
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket> socket)
|
||||
: IPC::ConnectionFromClient<ImageDecoderClientEndpoint, ImageDecoderServerEndpoint>(*this, move(socket), 1)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
virtual void die() override;
|
||||
|
||||
private:
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>);
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>);
|
||||
|
||||
virtual Messages::ImageDecoderServer::DecodeImageResponse decode_image(Core::AnonymousBuffer const&, Optional<DeprecatedString> const& mime_type) override;
|
||||
};
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace InspectorServer {
|
|||
|
||||
static HashMap<int, RefPtr<ConnectionFromClient>> s_connections;
|
||||
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> socket, int client_id)
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket> socket, int client_id)
|
||||
: IPC::ConnectionFromClient<InspectorClientEndpoint, InspectorServerEndpoint>(*this, move(socket), client_id)
|
||||
{
|
||||
s_connections.set(client_id, *this);
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
virtual void die() override;
|
||||
|
||||
private:
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>, int client_id);
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>, int client_id);
|
||||
|
||||
virtual Messages::InspectorServer::GetAllObjectsResponse get_all_objects(pid_t) override;
|
||||
virtual Messages::InspectorServer::SetInspectedObjectResponse set_inspected_object(pid_t, u64 object_id) override;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "InspectableProcess.h"
|
||||
#include <AK/JsonObject.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/Socket.h>
|
||||
|
||||
namespace InspectorServer {
|
||||
|
||||
|
@ -17,7 +18,7 @@ InspectableProcess* InspectableProcess::from_pid(pid_t pid)
|
|||
return g_processes.get(pid).value_or(nullptr);
|
||||
}
|
||||
|
||||
InspectableProcess::InspectableProcess(pid_t pid, NonnullOwnPtr<Core::Stream::LocalSocket> socket)
|
||||
InspectableProcess::InspectableProcess(pid_t pid, NonnullOwnPtr<Core::LocalSocket> socket)
|
||||
: m_pid(pid)
|
||||
, m_socket(move(socket))
|
||||
{
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace InspectorServer {
|
|||
|
||||
class InspectableProcess {
|
||||
public:
|
||||
InspectableProcess(pid_t, NonnullOwnPtr<Core::Stream::LocalSocket>);
|
||||
InspectableProcess(pid_t, NonnullOwnPtr<Core::LocalSocket>);
|
||||
~InspectableProcess() = default;
|
||||
|
||||
void send_request(JsonObject const& request);
|
||||
|
@ -22,7 +22,7 @@ public:
|
|||
|
||||
private:
|
||||
pid_t m_pid { 0 };
|
||||
NonnullOwnPtr<Core::Stream::LocalSocket> m_socket;
|
||||
NonnullOwnPtr<Core::LocalSocket> m_socket;
|
||||
};
|
||||
|
||||
extern HashMap<pid_t, NonnullOwnPtr<InspectorServer::InspectableProcess>> g_processes;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
namespace LaunchServer {
|
||||
|
||||
static HashMap<int, RefPtr<ConnectionFromClient>> s_connections;
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> client_socket, int client_id)
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket> client_socket, int client_id)
|
||||
: IPC::ConnectionFromClient<LaunchClientEndpoint, LaunchServerEndpoint>(*this, move(client_socket), client_id)
|
||||
{
|
||||
s_connections.set(client_id, *this);
|
||||
|
|
|
@ -20,7 +20,7 @@ public:
|
|||
virtual void die() override;
|
||||
|
||||
private:
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>, int client_id);
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>, int client_id);
|
||||
|
||||
virtual Messages::LaunchServer::OpenUrlResponse open_url(URL const&, DeprecatedString const&) override;
|
||||
virtual Messages::LaunchServer::GetHandlersForUrlResponse get_handlers_for_url(URL const&) override;
|
||||
|
|
|
@ -15,7 +15,7 @@ using namespace DNS;
|
|||
|
||||
static HashMap<int, RefPtr<ConnectionFromClient>> s_connections;
|
||||
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> socket, int client_id)
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket> socket, int client_id)
|
||||
: IPC::ConnectionFromClient<LookupClientEndpoint, LookupServerEndpoint>(*this, move(socket), client_id)
|
||||
{
|
||||
s_connections.set(client_id, *this);
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
virtual void die() override;
|
||||
|
||||
private:
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>, int client_id);
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>, int client_id);
|
||||
|
||||
virtual Messages::LookupServer::LookupNameResponse lookup_name(DeprecatedString const&) override;
|
||||
virtual Messages::LookupServer::LookupAddressResponse lookup_address(DeprecatedString const&) override;
|
||||
|
|
|
@ -237,7 +237,7 @@ ErrorOr<Vector<Answer>> LookupServer::lookup(Name const& name, DeprecatedString
|
|||
|
||||
auto buffer = TRY(request.to_byte_buffer());
|
||||
|
||||
auto udp_socket = TRY(Core::Stream::UDPSocket::connect(nameserver, 53, Time::from_seconds(1)));
|
||||
auto udp_socket = TRY(Core::UDPSocket::connect(nameserver, 53, Time::from_seconds(1)));
|
||||
TRY(udp_socket->set_blocking(true));
|
||||
|
||||
TRY(udp_socket->write(buffer));
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace NotificationServer {
|
|||
|
||||
static HashMap<int, RefPtr<ConnectionFromClient>> s_connections;
|
||||
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> client_socket, int client_id)
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket> client_socket, int client_id)
|
||||
: IPC::ConnectionFromClient<NotificationClientEndpoint, NotificationServerEndpoint>(*this, move(client_socket), client_id)
|
||||
{
|
||||
s_connections.set(client_id, *this);
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
virtual void die() override;
|
||||
|
||||
private:
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>, int client_id);
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>, int client_id);
|
||||
|
||||
virtual void show_notification(DeprecatedString const&, DeprecatedString const&, Gfx::ShareableBitmap const&) override;
|
||||
virtual void close_notification() override;
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
|
||||
namespace RequestServer::ConnectionCache {
|
||||
|
||||
HashMap<ConnectionKey, NonnullOwnPtr<NonnullOwnPtrVector<Connection<Core::Stream::TCPSocket, Core::Stream::Socket>>>> g_tcp_connection_cache {};
|
||||
HashMap<ConnectionKey, NonnullOwnPtr<NonnullOwnPtrVector<Connection<Core::TCPSocket, Core::Socket>>>> g_tcp_connection_cache {};
|
||||
HashMap<ConnectionKey, NonnullOwnPtr<NonnullOwnPtrVector<Connection<TLS::TLSv12>>>> g_tls_connection_cache {};
|
||||
|
||||
void request_did_finish(URL const& url, Core::Stream::Socket const* socket)
|
||||
void request_did_finish(URL const& url, Core::Socket const* socket)
|
||||
{
|
||||
if (!socket) {
|
||||
dbgln("Request with a null socket finished for URL {}", url);
|
||||
|
@ -71,9 +71,9 @@ void request_did_finish(URL const& url, Core::Stream::Socket const* socket)
|
|||
}
|
||||
};
|
||||
|
||||
if (is<Core::Stream::BufferedSocket<TLS::TLSv12>>(socket))
|
||||
if (is<Core::BufferedSocket<TLS::TLSv12>>(socket))
|
||||
fire_off_next_job(g_tls_connection_cache);
|
||||
else if (is<Core::Stream::BufferedSocket<Core::Stream::Socket>>(socket))
|
||||
else if (is<Core::BufferedSocket<Core::Socket>>(socket))
|
||||
fire_off_next_job(g_tcp_connection_cache);
|
||||
else
|
||||
dbgln("Unknown socket {} finished for URL {}", socket, url);
|
||||
|
|
|
@ -44,7 +44,7 @@ struct Proxy {
|
|||
if constexpr (requires { SocketType::connect(declval<DeprecatedString>(), *proxy_client_storage, forward<Args>(args)...); }) {
|
||||
proxy_client_storage = TRY(Core::SOCKSProxyClient::connect(data.host_ipv4, data.port, Core::SOCKSProxyClient::Version::V5, url.host(), url.port_or_default()));
|
||||
return TRY(SocketType::connect(url.host(), *proxy_client_storage, forward<Args>(args)...));
|
||||
} else if constexpr (IsSame<SocketType, Core::Stream::TCPSocket>) {
|
||||
} else if constexpr (IsSame<SocketType, Core::TCPSocket>) {
|
||||
return TRY(Core::SOCKSProxyClient::connect(data.host_ipv4, data.port, Core::SOCKSProxyClient::Version::V5, url.host(), url.port_or_default()));
|
||||
} else {
|
||||
return Error::from_string_literal("SOCKS5 not supported for this socket type");
|
||||
|
@ -57,7 +57,7 @@ struct Proxy {
|
|||
template<typename Socket, typename SocketStorageType = Socket>
|
||||
struct Connection {
|
||||
struct JobData {
|
||||
Function<void(Core::Stream::Socket&)> start {};
|
||||
Function<void(Core::Socket&)> start {};
|
||||
Function<void(Core::NetworkJob::Error)> fail {};
|
||||
Function<Vector<TLS::Certificate>()> provide_client_certificates {};
|
||||
|
||||
|
@ -91,7 +91,7 @@ struct Connection {
|
|||
using SocketType = Socket;
|
||||
using StorageType = SocketStorageType;
|
||||
|
||||
NonnullOwnPtr<Core::Stream::BufferedSocket<SocketStorageType>> socket;
|
||||
NonnullOwnPtr<Core::BufferedSocket<SocketStorageType>> socket;
|
||||
QueueType request_queue;
|
||||
NonnullRefPtr<Core::Timer> removal_timer;
|
||||
bool has_started { false };
|
||||
|
@ -121,10 +121,10 @@ struct AK::Traits<RequestServer::ConnectionCache::ConnectionKey> : public AK::Ge
|
|||
|
||||
namespace RequestServer::ConnectionCache {
|
||||
|
||||
extern HashMap<ConnectionKey, NonnullOwnPtr<NonnullOwnPtrVector<Connection<Core::Stream::TCPSocket, Core::Stream::Socket>>>> g_tcp_connection_cache;
|
||||
extern HashMap<ConnectionKey, NonnullOwnPtr<NonnullOwnPtrVector<Connection<Core::TCPSocket, Core::Socket>>>> g_tcp_connection_cache;
|
||||
extern HashMap<ConnectionKey, NonnullOwnPtr<NonnullOwnPtrVector<Connection<TLS::TLSv12>>>> g_tls_connection_cache;
|
||||
|
||||
void request_did_finish(URL const&, Core::Stream::Socket const*);
|
||||
void request_did_finish(URL const&, Core::Socket const*);
|
||||
void dump_jobs();
|
||||
|
||||
constexpr static size_t MaxConcurrentConnectionsPerURL = 4;
|
||||
|
@ -139,7 +139,7 @@ ErrorOr<void> recreate_socket_if_needed(T& connection, URL const& url)
|
|||
if (!connection.socket->is_open() || connection.socket->is_eof()) {
|
||||
// Create another socket for the connection.
|
||||
auto set_socket = [&](auto socket) -> ErrorOr<void> {
|
||||
connection.socket = TRY(Core::Stream::BufferedSocket<SocketStorageType>::create(move(socket)));
|
||||
connection.socket = TRY(Core::BufferedSocket<SocketStorageType>::create(move(socket)));
|
||||
return {};
|
||||
};
|
||||
|
||||
|
@ -192,7 +192,7 @@ decltype(auto) get_or_create_connection(auto& cache, URL const& url, auto& job,
|
|||
});
|
||||
return ReturnType { nullptr };
|
||||
}
|
||||
auto socket_result = Core::Stream::BufferedSocket<typename ConnectionType::StorageType>::create(connection_result.release_value());
|
||||
auto socket_result = Core::BufferedSocket<typename ConnectionType::StorageType>::create(connection_result.release_value());
|
||||
if (socket_result.is_error()) {
|
||||
dbgln("ConnectionCache: Failed to make a buffered socket for {}: {}", url, socket_result.error());
|
||||
Core::deferred_invoke([&job] {
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace RequestServer {
|
|||
|
||||
static HashMap<int, RefPtr<ConnectionFromClient>> s_connections;
|
||||
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> socket)
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket> socket)
|
||||
: IPC::ConnectionFromClient<RequestClientEndpoint, RequestServerEndpoint>(*this, move(socket), 1)
|
||||
{
|
||||
s_connections.set(1, *this);
|
||||
|
@ -123,7 +123,7 @@ struct Job {
|
|||
return *s_jobs.find(url)->value;
|
||||
}
|
||||
|
||||
void start(Core::Stream::Socket& socket)
|
||||
void start(Core::Socket& socket)
|
||||
{
|
||||
auto is_connected = socket.is_open();
|
||||
VERIFY(is_connected);
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
void did_request_certificates(Badge<Request>, Request&);
|
||||
|
||||
private:
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>);
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>);
|
||||
|
||||
virtual Messages::RequestServer::IsSupportedProtocolResponse is_supported_protocol(DeprecatedString const&) override;
|
||||
virtual Messages::RequestServer::StartRequestResponse start_request(DeprecatedString const&, URL const&, IPC::Dictionary const&, ByteBuffer const&, Core::ProxyData const&) override;
|
||||
|
|
|
@ -28,7 +28,7 @@ void ConnectionFromClient::set_database_path(DeprecatedString database_path)
|
|||
m_database_path = move(database_path);
|
||||
}
|
||||
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> socket, int client_id)
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket> socket, int client_id)
|
||||
: IPC::ConnectionFromClient<SQLClientEndpoint, SQLServerEndpoint>(*this, move(socket), client_id)
|
||||
, m_database_path(DeprecatedString::formatted("{}/sql", Core::StandardPaths::data_directory()))
|
||||
{
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
Function<void()> on_disconnect;
|
||||
|
||||
private:
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>, int client_id);
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>, int client_id);
|
||||
|
||||
virtual Messages::SQLServer::ConnectResponse connect(DeprecatedString const&) override;
|
||||
virtual Messages::SQLServer::PrepareStatementResponse prepare_statement(SQL::ConnectionID, DeprecatedString const&) override;
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
void set_bitmap(Gfx::Bitmap const& bitmap);
|
||||
|
||||
private:
|
||||
ConnectionToClipboardServer(NonnullOwnPtr<Core::Stream::LocalSocket> socket)
|
||||
ConnectionToClipboardServer(NonnullOwnPtr<Core::LocalSocket> socket)
|
||||
: IPC::ConnectionToServer<ClipboardClientEndpoint, ClipboardServerEndpoint>(*this, move(socket))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -14,10 +14,11 @@
|
|||
#include <AK/Types.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/Notifier.h>
|
||||
#include <LibCore/Socket.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
Client::Client(int id, NonnullOwnPtr<Core::Stream::TCPSocket> socket, int ptm_fd)
|
||||
Client::Client(int id, NonnullOwnPtr<Core::TCPSocket> socket, int ptm_fd)
|
||||
: m_id(id)
|
||||
, m_socket(move(socket))
|
||||
, m_ptm_fd(ptm_fd)
|
||||
|
@ -51,7 +52,7 @@ Client::Client(int id, NonnullOwnPtr<Core::Stream::TCPSocket> socket, int ptm_fd
|
|||
m_parser.on_error = [this]() { handle_error(); };
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Client>> Client::create(int id, NonnullOwnPtr<Core::Stream::TCPSocket> socket, int ptm_fd)
|
||||
ErrorOr<NonnullRefPtr<Client>> Client::create(int id, NonnullOwnPtr<Core::TCPSocket> socket, int ptm_fd)
|
||||
{
|
||||
auto client = adopt_ref(*new Client(id, move(socket), ptm_fd));
|
||||
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
|
||||
class Client : public RefCounted<Client> {
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<Client>> create(int id, NonnullOwnPtr<Core::Stream::TCPSocket> socket, int ptm_fd);
|
||||
static ErrorOr<NonnullRefPtr<Client>> create(int id, NonnullOwnPtr<Core::TCPSocket> socket, int ptm_fd);
|
||||
|
||||
Function<void()> on_exit;
|
||||
|
||||
private:
|
||||
Client(int id, NonnullOwnPtr<Core::Stream::TCPSocket> socket, int ptm_fd);
|
||||
Client(int id, NonnullOwnPtr<Core::TCPSocket> socket, int ptm_fd);
|
||||
|
||||
ErrorOr<void> drain_socket();
|
||||
ErrorOr<void> drain_pty();
|
||||
|
@ -38,7 +38,7 @@ private:
|
|||
// client id
|
||||
int m_id { 0 };
|
||||
// client resources
|
||||
NonnullOwnPtr<Core::Stream::TCPSocket> m_socket;
|
||||
NonnullOwnPtr<Core::TCPSocket> m_socket;
|
||||
Parser m_parser;
|
||||
// pty resources
|
||||
int m_ptm_fd { -1 };
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/DeprecatedFile.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/Socket.h>
|
||||
#include <LibCore/TCPServer.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <fcntl.h>
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
namespace WebContent {
|
||||
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> socket)
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket> socket)
|
||||
: IPC::ConnectionFromClient<WebContentClientEndpoint, WebContentServerEndpoint>(*this, move(socket), 1)
|
||||
, m_page_host(PageHost::create(*this))
|
||||
{
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
PageHost const& page_host() const { return *m_page_host; }
|
||||
|
||||
private:
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>);
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>);
|
||||
|
||||
Web::Page& page();
|
||||
Web::Page const& page() const;
|
||||
|
|
|
@ -321,13 +321,13 @@ static bool fire_an_event(DeprecatedString name, Optional<Web::DOM::Element&> ta
|
|||
ErrorOr<NonnullRefPtr<WebDriverConnection>> WebDriverConnection::connect(Web::PageClient& page_client, DeprecatedString const& webdriver_ipc_path)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Trying to connect to {}", webdriver_ipc_path);
|
||||
auto socket = TRY(Core::Stream::LocalSocket::connect(webdriver_ipc_path));
|
||||
auto socket = TRY(Core::LocalSocket::connect(webdriver_ipc_path));
|
||||
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Connected to WebDriver");
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) WebDriverConnection(move(socket), page_client));
|
||||
}
|
||||
|
||||
WebDriverConnection::WebDriverConnection(NonnullOwnPtr<Core::Stream::LocalSocket> socket, Web::PageClient& page_client)
|
||||
WebDriverConnection::WebDriverConnection(NonnullOwnPtr<Core::LocalSocket> socket, Web::PageClient& page_client)
|
||||
: IPC::ConnectionToServer<WebDriverClientEndpoint, WebDriverServerEndpoint>(*this, move(socket))
|
||||
, m_page_client(page_client)
|
||||
, m_current_window_handle("main"sv)
|
||||
|
|
|
@ -33,7 +33,7 @@ public:
|
|||
virtual ~WebDriverConnection() = default;
|
||||
|
||||
private:
|
||||
WebDriverConnection(NonnullOwnPtr<Core::Stream::LocalSocket> socket, Web::PageClient& page_client);
|
||||
WebDriverConnection(NonnullOwnPtr<Core::LocalSocket> socket, Web::PageClient& page_client);
|
||||
|
||||
virtual void die() override { }
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace WebDriver {
|
|||
Atomic<unsigned> Client::s_next_session_id;
|
||||
NonnullOwnPtrVector<Session> Client::s_sessions;
|
||||
|
||||
ErrorOr<NonnullRefPtr<Client>> Client::try_create(NonnullOwnPtr<Core::Stream::BufferedTCPSocket> socket, LaunchBrowserCallbacks callbacks, Core::Object* parent)
|
||||
ErrorOr<NonnullRefPtr<Client>> Client::try_create(NonnullOwnPtr<Core::BufferedTCPSocket> socket, LaunchBrowserCallbacks callbacks, Core::Object* parent)
|
||||
{
|
||||
if (!callbacks.launch_browser || !callbacks.launch_headless_browser)
|
||||
return Error::from_string_view("All callbacks to launch a browser must be provided"sv);
|
||||
|
@ -29,7 +29,7 @@ ErrorOr<NonnullRefPtr<Client>> Client::try_create(NonnullOwnPtr<Core::Stream::Bu
|
|||
return adopt_nonnull_ref_or_enomem(new (nothrow) Client(move(socket), move(callbacks), parent));
|
||||
}
|
||||
|
||||
Client::Client(NonnullOwnPtr<Core::Stream::BufferedTCPSocket> socket, LaunchBrowserCallbacks callbacks, Core::Object* parent)
|
||||
Client::Client(NonnullOwnPtr<Core::BufferedTCPSocket> socket, LaunchBrowserCallbacks callbacks, Core::Object* parent)
|
||||
: Web::WebDriver::Client(move(socket), parent)
|
||||
, m_callbacks(move(callbacks))
|
||||
{
|
||||
|
|
|
@ -28,13 +28,13 @@ class Client final : public Web::WebDriver::Client {
|
|||
C_OBJECT_ABSTRACT(Client);
|
||||
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<Client>> try_create(NonnullOwnPtr<Core::Stream::BufferedTCPSocket>, LaunchBrowserCallbacks, Core::Object* parent);
|
||||
static ErrorOr<NonnullRefPtr<Client>> try_create(NonnullOwnPtr<Core::BufferedTCPSocket>, LaunchBrowserCallbacks, Core::Object* parent);
|
||||
virtual ~Client() override;
|
||||
|
||||
void close_session(unsigned session_id);
|
||||
|
||||
private:
|
||||
Client(NonnullOwnPtr<Core::Stream::BufferedTCPSocket>, LaunchBrowserCallbacks, Core::Object* parent);
|
||||
Client(NonnullOwnPtr<Core::BufferedTCPSocket>, LaunchBrowserCallbacks, Core::Object* parent);
|
||||
|
||||
ErrorOr<Session*, Web::WebDriver::Error> find_session_with_id(StringView session_id);
|
||||
ErrorOr<NonnullOwnPtr<Session>, Web::WebDriver::Error> take_session_with_id(StringView session_id);
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
namespace WebDriver {
|
||||
|
||||
WebContentConnection::WebContentConnection(NonnullOwnPtr<Core::Stream::LocalSocket> socket, NonnullRefPtr<Client> client, unsigned session_id)
|
||||
WebContentConnection::WebContentConnection(NonnullOwnPtr<Core::LocalSocket> socket, NonnullRefPtr<Client> client, unsigned session_id)
|
||||
: IPC::ConnectionFromClient<WebDriverClientEndpoint, WebDriverServerEndpoint>(*this, move(socket), 1)
|
||||
, m_client(move(client))
|
||||
, m_session_id(session_id)
|
||||
|
|
|
@ -19,7 +19,7 @@ class WebContentConnection
|
|||
: public IPC::ConnectionFromClient<WebDriverClientEndpoint, WebDriverServerEndpoint> {
|
||||
C_OBJECT_ABSTRACT(WebContentConnection)
|
||||
public:
|
||||
WebContentConnection(NonnullOwnPtr<Core::Stream::LocalSocket> socket, NonnullRefPtr<Client> client, unsigned session_id);
|
||||
WebContentConnection(NonnullOwnPtr<Core::LocalSocket> socket, NonnullRefPtr<Client> client, unsigned session_id);
|
||||
|
||||
virtual void die() override;
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
return;
|
||||
}
|
||||
|
||||
auto maybe_buffered_socket = Core::Stream::BufferedTCPSocket::create(maybe_client_socket.release_value());
|
||||
auto maybe_buffered_socket = Core::BufferedTCPSocket::create(maybe_client_socket.release_value());
|
||||
if (maybe_buffered_socket.is_error()) {
|
||||
warnln("Could not obtain a buffered socket for the client: {}", maybe_buffered_socket.error());
|
||||
return;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
namespace WebServer {
|
||||
|
||||
Client::Client(NonnullOwnPtr<Core::Stream::BufferedTCPSocket> socket, Core::Object* parent)
|
||||
Client::Client(NonnullOwnPtr<Core::BufferedTCPSocket> socket, Core::Object* parent)
|
||||
: Core::Object(parent)
|
||||
, m_socket(move(socket))
|
||||
{
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <AK/String.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/Socket.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibHTTP/Forward.h>
|
||||
#include <LibHTTP/HttpRequest.h>
|
||||
|
@ -22,7 +23,7 @@ public:
|
|||
void start();
|
||||
|
||||
private:
|
||||
Client(NonnullOwnPtr<Core::Stream::BufferedTCPSocket>, Core::Object* parent);
|
||||
Client(NonnullOwnPtr<Core::BufferedTCPSocket>, Core::Object* parent);
|
||||
|
||||
struct ContentInfo {
|
||||
String type;
|
||||
|
@ -38,7 +39,7 @@ private:
|
|||
ErrorOr<void> handle_directory_listing(String const& requested_path, String const& real_path, HTTP::HttpRequest const&);
|
||||
bool verify_credentials(Vector<HTTP::HttpRequest::Header> const&);
|
||||
|
||||
NonnullOwnPtr<Core::Stream::BufferedTCPSocket> m_socket;
|
||||
NonnullOwnPtr<Core::BufferedTCPSocket> m_socket;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
return;
|
||||
}
|
||||
|
||||
auto maybe_buffered_socket = Core::Stream::BufferedTCPSocket::create(maybe_client_socket.release_value());
|
||||
auto maybe_buffered_socket = Core::BufferedTCPSocket::create(maybe_client_socket.release_value());
|
||||
if (maybe_buffered_socket.is_error()) {
|
||||
warnln("Could not obtain a buffered socket for the client: {}", maybe_buffered_socket.error());
|
||||
return;
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace WebSocket {
|
|||
|
||||
static HashMap<int, RefPtr<ConnectionFromClient>> s_connections;
|
||||
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> socket)
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket> socket)
|
||||
: IPC::ConnectionFromClient<WebSocketClientEndpoint, WebSocketServerEndpoint>(*this, move(socket), 1)
|
||||
{
|
||||
s_connections.set(1, *this);
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
virtual void die() override;
|
||||
|
||||
private:
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>);
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>);
|
||||
|
||||
virtual Messages::WebSocketServer::ConnectResponse connect(URL const&, DeprecatedString const&, Vector<DeprecatedString> const&, Vector<DeprecatedString> const&, IPC::Dictionary const&) override;
|
||||
virtual Messages::WebSocketServer::ReadyStateResponse ready_state(i32) override;
|
||||
|
|
|
@ -45,7 +45,7 @@ ConnectionFromClient* ConnectionFromClient::from_client_id(int client_id)
|
|||
return (*it).value.ptr();
|
||||
}
|
||||
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> client_socket, int client_id)
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket> client_socket, int client_id)
|
||||
: IPC::ConnectionFromClient<WindowClientEndpoint, WindowServerEndpoint>(*this, move(client_socket), client_id)
|
||||
{
|
||||
if (!s_connections)
|
||||
|
|
|
@ -83,7 +83,7 @@ public:
|
|||
void notify_about_theme_change();
|
||||
|
||||
private:
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>, int client_id);
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>, int client_id);
|
||||
|
||||
// ^ConnectionFromClient
|
||||
virtual void die() override;
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace WindowServer {
|
|||
|
||||
HashMap<int, NonnullRefPtr<WMConnectionFromClient>> WMConnectionFromClient::s_connections {};
|
||||
|
||||
WMConnectionFromClient::WMConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> client_socket, int client_id)
|
||||
WMConnectionFromClient::WMConnectionFromClient(NonnullOwnPtr<Core::LocalSocket> client_socket, int client_id)
|
||||
: IPC::ConnectionFromClient<WindowManagerClientEndpoint, WindowManagerServerEndpoint>(*this, move(client_socket), client_id)
|
||||
{
|
||||
s_connections.set(client_id, *this);
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
int window_id() const { return m_window_id; }
|
||||
|
||||
private:
|
||||
explicit WMConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> client_socket, int client_id);
|
||||
explicit WMConnectionFromClient(NonnullOwnPtr<Core::LocalSocket> client_socket, int client_id);
|
||||
|
||||
// ^ConnectionFromClient
|
||||
virtual void die() override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue