mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 09:47:35 +00:00
Userland: Make IPC results with one return value available directly
This changes client methods so that they return the IPC response's return value directly - instead of the response struct - for IPC methods which only have a single return value.
This commit is contained in:
parent
5bb79ea0a7
commit
eb21aa65d1
18 changed files with 58 additions and 111 deletions
|
@ -21,11 +21,6 @@ void RequestClient::handshake()
|
|||
greet();
|
||||
}
|
||||
|
||||
bool RequestClient::is_supported_protocol(const String& protocol)
|
||||
{
|
||||
return IPCProxy::is_supported_protocol(protocol).supported();
|
||||
}
|
||||
|
||||
template<typename RequestHashMapTraits>
|
||||
RefPtr<Request> RequestClient::start_request(const String& method, const String& url, const HashMap<String, String, RequestHashMapTraits>& request_headers, ReadonlyBytes request_body)
|
||||
{
|
||||
|
@ -49,14 +44,14 @@ bool RequestClient::stop_request(Badge<Request>, Request& request)
|
|||
{
|
||||
if (!m_requests.contains(request.id()))
|
||||
return false;
|
||||
return IPCProxy::stop_request(request.id()).success();
|
||||
return IPCProxy::stop_request(request.id());
|
||||
}
|
||||
|
||||
bool RequestClient::set_certificate(Badge<Request>, Request& request, String certificate, String key)
|
||||
{
|
||||
if (!m_requests.contains(request.id()))
|
||||
return false;
|
||||
return IPCProxy::set_certificate(request.id(), move(certificate), move(key)).success();
|
||||
return IPCProxy::set_certificate(request.id(), move(certificate), move(key));
|
||||
}
|
||||
|
||||
void RequestClient::request_finished(i32 request_id, bool success, u32 total_size)
|
||||
|
|
|
@ -23,7 +23,6 @@ class RequestClient
|
|||
public:
|
||||
virtual void handshake() override;
|
||||
|
||||
bool is_supported_protocol(const String&);
|
||||
template<typename RequestHashMapTraits = Traits<String>>
|
||||
RefPtr<Request> start_request(const String& method, const String& url, const HashMap<String, String, RequestHashMapTraits>& request_headers = {}, ReadonlyBytes request_body = {});
|
||||
|
||||
|
|
|
@ -25,8 +25,7 @@ RefPtr<WebSocket> WebSocketClient::connect(const URL& url, const String& origin,
|
|||
IPC::Dictionary header_dictionary;
|
||||
for (auto& it : request_headers)
|
||||
header_dictionary.add(it.key, it.value);
|
||||
auto response = IPCProxy::connect(url, origin, protocols, extensions, header_dictionary);
|
||||
auto connection_id = response.connection_id();
|
||||
auto connection_id = IPCProxy::connect(url, origin, protocols, extensions, header_dictionary);
|
||||
if (connection_id < 0)
|
||||
return nullptr;
|
||||
auto connection = WebSocket::create_from_id({}, *this, connection_id);
|
||||
|
@ -38,7 +37,7 @@ u32 WebSocketClient::ready_state(Badge<WebSocket>, WebSocket& connection)
|
|||
{
|
||||
if (!m_connections.contains(connection.id()))
|
||||
return (u32)WebSocket::ReadyState::Closed;
|
||||
return IPCProxy::ready_state(connection.id()).ready_state();
|
||||
return IPCProxy::ready_state(connection.id());
|
||||
}
|
||||
|
||||
void WebSocketClient::send(Badge<WebSocket>, WebSocket& connection, ByteBuffer data, bool is_text)
|
||||
|
@ -59,7 +58,7 @@ bool WebSocketClient::set_certificate(Badge<WebSocket>, WebSocket& connection, S
|
|||
{
|
||||
if (!m_connections.contains(connection.id()))
|
||||
return false;
|
||||
return IPCProxy::set_certificate(connection.id(), move(certificate), move(key)).success();
|
||||
return IPCProxy::set_certificate(connection.id(), move(certificate), move(key));
|
||||
}
|
||||
|
||||
void WebSocketClient::connected(i32 connection_id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue