NetworkPartitionKey.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Copyright (c) 2024, Andrew Kaster <akaster@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/Forward.h>
  8. #include <LibWeb/HTML/Origin.h>
  9. namespace Web::Fetch::Infrastructure {
  10. // https://fetch.spec.whatwg.org/#network-partition-key
  11. struct NetworkPartitionKey {
  12. HTML::Origin top_level_origin;
  13. // FIXME: See https://github.com/whatwg/fetch/issues/1035
  14. // This is the document origin in other browsers
  15. void* second_key = nullptr;
  16. bool operator==(NetworkPartitionKey const&) const = default;
  17. };
  18. NetworkPartitionKey determine_the_network_partition_key(HTML::Environment const& environment);
  19. Optional<NetworkPartitionKey> determine_the_network_partition_key(Infrastructure::Request const& request);
  20. }
  21. template<>
  22. class AK::Traits<Web::Fetch::Infrastructure::NetworkPartitionKey> : public DefaultTraits<Web::Fetch::Infrastructure::NetworkPartitionKey> {
  23. public:
  24. static unsigned hash(Web::Fetch::Infrastructure::NetworkPartitionKey const& partition_key)
  25. {
  26. return ::AK::Traits<Web::HTML::Origin>::hash(partition_key.top_level_origin);
  27. }
  28. };