LibWeb: Make StorageKey serializable over IPC

This commit is contained in:
Shannon Booth
2026-04-10 21:07:58 +02:00
committed by Shannon Booth
parent aca463883f
commit 98ca5e0635
Notes: github-actions[bot] 2026-04-14 16:44:37 +00:00
2 changed files with 30 additions and 0 deletions

View File

@@ -4,6 +4,8 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibIPC/Decoder.h>
#include <LibIPC/Encoder.h>
#include <LibWeb/DOMURL/DOMURL.h>
#include <LibWeb/HTML/Scripting/Environments.h>
#include <LibWeb/StorageAPI/StorageKey.h>
@@ -51,3 +53,21 @@ StorageKey obtain_a_storage_key_for_non_storage_purposes(HTML::Environment const
}
}
namespace IPC {
template<>
ErrorOr<void> encode(Encoder& encoder, Web::StorageAPI::StorageKey const& key)
{
TRY(encoder.encode(key.origin));
return {};
}
template<>
ErrorOr<Web::StorageAPI::StorageKey> decode(Decoder& decoder)
{
auto origin = TRY(decoder.decode<URL::Origin>());
return Web::StorageAPI::StorageKey { move(origin) };
}
}