diff options
author | Andreas Kling <kling@serenityos.org> | 2021-11-28 11:56:31 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-28 23:14:19 +0100 |
commit | cb9cac4e4002d6f2d5a16c7344dfb5393cec2b56 (patch) | |
tree | daa183f9f73c17d0e72e0d0bd7b89ecbf0f6fdbe /Userland/Libraries/LibWeb | |
parent | 8d76eb773f25b1e51ef923734cd355692f014ce5 (diff) | |
download | serenity-cb9cac4e4002d6f2d5a16c7344dfb5393cec2b56.zip |
LibIPC+IPCCompiler+AK: Make IPC value decoders return ErrorOr<void>
This allows us to use TRY() in decoding helpers, leading to a nice
reduction in line count.
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r-- | Userland/Libraries/LibWeb/Cookie/ParsedCookie.cpp | 29 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Cookie/ParsedCookie.h | 2 |
2 files changed, 11 insertions, 20 deletions
diff --git a/Userland/Libraries/LibWeb/Cookie/ParsedCookie.cpp b/Userland/Libraries/LibWeb/Cookie/ParsedCookie.cpp index 5f74d07d46..8ae52fd32d 100644 --- a/Userland/Libraries/LibWeb/Cookie/ParsedCookie.cpp +++ b/Userland/Libraries/LibWeb/Cookie/ParsedCookie.cpp @@ -348,24 +348,15 @@ bool IPC::encode(IPC::Encoder& encoder, const Web::Cookie::ParsedCookie& cookie) return true; } -bool IPC::decode(IPC::Decoder& decoder, Web::Cookie::ParsedCookie& cookie) +ErrorOr<void> IPC::decode(IPC::Decoder& decoder, Web::Cookie::ParsedCookie& cookie) { - if (!decoder.decode(cookie.name)) - return false; - if (!decoder.decode(cookie.value)) - return false; - if (!decoder.decode(cookie.expiry_time_from_expires_attribute)) - return false; - if (!decoder.decode(cookie.expiry_time_from_max_age_attribute)) - return false; - if (!decoder.decode(cookie.domain)) - return false; - if (!decoder.decode(cookie.path)) - return false; - if (!decoder.decode(cookie.secure_attribute_present)) - return false; - if (!decoder.decode(cookie.http_only_attribute_present)) - return false; - - return true; + TRY(decoder.decode(cookie.name)); + TRY(decoder.decode(cookie.value)); + TRY(decoder.decode(cookie.expiry_time_from_expires_attribute)); + TRY(decoder.decode(cookie.expiry_time_from_max_age_attribute)); + TRY(decoder.decode(cookie.domain)); + TRY(decoder.decode(cookie.path)); + TRY(decoder.decode(cookie.secure_attribute_present)); + TRY(decoder.decode(cookie.http_only_attribute_present)); + return {}; } diff --git a/Userland/Libraries/LibWeb/Cookie/ParsedCookie.h b/Userland/Libraries/LibWeb/Cookie/ParsedCookie.h index 3a71812b77..451ea29b02 100644 --- a/Userland/Libraries/LibWeb/Cookie/ParsedCookie.h +++ b/Userland/Libraries/LibWeb/Cookie/ParsedCookie.h @@ -31,6 +31,6 @@ Optional<ParsedCookie> parse_cookie(const String& cookie_string); namespace IPC { bool encode(IPC::Encoder&, const Web::Cookie::ParsedCookie&); -bool decode(IPC::Decoder&, Web::Cookie::ParsedCookie&); +ErrorOr<void> decode(IPC::Decoder&, Web::Cookie::ParsedCookie&); } |