Make ResourceFetcher return Resources with LoadError instead of nullptrs.
Before this change, when a request was immediately blocked by access checks,
ResourceFetcher::requestResource() would return a nullptr, while returning a
Resource instance with a LoadError set if the request was blocked only after
following one or more redirects. This resulted in various resource types
failing in inconsistent ways in the two cases.
This CL makes this behavior consistent by making requestResource() always
return a Resource instance with a LoadError. This allows for cleaner and more
consistent handling of errors in ResourceClients, as wells as more flexibility
should the client choose to distinguish the underlying causes of errors. Due
to the infrequency of requests failing access checks during normal use, the
performance impact should be negligible.
This is a reland of
https://codereview.chromium.org/2231523002/, which got
reverted due to making the following layout test flaky:
http/tests/security/contentSecurityPolicy/nonces/import-enforce-blocked.php
The test has been updated so there is no longer a race condition.
BUG=
616234
Committed:
https://crrev.com/2f545df32a684b115b8b4c5458778695881b1bc6
Cr-Commit-Position: refs/heads/master@{#423978}