diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-04 22:53:16 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-04 22:53:16 +0000 |
commit | ca2f19e15442db908f02e9fcfc1e35243d4689d7 (patch) | |
tree | 2ac8309b0eded29e787f6f09d98f870df767442f /net | |
parent | cb4ff9d7374c09b4ff0c8e257e15b81bb7bb42ed (diff) | |
download | chromium_src-ca2f19e15442db908f02e9fcfc1e35243d4689d7.zip chromium_src-ca2f19e15442db908f02e9fcfc1e35243d4689d7.tar.gz chromium_src-ca2f19e15442db908f02e9fcfc1e35243d4689d7.tar.bz2 |
Update the request time of http cache entries on 304.
BUG=http://crbug.com/20594
TEST=HttpCache.UpdatesRequestResponseTimeOn304
Review URL: http://codereview.chromium.org/199028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25541 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/http/http_cache.cc | 1 | ||||
-rw-r--r-- | net/http/http_cache_unittest.cc | 20 | ||||
-rw-r--r-- | net/http/http_transaction_unittest.cc | 5 | ||||
-rw-r--r-- | net/http/http_transaction_unittest.h | 5 |
4 files changed, 25 insertions, 6 deletions
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc index 44b5d00..12d0844 100644 --- a/net/http/http_cache.cc +++ b/net/http/http_cache.cc @@ -1444,6 +1444,7 @@ void HttpCache::Transaction::OnNetworkInfoAvailable(int result) { // (response_.ssl_info), too? response_.headers->Update(*new_response->headers); response_.response_time = new_response->response_time; + response_.request_time = new_response->request_time; if (response_.headers->HasHeaderValue("cache-control", "no-store")) { cache_->DoomEntry(cache_key_); diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc index fa20f13..8d01b6a 100644 --- a/net/http/http_cache_unittest.cc +++ b/net/http/http_cache_unittest.cc @@ -458,6 +458,7 @@ bool FastTransactionServer::no_store; const MockTransaction kFastNoStoreGET_Transaction = { "http://www.google.com/nostore", "GET", + base::Time(), "", net::LOAD_VALIDATE_CACHE, "HTTP/1.1 200 OK", @@ -562,6 +563,7 @@ void RangeTransactionServer::RangeHandler(const net::HttpRequestInfo* request, const MockTransaction kRangeGET_TransactionOK = { "http://www.google.com/range", "GET", + base::Time(), "Range: bytes = 40-49\r\n", net::LOAD_NORMAL, "HTTP/1.1 206 Partial Content", @@ -2498,9 +2500,10 @@ TEST(HttpCache, CacheDisabledMode) { // Other tests check that the response headers of the cached response // get updated on 304. Here we specifically check that the -// HttpResponseHeaders::response_time field also gets updated. +// HttpResponseHeaders::request_time and HttpResponseHeaders::response_time +// fields also gets updated. // http://crbug.com/20594. -TEST(HttpCache, UpdatesResponseTimeOn304) { +TEST(HttpCache, UpdatesRequestResponseTimeOn304) { MockHttpCache cache; const char* kUrl = "http://foobar"; @@ -2543,14 +2546,19 @@ TEST(HttpCache, UpdatesResponseTimeOn304) { kNetResponse2.AssignTo(&mock_network_response); - base::Time t = base::Time() + base::TimeDelta::FromHours(1234); - mock_network_response.response_time = t; + base::Time request_time = base::Time() + base::TimeDelta::FromHours(1234); + base::Time response_time = base::Time() + base::TimeDelta::FromHours(1235); + + mock_network_response.request_time = request_time; + mock_network_response.response_time = response_time; net::HttpResponseInfo response; RunTransactionTestWithResponseInfo(cache.http_cache(), request, &response); - // The response time should have been updated. - EXPECT_EQ(t.ToInternalValue(), + // The request and response times should have been updated. + EXPECT_EQ(request_time.ToInternalValue(), + response.request_time.ToInternalValue()); + EXPECT_EQ(response_time.ToInternalValue(), response.response_time.ToInternalValue()); std::string headers; diff --git a/net/http/http_transaction_unittest.cc b/net/http/http_transaction_unittest.cc index 4a0cef7..01e6ea5 100644 --- a/net/http/http_transaction_unittest.cc +++ b/net/http/http_transaction_unittest.cc @@ -22,6 +22,7 @@ const MockTransaction kSimpleGET_Transaction = { "http://www.google.com/", "GET", + base::Time(), "", net::LOAD_NORMAL, "HTTP/1.1 200 OK", @@ -36,6 +37,7 @@ const MockTransaction kSimpleGET_Transaction = { const MockTransaction kSimplePOST_Transaction = { "http://bugdatabase.com/edit", "POST", + base::Time(), "", net::LOAD_NORMAL, "HTTP/1.1 200 OK", @@ -50,6 +52,7 @@ const MockTransaction kSimplePOST_Transaction = { const MockTransaction kTypicalGET_Transaction = { "http://www.example.com/~foo/bar.html", "GET", + base::Time(), "", net::LOAD_NORMAL, "HTTP/1.1 200 OK", @@ -65,6 +68,7 @@ const MockTransaction kTypicalGET_Transaction = { const MockTransaction kETagGET_Transaction = { "http://www.google.com/foopy", "GET", + base::Time(), "", net::LOAD_NORMAL, "HTTP/1.1 200 OK", @@ -80,6 +84,7 @@ const MockTransaction kETagGET_Transaction = { const MockTransaction kRangeGET_Transaction = { "http://www.google.com/", "GET", + base::Time(), "Range: 0-100\r\n", net::LOAD_NORMAL, "HTTP/1.1 200 OK", diff --git a/net/http/http_transaction_unittest.h b/net/http/http_transaction_unittest.h index 1f4919f..d2e2115 100644 --- a/net/http/http_transaction_unittest.h +++ b/net/http/http_transaction_unittest.h @@ -43,6 +43,8 @@ typedef void (*MockTransactionHandler)(const net::HttpRequestInfo* request, struct MockTransaction { const char* url; const char* method; + // If |request_time| is unspecified, the current time will be used. + base::Time request_time; const char* request_headers; int load_flags; const char* status; @@ -219,6 +221,9 @@ class MockNetworkTransaction : public net::HttpTransaction { std::replace(header_data.begin(), header_data.end(), '\n', '\0'); response_.request_time = base::Time::Now(); + if (!t->request_time.is_null()) + response_.request_time = t->request_time; + response_.was_cached = false; response_.response_time = base::Time::Now(); |