WebSocket: Avoid unnecessary IPC::Dictionary wrapper

We already have and use HashMap<DeprecatedString, DeprecatedString>
nearly everywhere, which is equivalent.
This commit is contained in:
Ben Wiederhake 2023-05-14 23:04:47 +02:00 committed by Andreas Kling
parent 9b9a38ec81
commit d030f0fe9b
Notes: sideshowbarker 2024-07-18 01:43:16 +09:00
4 changed files with 8 additions and 8 deletions

View file

@ -16,10 +16,10 @@ WebSocketClient::WebSocketClient(NonnullOwnPtr<Core::LocalSocket> socket)
RefPtr<WebSocket> WebSocketClient::connect(const URL& url, DeprecatedString const& origin, Vector<DeprecatedString> const& protocols, Vector<DeprecatedString> const& extensions, HashMap<DeprecatedString, DeprecatedString> const& request_headers)
{
IPC::Dictionary header_dictionary;
for (auto& it : request_headers)
header_dictionary.add(it.key, it.value);
auto connection_id = IPCProxy::connect(url, origin, protocols, extensions, header_dictionary);
auto headers_or_error = request_headers.clone();
if (headers_or_error.is_error())
return nullptr;
auto connection_id = IPCProxy::connect(url, origin, protocols, extensions, headers_or_error.release_value());
if (connection_id < 0)
return nullptr;
auto connection = WebSocket::create_from_id({}, *this, connection_id);

View file

@ -27,7 +27,7 @@ void ConnectionFromClient::die()
}
Messages::WebSocketServer::ConnectResponse ConnectionFromClient::connect(URL const& url, DeprecatedString const& origin,
Vector<DeprecatedString> const& protocols, Vector<DeprecatedString> const& extensions, IPC::Dictionary const& additional_request_headers)
Vector<DeprecatedString> const& protocols, Vector<DeprecatedString> const& extensions, HashMap<DeprecatedString, DeprecatedString> const& additional_request_headers)
{
if (!url.is_valid()) {
dbgln("WebSocket::Connect: Invalid URL requested: '{}'", url);
@ -40,7 +40,7 @@ Messages::WebSocketServer::ConnectResponse ConnectionFromClient::connect(URL con
connection_info.set_extensions(extensions);
Vector<ConnectionInfo::Header> headers;
for (auto const& header : additional_request_headers.entries()) {
for (auto const& header : additional_request_headers) {
headers.append({ header.key, header.value });
}
connection_info.set_headers(headers);

View file

@ -26,7 +26,7 @@ public:
private:
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::ConnectResponse connect(URL const&, DeprecatedString const&, Vector<DeprecatedString> const&, Vector<DeprecatedString> const&, HashMap<DeprecatedString, DeprecatedString> const&) override;
virtual Messages::WebSocketServer::ReadyStateResponse ready_state(i32) override;
virtual Messages::WebSocketServer::SubprotocolInUseResponse subprotocol_in_use(i32) override;
virtual void send(i32, bool, ByteBuffer const&) override;

View file

@ -3,7 +3,7 @@
endpoint WebSocketServer
{
// Connection API
connect(URL url, DeprecatedString origin, Vector<DeprecatedString> protocols, Vector<DeprecatedString> extensions, IPC::Dictionary additional_request_headers) => (i32 connection_id)
connect(URL url, DeprecatedString origin, Vector<DeprecatedString> protocols, Vector<DeprecatedString> extensions, HashMap<DeprecatedString,DeprecatedString> additional_request_headers) => (i32 connection_id)
ready_state(i32 connection_id) => (u32 ready_state)
subprotocol_in_use(i32 connection_id) => (DeprecatedString subprotocol_in_use)
send(i32 connection_id, bool is_text, ByteBuffer data) =|