[net/cache] Skip the cache if the response is expected to exceed 2GB.

The state machine in http_cache_transaction doesn't handle partial
requests that are larger than numeric_limits<int32_t>::max(). If there
is a truncated partial cache entry for a large response, then the cache
will try to issue partial requests of size at most
numeric_limits<int32_t>::max() bytes until the entire resource is
fetched.

However, if StopCaching() is called, as it often is for response of this
size that are downloaded, then the cache transaction switches to pass
through mode. This trips a bug in the state machine where the response
would be considered complete once the current partial request completes.

There are multiple issues in the cache transaction that needs
addressing, but for now we are going to skip the cache entirely if we
are likely to hit this case. The partial cache entry is most likely the
result of a MIME sniffing attempt and would be insignificant compared to
the resource size. Hence skipping the cache in this case isn't expected
to regress on performance.

This change adds several unit tests that drive a request with a response
size of 5GB. These tests are expected to be slower than the average net
unit test, but shouldn't cause trouble for the bots.

BUG=89567

Review-Url: https://codereview.chromium.org/2089783002
Cr-Commit-Position: refs/heads/master@{#402774}
5 files changed