From d1c1218d42f88f1efebb9b48dc227581d7d7bd0b Mon Sep 17 00:00:00 2001 From: networkException Date: Sun, 29 Oct 2023 02:49:22 +0100 Subject: [PATCH] LibWeb/Fetch: Implement changes to priority This patch updates the priority member of fetch requests to be an enum. The implementation defined struct previously named Priority has been renamed to InternalPriority in line with the spec. --- .../Fetch/Infrastructure/HTTP/Requests.h | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h index 65f36c2265..1f04a5f490 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2022-2023, Linus Groh + * Copyright (c) 2023, networkException * * SPDX-License-Identifier: BSD-2-Clause */ @@ -150,8 +151,14 @@ public: Client, }; + enum class Priority { + High, + Low, + Auto + }; + // Members are implementation-defined - struct Priority { }; + struct InternalPriority { }; using BodyType = Variant>; using OriginType = Variant; @@ -207,8 +214,8 @@ public: [[nodiscard]] Optional const& destination() const { return m_destination; } void set_destination(Optional destination) { m_destination = move(destination); } - [[nodiscard]] Optional const& priority() const { return m_priority; } - void set_priority(Optional priority) { m_priority = move(priority); } + [[nodiscard]] Priority const& priority() const { return m_priority; } + void set_priority(Priority priority) { m_priority = priority; } [[nodiscard]] OriginType const& origin() const { return m_origin; } void set_origin(OriginType origin) { m_origin = move(origin); } @@ -387,9 +394,13 @@ private: // those destinations skip service workers. Optional m_destination; - // https://fetch.spec.whatwg.org/#concept-request-priority - // A request has an associated priority (null or a user-agent-defined object). Unless otherwise stated it is null. - Optional m_priority; + // https://fetch.spec.whatwg.org/#request-priority + // A request has an associated priority, which is "high", "low", or "auto". Unless stated otherwise it is "auto". + Priority m_priority { Priority::Auto }; + + // https://fetch.spec.whatwg.org/#request-internal-priority + // A request has an associated internal priority (null or an implementation-defined object). Unless otherwise stated it is null. + Optional m_internal_priority; // https://fetch.spec.whatwg.org/#concept-request-origin // A request has an associated origin, which is "client" or an origin. Unless stated otherwise it is "client".