diff options
Diffstat (limited to 'net/http')
-rw-r--r-- | net/http/http_cache.cc | 1 | ||||
-rw-r--r-- | net/http/http_network_transaction.cc | 4 | ||||
-rw-r--r-- | net/http/http_response_info.h | 9 | ||||
-rw-r--r-- | net/http/http_transaction_unittest.h | 2 | ||||
-rw-r--r-- | net/http/http_transaction_winhttp.cc | 3 |
5 files changed, 17 insertions, 2 deletions
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc index 2ac62ef..7edc0a8 100644 --- a/net/http/http_cache.cc +++ b/net/http/http_cache.cc @@ -1022,6 +1022,7 @@ bool HttpCache::ReadResponseInfo(disk_cache::Entry* disk_entry, if (!pickle.ReadInt64(&iter, &time_val)) return false; response_info->request_time = Time::FromInternalValue(time_val); + response_info->was_cached = true; // Set status to show cache resurrection. // read response-time if (!pickle.ReadInt64(&iter, &time_val)) diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc index 45a9a5e..9d6ed1b 100644 --- a/net/http/http_network_transaction.cc +++ b/net/http/http_network_transaction.cc @@ -560,8 +560,10 @@ int HttpNetworkTransaction::DoWriteHeaders() { // Record our best estimate of the 'request time' as the time when we send // out the first bytes of the request headers. - if (request_headers_bytes_sent_ == 0) + if (request_headers_bytes_sent_ == 0) { response_.request_time = Time::Now(); + response_.was_cached = false; + } const char* buf = request_headers_.data() + request_headers_bytes_sent_; int buf_len = static_cast<int>(request_headers_.size() - diff --git a/net/http/http_response_info.h b/net/http/http_response_info.h index 80defef..5563ada 100644 --- a/net/http/http_response_info.h +++ b/net/http/http_response_info.h @@ -15,6 +15,15 @@ namespace net { class HttpResponseInfo { public: + // The following is only defined if the request_time memmber is set. + // If this response was resurrected from cache, then this bool is set, and + // request_time may corresponds to a time "far" in the past. Note that + // stale content (perhaps un-cacheable) may be fetched from cache subject to + // the load flags specified on the request info. For example, this is done + // when a user presses the back button to re-render pages, or at startup, when + // reloading previously visited pages (without going over the network). + bool was_cached; + // The time at which the request was made that resulted in this response. // For cached responses, this time could be "far" in the past. base::Time request_time; diff --git a/net/http/http_transaction_unittest.h b/net/http/http_transaction_unittest.h index eb2d7bb..ccdb954 100644 --- a/net/http/http_transaction_unittest.h +++ b/net/http/http_transaction_unittest.h @@ -7,6 +7,7 @@ #include "net/http/http_transaction.h" +#include <algorithm> #include <string> #include "base/compiler_specific.h" @@ -212,6 +213,7 @@ class MockNetworkTransaction : public net::HttpTransaction { std::replace(header_data.begin(), header_data.end(), '\n', '\0'); response_.request_time = base::Time::Now(); + response_.was_cached = false; response_.response_time = base::Time::Now(); response_.headers = new net::HttpResponseHeaders(header_data); response_.ssl_info.cert_status = t->cert_status; diff --git a/net/http/http_transaction_winhttp.cc b/net/http/http_transaction_winhttp.cc index b1ecf2a..06cd391 100644 --- a/net/http/http_transaction_winhttp.cc +++ b/net/http/http_transaction_winhttp.cc @@ -172,7 +172,7 @@ class HttpTransactionWinHttp::Session WINHTTP_FLAG_SECURE_PROTOCOL_TLS1 }; - Session(ProxyService* proxy_service); + explicit Session(ProxyService* proxy_service); // Opens the primary WinHttp session handle. bool Init(const std::string& user_agent); @@ -1232,6 +1232,7 @@ int HttpTransactionWinHttp::SendRequest() { } response_.request_time = Time::Now(); + response_.was_cached = false; DWORD total_size = 0; if (request_->upload_data) { |