Bug 1900561 - Set nsIClassOfService::fetchPriority where callers use nsISupportsPriority.adjustPriority r=acreskey

Depends on D221957

Differential Revision: https://phabricator.services.mozilla.com/D221958
This commit is contained in:
Valentin Gosu
2024-09-24 12:29:08 +00:00
parent 7b36a93327
commit ebbb22fc8b
4 changed files with 22 additions and 3 deletions

View File

@@ -855,12 +855,16 @@ nsresult FetchDriver::HttpFetch(
nsIClassOfService::Tail); nsIClassOfService::Tail);
} }
const auto fetchPriority = ToFetchPriority(mRequest->GetPriorityMode());
if (cos) {
cos->SetFetchPriorityDOM(fetchPriority);
}
if (nsCOMPtr<nsISupportsPriority> p = do_QueryInterface(chan)) { if (nsCOMPtr<nsISupportsPriority> p = do_QueryInterface(chan)) {
if (mIsTrackingFetch && if (mIsTrackingFetch &&
StaticPrefs::privacy_trackingprotection_lower_network_priority()) { StaticPrefs::privacy_trackingprotection_lower_network_priority()) {
p->SetPriority(nsISupportsPriority::PRIORITY_LOWEST); p->SetPriority(nsISupportsPriority::PRIORITY_LOWEST);
} else if (StaticPrefs::network_fetchpriority_enabled()) { } else if (StaticPrefs::network_fetchpriority_enabled()) {
const auto fetchPriority = ToFetchPriority(mRequest->GetPriorityMode());
// According to step 15 of https://fetch.spec.whatwg.org/#concept-fetch // According to step 15 of https://fetch.spec.whatwg.org/#concept-fetch
// requests priority, initiator, destination, and render-blocking are // requests priority, initiator, destination, and render-blocking are
// used in an implementation-defined manner to set the internal priority. // used in an implementation-defined manner to set the internal priority.

View File

@@ -733,11 +733,11 @@ static void AdjustPriorityAndClassOfServiceForLinkPreloadScripts(
return; return;
} }
const auto fetchPriority = ToFetchPriority(aRequest->FetchPriority());
if (nsCOMPtr<nsISupportsPriority> supportsPriority = if (nsCOMPtr<nsISupportsPriority> supportsPriority =
do_QueryInterface(aChannel)) { do_QueryInterface(aChannel)) {
LOG(("Is <link rel=[module]preload")); LOG(("Is <link rel=[module]preload"));
const auto fetchPriority = ToFetchPriority(aRequest->FetchPriority());
// The spec defines the priority to be set in an implementation defined // The spec defines the priority to be set in an implementation defined
// manner (<https://fetch.spec.whatwg.org/#concept-fetch>, step 15 and // manner (<https://fetch.spec.whatwg.org/#concept-fetch>, step 15 and
// <https://html.spec.whatwg.org/#concept-script-fetch-options-fetch-priority>). // <https://html.spec.whatwg.org/#concept-script-fetch-options-fetch-priority>).
@@ -752,6 +752,10 @@ static void AdjustPriorityAndClassOfServiceForLinkPreloadScripts(
adjustedPriority); adjustedPriority);
#endif #endif
} }
if (nsCOMPtr<nsIClassOfService> cos = do_QueryInterface(aChannel)) {
cos->SetFetchPriorityDOM(fetchPriority);
}
} }
void AdjustPriorityForNonLinkPreloadScripts(nsIChannel* aChannel, void AdjustPriorityForNonLinkPreloadScripts(nsIChannel* aChannel,
@@ -762,10 +766,10 @@ void AdjustPriorityForNonLinkPreloadScripts(nsIChannel* aChannel,
return; return;
} }
const auto fetchPriority = ToFetchPriority(aRequest->FetchPriority());
if (nsCOMPtr<nsISupportsPriority> supportsPriority = if (nsCOMPtr<nsISupportsPriority> supportsPriority =
do_QueryInterface(aChannel)) { do_QueryInterface(aChannel)) {
LOG(("Is not <link rel=[module]preload")); LOG(("Is not <link rel=[module]preload"));
const auto fetchPriority = ToFetchPriority(aRequest->FetchPriority());
// The spec defines the priority to be set in an implementation defined // The spec defines the priority to be set in an implementation defined
// manner (<https://fetch.spec.whatwg.org/#concept-fetch>, step 15 and // manner (<https://fetch.spec.whatwg.org/#concept-fetch>, step 15 and
@@ -801,6 +805,9 @@ void AdjustPriorityForNonLinkPreloadScripts(nsIChannel* aChannel,
#endif #endif
} }
} }
if (nsCOMPtr<nsIClassOfService> cos = do_QueryInterface(aChannel)) {
cos->SetFetchPriorityDOM(fetchPriority);
}
} }
// static // static

View File

@@ -838,6 +838,10 @@ static void AdjustPriorityForImages(nsIChannel* aChannel,
supportsPriority->AdjustPriority(priority); supportsPriority->AdjustPriority(priority);
} }
if (nsCOMPtr<nsIClassOfService> cos = do_QueryInterface(aChannel)) {
cos->SetFetchPriorityDOM(aFetchPriority);
}
} }
static nsresult NewImageChannel( static nsresult NewImageChannel(

View File

@@ -1489,6 +1489,10 @@ void Loader::AdjustPriority(const SheetLoadData& aLoadData,
sp->GetPriority(&adjustedPriority); sp->GetPriority(&adjustedPriority);
LogPriorityMapping(sCssLoaderLog, aLoadData.mFetchPriority, adjustedPriority); LogPriorityMapping(sCssLoaderLog, aLoadData.mFetchPriority, adjustedPriority);
#endif #endif
if (nsCOMPtr<nsIClassOfService> cos = do_QueryInterface(aChannel)) {
cos->SetFetchPriorityDOM(aLoadData.mFetchPriority);
}
} }
nsresult Loader::LoadSheetAsyncInternal(SheetLoadData& aLoadData, nsresult Loader::LoadSheetAsyncInternal(SheetLoadData& aLoadData,