summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Cookie
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2022-11-15 11:24:59 -0500
committerTim Flynn <trflynn89@pm.me>2022-11-15 13:25:51 -0500
commit05f41382bb527fbf2bb47340ad065b36f2e7409f (patch)
tree3da51238f398d92fc289351837cd26699bdad21f /Userland/Libraries/LibWeb/Cookie
parentb1ea418d14b4392741720914b834c61322cdb5b4 (diff)
downloadserenity-05f41382bb527fbf2bb47340ad065b36f2e7409f.zip
Userland: Properly define IPC::encode and IPC::decode specializations
In order to avoid the base encode/decode methods from being used (and failing a static assertion), we must be sure to declare/define the custom type implementations as template specializations. After this, LibIPC is no longer sensitive to include order.
Diffstat (limited to 'Userland/Libraries/LibWeb/Cookie')
-rw-r--r--Userland/Libraries/LibWeb/Cookie/Cookie.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Cookie/Cookie.h3
-rw-r--r--Userland/Libraries/LibWeb/Cookie/ParsedCookie.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Cookie/ParsedCookie.h3
4 files changed, 10 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/Cookie/Cookie.cpp b/Userland/Libraries/LibWeb/Cookie/Cookie.cpp
index d47d6d92bd..2a43385e64 100644
--- a/Userland/Libraries/LibWeb/Cookie/Cookie.cpp
+++ b/Userland/Libraries/LibWeb/Cookie/Cookie.cpp
@@ -38,6 +38,7 @@ SameSite same_site_from_string(StringView same_site_mode)
}
+template<>
bool IPC::encode(Encoder& encoder, Web::Cookie::Cookie const& cookie)
{
encoder << cookie.name;
@@ -56,6 +57,7 @@ bool IPC::encode(Encoder& encoder, Web::Cookie::Cookie const& cookie)
return true;
}
+template<>
ErrorOr<void> IPC::decode(Decoder& decoder, Web::Cookie::Cookie& cookie)
{
TRY(decoder.decode(cookie.name));
diff --git a/Userland/Libraries/LibWeb/Cookie/Cookie.h b/Userland/Libraries/LibWeb/Cookie/Cookie.h
index 2192cc5d69..8c94686494 100644
--- a/Userland/Libraries/LibWeb/Cookie/Cookie.h
+++ b/Userland/Libraries/LibWeb/Cookie/Cookie.h
@@ -46,7 +46,10 @@ SameSite same_site_from_string(StringView same_site_mode);
namespace IPC {
+template<>
bool encode(Encoder&, Web::Cookie::Cookie const&);
+
+template<>
ErrorOr<void> decode(Decoder&, Web::Cookie::Cookie&);
}
diff --git a/Userland/Libraries/LibWeb/Cookie/ParsedCookie.cpp b/Userland/Libraries/LibWeb/Cookie/ParsedCookie.cpp
index bcf44ee5e0..3dd0b2d0fd 100644
--- a/Userland/Libraries/LibWeb/Cookie/ParsedCookie.cpp
+++ b/Userland/Libraries/LibWeb/Cookie/ParsedCookie.cpp
@@ -347,6 +347,7 @@ Optional<Core::DateTime> parse_date_time(StringView date_string)
}
+template<>
bool IPC::encode(Encoder& encoder, Web::Cookie::ParsedCookie const& cookie)
{
encoder << cookie.name;
@@ -362,6 +363,7 @@ bool IPC::encode(Encoder& encoder, Web::Cookie::ParsedCookie const& cookie)
return true;
}
+template<>
ErrorOr<void> IPC::decode(Decoder& decoder, Web::Cookie::ParsedCookie& cookie)
{
TRY(decoder.decode(cookie.name));
diff --git a/Userland/Libraries/LibWeb/Cookie/ParsedCookie.h b/Userland/Libraries/LibWeb/Cookie/ParsedCookie.h
index 58df4efb73..1fc1651219 100644
--- a/Userland/Libraries/LibWeb/Cookie/ParsedCookie.h
+++ b/Userland/Libraries/LibWeb/Cookie/ParsedCookie.h
@@ -32,7 +32,10 @@ Optional<ParsedCookie> parse_cookie(String const& cookie_string);
namespace IPC {
+template<>
bool encode(Encoder&, Web::Cookie::ParsedCookie const&);
+
+template<>
ErrorOr<void> decode(Decoder&, Web::Cookie::ParsedCookie&);
}