Truly independent web browser
LibWeb: Correct what comments say about a fetch's client
Luke Wilde480d5adb5015
diff --git a/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp b/Libraries/LibWeb/Fetch/Fetching/Fetching.cppindex 35a0bbd833e..e62c5fad636 100644--- a/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp+++ b/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp@@ -476,7 +476,8 @@ GC::Ref<Infrastructure::FetchController> fetch(JS::Realm& realm, Infrastructure:local_client->fetch_group().append(record);// AD-HOC: A keepalive request's body length counts toward its fetch group's keepalive quota from here until- // its done flag is set or its body is null, since its fetch record can be collected before then.+ // its done flag is set, its body is null or the request is destroyed, since its fetch record can be+ // collected before then.if (request.keepalive()) {auto body_length = request.body().visit([](Empty) -> u64 { return 0; },@@ -551,8 +552,8 @@ void populate_request_from_client(Infrastructure::Request& request, Optional<HTM}}- // AD-HOC: Fetching reads the client through a snapshot of it, taken here, so that it needs neither the settings- // object nor its global object.+ // AD-HOC: Take a snapshot of the client for main fetch and the steps under it, which reach the client itself only+ // through its global object, to queue tasks and to report violations and timing.if (client.has_value())request.set_client_snapshot(client->visit([](auto const& client) { return snapshot_client_context(*client); }));}@@ -1804,8 +1805,7 @@ GC::Ref<PendingResponse> http_fetch(JS::Realm& realm, Infrastructure::FetchParam// NOTE: The cross-origin resource policy check runs for responses coming from the network and responses coming// from the service worker. This is different from the CORS check, as request’s client and the service// worker can have different embedder policies.- // NB: request's policy container is a clone of its client's, taken at fetch start, or a new one when it has no- // client.+ // NB: request's policy container is a copy of its client's, or a new one when it has no client.auto const& client_embedder_policy = request->policy_container().get<NonnullRefPtr<HTML::PolicyContainer const>>()->embedder_policy;if ((request->response_tainting() == Infrastructure::Request::ResponseTainting::Opaque || response->type() == Infrastructure::Response::Type::Opaque)&& cross_origin_resource_policy_check(request->origin().get<URL::Origin>(), client_embedder_policy, *internal_response) == Infrastructure::RequestOrResponseBlocking::Blocked) {@@ -2401,8 +2401,8 @@ GC::Ref<PendingResponse> http_network_or_cache_fetch(JS::Realm& realm, Infrastru// 4. For each fetchRecord of inflightRecords:// 1. Let inflightRequest be fetchRecord’s request.// 2. Increment inflightKeepaliveBytes by inflightRequest’s body’s length.- // AD-HOC: The fetch group's keepalive quota accountant holds this sum, so a request whose fetch record was- // collected still counts.+ // AD-HOC: The sum is read from the fetch group's keepalive quota accountant, since a request's fetch record+ // can be collected before its done flag is set.auto inflight_keep_alive_bytes = http_request->client_snapshot()->keepalive_quota_accountant->in_flight_byte_count();// 5. If the sum of contentLength and inflightKeepaliveBytes is greater than 64 kibibytes, then return a network error.diff --git a/Libraries/LibWeb/Fetch/Infrastructure/ClientContextSnapshot.h b/Libraries/LibWeb/Fetch/Infrastructure/ClientContextSnapshot.hindex ae0c7735b98..bc6951e18bf 100644--- a/Libraries/LibWeb/Fetch/Infrastructure/ClientContextSnapshot.h+++ b/Libraries/LibWeb/Fetch/Infrastructure/ClientContextSnapshot.h@@ -62,7 +62,7 @@ struct ClientContext {IsLoadingBypassingCache is_loading_bypassing_cache { IsLoadingBypassingCache::No };double time_origin { 0 };- // The navigable of the Window that is the global object, if any.+ // The navigable of the Window that is the global object, if it has one and this process hosts the Window.Optional<HTML::CrossProcessId> navigable_id;// The URL a "client" referrer is determined from, or none for no referrer.@@ -74,7 +74,8 @@ struct ClientContext {NonnullRefPtr<KeepaliveQuotaAccountant> keepalive_quota_accountant;};-// A request's client context as it was when the fetch started.+// A request's client context, taken when the fetch started, or, for a client another process hosts, made from what+// that process serialized.struct WEB_API ClientContextSnapshot final : public AtomicRefCounted<ClientContextSnapshot>, public ClientContext {explicit ClientContextSnapshot(ClientContext context)diff --git a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.hindex 8c76909607c..e028ed3eb80 100644--- a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h+++ b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h@@ -563,7 +563,8 @@ private:// A request has an associated done flag. Unless stated otherwise, it is unset.bool m_done { false };- // Counts this request's body against its client's keepalive quota until its done flag is set or its body is null.+ // Counts this request's body against its client's keepalive quota until its done flag is set, its body is null or+ // it is destroyed.Optional<KeepaliveQuotaAccountant::Reservation> m_keepalive_quota_reservation;// https://fetch.spec.whatwg.org/#timing-allow-faileddiff --git a/Libraries/LibWeb/Fetch/Infrastructure/KeepaliveQuotaAccountant.h b/Libraries/LibWeb/Fetch/Infrastructure/KeepaliveQuotaAccountant.hindex d274b6c49f7..f1c517408a8 100644--- a/Libraries/LibWeb/Fetch/Infrastructure/KeepaliveQuotaAccountant.h+++ b/Libraries/LibWeb/Fetch/Infrastructure/KeepaliveQuotaAccountant.h@@ -15,7 +15,7 @@namespace Web::Fetch::Infrastructure {-// The sum of the body lengths of a fetch group's keepalive requests whose done flag is unset.+// The sum of the body lengths that a fetch group's keepalive requests hold reservations for.class WEB_API KeepaliveQuotaAccountant final : public AtomicRefCounted<KeepaliveQuotaAccountant> {public:// Keeps its byte count in the accountant's sum until it is destroyed.