Set network_accessed earlier, when network transaction creates stream.
HttpResponseInfo contains a "network_accessed" flag that is currently
set when HttpNetworkTransaction finishes sending the request. This is
not entirely accurate; it ends up false for requests that don't send a
request but do touch the network in other ways (e.g. DNS resolution
fails, or TCP connection is terminated before we finish sending the
request).
This flag is used only by Domain Reliability for checking whether a
request touched the network, and by ServiceWorker for histograms.
horo says ServiceWorker won't be affected, and I would prefer these
semantics for Domain Reliability's use, so I'm changing it.
Note that this also changes several instances of GetResponseInfo
to stop returning NULL.
See also for context:
https://groups.google.com/a/chromium.org/forum/#!topic/net-dev/Wtn65jGyot0
BUG=480565
Review URL: https://codereview.chromium.org/1072423005
Cr-Commit-Position: refs/heads/master@{#330011}
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc
index 998b7ef..cf73369 100644
--- a/net/http/http_network_transaction.cc
+++ b/net/http/http_network_transaction.cc
@@ -395,10 +395,7 @@
void HttpNetworkTransaction::DoneReading() {}
const HttpResponseInfo* HttpNetworkTransaction::GetResponseInfo() const {
- return ((headers_valid_ && response_.headers.get()) ||
- response_.ssl_info.cert.get() || response_.cert_request_info.get())
- ? &response_
- : NULL;
+ return &response_;
}
LoadState HttpNetworkTransaction::GetLoadState() const {
@@ -736,6 +733,8 @@
FROM_HERE_WITH_EXPLICIT_FUNCTION(
"424359 HttpNetworkTransaction::DoCreateStream"));
+ response_.network_accessed = true;
+
next_state_ = STATE_CREATE_STREAM_COMPLETE;
if (ForWebSocketHandshake()) {
stream_request_.reset(
@@ -974,7 +973,6 @@
send_end_time_ = base::TimeTicks::Now();
if (result < 0)
return HandleIOError(result);
- response_.network_accessed = true;
next_state_ = STATE_READ_HEADERS;
return OK;
}