Stop re-setting ResourceRequest's priority if it is already set

This CL addresses the concerns in https://crbug.com/882344, and is somewhat
a follow-up to https://crbug.com/872776. This CL ensures that ResourceRequests
with a pre-set priority do not get their priority re-computed by
ResourceFetcher.

Before this CL, ResourceRequests passing through ResourceFetcher
always have their priority computed. When a Service Worker fetches a
resource from the network, it does so using the fetch() API, whose
requests get the computed priority kHigh. Therefore, all requests
passing through Service Worker whose priority is < kHigh would
unnecessarily get upgraded to kHigh. This is the inverse of the problem
described in https://crbug.com/872776.

After this CL, we stop invoking ResourceFetcher::ComputeLoadPriority
if a ResourceRequest already has its priority set. This ensures that
originally-computed priorities are completely preserved when passing
through a Service Worker. What this CL does not change is the fact that
requests that already have their priorities set are exempt from priority
experiments, but if that is to be done, it should be done separately.

An added benefit is that we remove some funny logic from ComputeLoadPriority
that ensures a request is never down-prioritized.

Chromestatus: https://chromestatus.com/feature/5642182885113856

R=kinuko@chromium.org, yhirano@chromium.org, yoavweiss@chromium.org

Bug: 882344
Change-Id: Ic2516f3338f1ad1f4caa77b76dbcecb3dcaf84a8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1683494
Commit-Queue: Dominic Farolino <dom@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#676409}
7 files changed