LibProtocol+LibWebView: Allow callers provide their own RequestClient

This will be used by Ladybird when it spawns its RequestServer in a
Lagom-specific way rather than using SystemServer to do it.
This commit is contained in:
Andrew Kaster 2023-08-01 14:41:13 -06:00 committed by Andreas Kling
parent 28d3d3c9fc
commit ec3267e002
3 changed files with 11 additions and 5 deletions

View file

@ -21,6 +21,8 @@ class RequestClient final
IPC_CLIENT_CONNECTION(RequestClient, "/tmp/session/%sid/portal/request"sv)
public:
explicit RequestClient(NonnullOwnPtr<Core::LocalSocket>);
template<typename RequestHashMapTraits = Traits<DeprecatedString>>
RefPtr<Request> start_request(DeprecatedString const& method, URL const&, HashMap<DeprecatedString, DeprecatedString, RequestHashMapTraits> const& request_headers = {}, ReadonlyBytes request_body = {}, Core::ProxyData const& = {});
@ -30,8 +32,6 @@ public:
bool set_certificate(Badge<Request>, Request&, DeprecatedString, DeprecatedString);
private:
RequestClient(NonnullOwnPtr<Core::LocalSocket>);
virtual void request_progress(i32, Optional<u64> const&, u64) override;
virtual void request_finished(i32, bool, u64) override;
virtual void certificate_requested(i32) override;

View file

@ -68,10 +68,15 @@ void RequestServerRequestAdapter::stream_into(Stream& stream)
m_request->stream_into(stream);
}
ErrorOr<NonnullRefPtr<RequestServerAdapter>> RequestServerAdapter::try_create(NonnullRefPtr<Protocol::RequestClient> protocol_client)
{
return try_make_ref_counted<RequestServerAdapter>(move(protocol_client));
}
ErrorOr<NonnullRefPtr<RequestServerAdapter>> RequestServerAdapter::try_create()
{
auto protocol_client = TRY(Protocol::RequestClient::try_create());
return adopt_nonnull_ref_or_enomem(new (nothrow) RequestServerAdapter(move(protocol_client)));
return try_make_ref_counted<RequestServerAdapter>(move(protocol_client));
}
RequestServerAdapter::RequestServerAdapter(NonnullRefPtr<Protocol::RequestClient> protocol_client)

View file

@ -36,6 +36,9 @@ private:
class RequestServerAdapter : public Web::ResourceLoaderConnector {
public:
explicit RequestServerAdapter(NonnullRefPtr<Protocol::RequestClient> protocol_client);
static ErrorOr<NonnullRefPtr<RequestServerAdapter>> try_create(NonnullRefPtr<Protocol::RequestClient>);
static ErrorOr<NonnullRefPtr<RequestServerAdapter>> try_create();
virtual ~RequestServerAdapter() override;
@ -45,8 +48,6 @@ public:
virtual RefPtr<Web::ResourceLoaderConnectorRequest> start_request(DeprecatedString const& method, URL const&, HashMap<DeprecatedString, DeprecatedString> const& request_headers = {}, ReadonlyBytes request_body = {}, Core::ProxyData const& = {}) override;
private:
RequestServerAdapter(NonnullRefPtr<Protocol::RequestClient> protocol_client);
RefPtr<Protocol::RequestClient> m_protocol_client;
};