diff options
author | Linus Groh <mail@linusgroh.de> | 2022-12-04 18:02:33 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-12-06 08:54:33 +0100 |
commit | 6e19ab2bbce0b113b628e6f8e9b5c0640053933e (patch) | |
tree | 372d21b2f5dcff112f5d0089559c6af5798680d4 /Userland/Libraries/LibProtocol | |
parent | f74251606d74b504a1379ebb893fdb5529054ea5 (diff) | |
download | serenity-6e19ab2bbce0b113b628e6f8e9b5c0640053933e.zip |
AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
Diffstat (limited to 'Userland/Libraries/LibProtocol')
-rw-r--r-- | Userland/Libraries/LibProtocol/Request.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibProtocol/Request.h | 14 | ||||
-rw-r--r-- | Userland/Libraries/LibProtocol/RequestClient.cpp | 10 | ||||
-rw-r--r-- | Userland/Libraries/LibProtocol/RequestClient.h | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibProtocol/WebSocket.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibProtocol/WebSocket.h | 12 | ||||
-rw-r--r-- | Userland/Libraries/LibProtocol/WebSocketClient.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibProtocol/WebSocketClient.h | 8 |
8 files changed, 32 insertions, 32 deletions
diff --git a/Userland/Libraries/LibProtocol/Request.cpp b/Userland/Libraries/LibProtocol/Request.cpp index 2a61eaa34f..30d235e0d5 100644 --- a/Userland/Libraries/LibProtocol/Request.cpp +++ b/Userland/Libraries/LibProtocol/Request.cpp @@ -128,7 +128,7 @@ void Request::did_progress(Badge<RequestClient>, Optional<u32> total_size, u32 d on_progress(total_size, downloaded_size); } -void Request::did_receive_headers(Badge<RequestClient>, HashMap<String, String, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> response_code) +void Request::did_receive_headers(Badge<RequestClient>, HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> response_code) { if (on_headers_received) on_headers_received(response_headers, response_code); diff --git a/Userland/Libraries/LibProtocol/Request.h b/Userland/Libraries/LibProtocol/Request.h index f004935175..f585e04d01 100644 --- a/Userland/Libraries/LibProtocol/Request.h +++ b/Userland/Libraries/LibProtocol/Request.h @@ -8,11 +8,11 @@ #include <AK/Badge.h> #include <AK/ByteBuffer.h> +#include <AK/DeprecatedString.h> #include <AK/FileStream.h> #include <AK/Function.h> #include <AK/MemoryStream.h> #include <AK/RefCounted.h> -#include <AK/String.h> #include <AK/WeakPtr.h> #include <LibCore/Notifier.h> #include <LibCore/Stream.h> @@ -25,8 +25,8 @@ class RequestClient; class Request : public RefCounted<Request> { public: struct CertificateAndKey { - String certificate; - String key; + DeprecatedString certificate; + DeprecatedString key; }; static NonnullRefPtr<Request> create_from_id(Badge<RequestClient>, RequestClient& client, i32 request_id) @@ -46,15 +46,15 @@ public: void set_should_buffer_all_input(bool); /// Note: Must be set before `set_should_buffer_all_input(true)`. - Function<void(bool success, u32 total_size, HashMap<String, String, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> response_code, ReadonlyBytes payload)> on_buffered_request_finish; + Function<void(bool success, u32 total_size, HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> response_code, ReadonlyBytes payload)> on_buffered_request_finish; Function<void(bool success, u32 total_size)> on_finish; Function<void(Optional<u32> total_size, u32 downloaded_size)> on_progress; - Function<void(HashMap<String, String, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> response_code)> on_headers_received; + Function<void(HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> response_code)> on_headers_received; Function<CertificateAndKey()> on_certificate_requested; void did_finish(Badge<RequestClient>, bool success, u32 total_size); void did_progress(Badge<RequestClient>, Optional<u32> total_size, u32 downloaded_size); - void did_receive_headers(Badge<RequestClient>, HashMap<String, String, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> response_code); + void did_receive_headers(Badge<RequestClient>, HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> response_code); void did_request_certificates(Badge<RequestClient>); RefPtr<Core::Notifier>& write_notifier(Badge<RequestClient>) { return m_write_notifier; } @@ -73,7 +73,7 @@ private: struct InternalBufferedData { DuplexMemoryStream payload_stream; - HashMap<String, String, CaseInsensitiveStringTraits> response_headers; + HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> response_headers; Optional<u32> response_code; }; diff --git a/Userland/Libraries/LibProtocol/RequestClient.cpp b/Userland/Libraries/LibProtocol/RequestClient.cpp index e9b22c4e8e..933f979302 100644 --- a/Userland/Libraries/LibProtocol/RequestClient.cpp +++ b/Userland/Libraries/LibProtocol/RequestClient.cpp @@ -21,7 +21,7 @@ void RequestClient::ensure_connection(URL const& url, ::RequestServer::CacheLeve } template<typename RequestHashMapTraits> -RefPtr<Request> RequestClient::start_request(String const& method, URL const& url, HashMap<String, String, RequestHashMapTraits> const& request_headers, ReadonlyBytes request_body, Core::ProxyData const& proxy_data) +RefPtr<Request> RequestClient::start_request(DeprecatedString const& method, URL const& url, HashMap<DeprecatedString, DeprecatedString, RequestHashMapTraits> const& request_headers, ReadonlyBytes request_body, Core::ProxyData const& proxy_data) { IPC::Dictionary header_dictionary; for (auto& it : request_headers) @@ -49,7 +49,7 @@ bool RequestClient::stop_request(Badge<Request>, Request& request) return IPCProxy::stop_request(request.id()); } -bool RequestClient::set_certificate(Badge<Request>, Request& request, String certificate, String key) +bool RequestClient::set_certificate(Badge<Request>, Request& request, DeprecatedString certificate, DeprecatedString key) { if (!m_requests.contains(request.id())) return false; @@ -75,7 +75,7 @@ void RequestClient::request_progress(i32 request_id, Optional<u32> const& total_ void RequestClient::headers_became_available(i32 request_id, IPC::Dictionary const& response_headers, Optional<u32> const& status_code) { if (auto request = const_cast<Request*>(m_requests.get(request_id).value_or(nullptr))) { - HashMap<String, String, CaseInsensitiveStringTraits> headers; + HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> headers; response_headers.for_each_entry([&](auto& name, auto& value) { headers.set(name, value); }); request->did_receive_headers({}, headers, status_code); } @@ -90,5 +90,5 @@ void RequestClient::certificate_requested(i32 request_id) } -template RefPtr<Protocol::Request> Protocol::RequestClient::start_request(String const& method, URL const&, HashMap<String, String> const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&); -template RefPtr<Protocol::Request> Protocol::RequestClient::start_request(String const& method, URL const&, HashMap<String, String, CaseInsensitiveStringTraits> const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&); +template RefPtr<Protocol::Request> Protocol::RequestClient::start_request(DeprecatedString const& method, URL const&, HashMap<DeprecatedString, DeprecatedString> const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&); +template RefPtr<Protocol::Request> Protocol::RequestClient::start_request(DeprecatedString const& method, URL const&, HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&); diff --git a/Userland/Libraries/LibProtocol/RequestClient.h b/Userland/Libraries/LibProtocol/RequestClient.h index 3ae788645f..73cbf91229 100644 --- a/Userland/Libraries/LibProtocol/RequestClient.h +++ b/Userland/Libraries/LibProtocol/RequestClient.h @@ -21,13 +21,13 @@ class RequestClient final IPC_CLIENT_CONNECTION(RequestClient, "/tmp/session/%sid/portal/request"sv) public: - template<typename RequestHashMapTraits = Traits<String>> - RefPtr<Request> start_request(String const& method, URL const&, HashMap<String, String, RequestHashMapTraits> const& request_headers = {}, ReadonlyBytes request_body = {}, Core::ProxyData const& = {}); + 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& = {}); void ensure_connection(URL const&, ::RequestServer::CacheLevel); bool stop_request(Badge<Request>, Request&); - bool set_certificate(Badge<Request>, Request&, String, String); + bool set_certificate(Badge<Request>, Request&, DeprecatedString, DeprecatedString); private: RequestClient(NonnullOwnPtr<Core::Stream::LocalSocket>); diff --git a/Userland/Libraries/LibProtocol/WebSocket.cpp b/Userland/Libraries/LibProtocol/WebSocket.cpp index 88f8d7bb41..fd85b64add 100644 --- a/Userland/Libraries/LibProtocol/WebSocket.cpp +++ b/Userland/Libraries/LibProtocol/WebSocket.cpp @@ -30,7 +30,7 @@ void WebSocket::send(StringView text_message) send(ByteBuffer::copy(text_message.bytes()).release_value_but_fixme_should_propagate_errors(), true); } -void WebSocket::close(u16 code, String reason) +void WebSocket::close(u16 code, DeprecatedString reason) { m_client->close({}, *this, code, move(reason)); } @@ -53,7 +53,7 @@ void WebSocket::did_error(Badge<WebSocketClient>, i32 error_code) on_error((WebSocket::Error)error_code); } -void WebSocket::did_close(Badge<WebSocketClient>, u16 code, String reason, bool was_clean) +void WebSocket::did_close(Badge<WebSocketClient>, u16 code, DeprecatedString reason, bool was_clean) { if (on_close) on_close(code, move(reason), was_clean); diff --git a/Userland/Libraries/LibProtocol/WebSocket.h b/Userland/Libraries/LibProtocol/WebSocket.h index c0f079f5c1..d323a9edcf 100644 --- a/Userland/Libraries/LibProtocol/WebSocket.h +++ b/Userland/Libraries/LibProtocol/WebSocket.h @@ -8,9 +8,9 @@ #include <AK/Badge.h> #include <AK/ByteBuffer.h> +#include <AK/DeprecatedString.h> #include <AK/Function.h> #include <AK/RefCounted.h> -#include <AK/String.h> #include <AK/WeakPtr.h> #include <LibCore/Notifier.h> #include <LibIPC/Forward.h> @@ -22,8 +22,8 @@ class WebSocketClient; class WebSocket : public RefCounted<WebSocket> { public: struct CertificateAndKey { - String certificate; - String key; + DeprecatedString certificate; + DeprecatedString key; }; struct Message { @@ -55,18 +55,18 @@ public: void send(ByteBuffer binary_or_text_message, bool is_text); void send(StringView text_message); - void close(u16 code = 1005, String reason = {}); + void close(u16 code = 1005, DeprecatedString reason = {}); Function<void()> on_open; Function<void(Message)> on_message; Function<void(Error)> on_error; - Function<void(u16 code, String reason, bool was_clean)> on_close; + Function<void(u16 code, DeprecatedString reason, bool was_clean)> on_close; Function<CertificateAndKey()> on_certificate_requested; void did_open(Badge<WebSocketClient>); void did_receive(Badge<WebSocketClient>, ByteBuffer, bool); void did_error(Badge<WebSocketClient>, i32); - void did_close(Badge<WebSocketClient>, u16, String, bool); + void did_close(Badge<WebSocketClient>, u16, DeprecatedString, bool); void did_request_certificates(Badge<WebSocketClient>); private: diff --git a/Userland/Libraries/LibProtocol/WebSocketClient.cpp b/Userland/Libraries/LibProtocol/WebSocketClient.cpp index 5c84919bfc..b96d04951b 100644 --- a/Userland/Libraries/LibProtocol/WebSocketClient.cpp +++ b/Userland/Libraries/LibProtocol/WebSocketClient.cpp @@ -14,7 +14,7 @@ WebSocketClient::WebSocketClient(NonnullOwnPtr<Core::Stream::LocalSocket> socket { } -RefPtr<WebSocket> WebSocketClient::connect(const URL& url, String const& origin, Vector<String> const& protocols, Vector<String> const& extensions, HashMap<String, String> const& request_headers) +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) @@ -41,14 +41,14 @@ void WebSocketClient::send(Badge<WebSocket>, WebSocket& connection, ByteBuffer d async_send(connection.id(), is_text, move(data)); } -void WebSocketClient::close(Badge<WebSocket>, WebSocket& connection, u16 code, String message) +void WebSocketClient::close(Badge<WebSocket>, WebSocket& connection, u16 code, DeprecatedString message) { if (!m_connections.contains(connection.id())) return; async_close(connection.id(), code, move(message)); } -bool WebSocketClient::set_certificate(Badge<WebSocket>, WebSocket& connection, String certificate, String key) +bool WebSocketClient::set_certificate(Badge<WebSocket>, WebSocket& connection, DeprecatedString certificate, DeprecatedString key) { if (!m_connections.contains(connection.id())) return false; @@ -76,7 +76,7 @@ void WebSocketClient::errored(i32 connection_id, i32 message) maybe_connection.value()->did_error({}, message); } -void WebSocketClient::closed(i32 connection_id, u16 code, String const& reason, bool clean) +void WebSocketClient::closed(i32 connection_id, u16 code, DeprecatedString const& reason, bool clean) { auto maybe_connection = m_connections.get(connection_id); if (maybe_connection.has_value()) diff --git a/Userland/Libraries/LibProtocol/WebSocketClient.h b/Userland/Libraries/LibProtocol/WebSocketClient.h index db67203aa9..60281c93c0 100644 --- a/Userland/Libraries/LibProtocol/WebSocketClient.h +++ b/Userland/Libraries/LibProtocol/WebSocketClient.h @@ -21,12 +21,12 @@ class WebSocketClient final IPC_CLIENT_CONNECTION(WebSocketClient, "/tmp/session/%sid/portal/websocket"sv) public: - RefPtr<WebSocket> connect(const URL&, String const& origin = {}, Vector<String> const& protocols = {}, Vector<String> const& extensions = {}, HashMap<String, String> const& request_headers = {}); + RefPtr<WebSocket> connect(const URL&, DeprecatedString const& origin = {}, Vector<DeprecatedString> const& protocols = {}, Vector<DeprecatedString> const& extensions = {}, HashMap<DeprecatedString, DeprecatedString> const& request_headers = {}); u32 ready_state(Badge<WebSocket>, WebSocket&); void send(Badge<WebSocket>, WebSocket&, ByteBuffer, bool is_text); - void close(Badge<WebSocket>, WebSocket&, u16 code, String reason); - bool set_certificate(Badge<WebSocket>, WebSocket&, String, String); + void close(Badge<WebSocket>, WebSocket&, u16 code, DeprecatedString reason); + bool set_certificate(Badge<WebSocket>, WebSocket&, DeprecatedString, DeprecatedString); private: WebSocketClient(NonnullOwnPtr<Core::Stream::LocalSocket>); @@ -34,7 +34,7 @@ private: virtual void connected(i32) override; virtual void received(i32, bool, ByteBuffer const&) override; virtual void errored(i32, i32) override; - virtual void closed(i32, u16, String const&, bool) override; + virtual void closed(i32, u16, DeprecatedString const&, bool) override; virtual void certificate_requested(i32) override; HashMap<i32, NonnullRefPtr<WebSocket>> m_connections; |