Index: net/http/http_cache_unittest.cc |
=================================================================== |
--- net/http/http_cache_unittest.cc (revision 199488) |
+++ net/http/http_cache_unittest.cc (working copy) |
@@ -13,6 +13,8 @@ |
#include "net/base/cache_type.h" |
#include "net/base/host_port_pair.h" |
#include "net/base/load_flags.h" |
+#include "net/base/load_timing_info.h" |
+#include "net/base/load_timing_info_test_util.h" |
#include "net/base/net_errors.h" |
#include "net/base/net_log_unittest.h" |
#include "net/base/upload_bytes_element_reader.h" |
@@ -36,6 +38,49 @@ |
namespace { |
+// Tests the load timing values of a request that goes through a |
+// MockNetworkTransaction. |
+void TestLoadTimingNetworkRequest(const net::LoadTimingInfo& load_timing_info) { |
+ EXPECT_FALSE(load_timing_info.socket_reused); |
+ EXPECT_NE(net::NetLog::Source::kInvalidId, load_timing_info.socket_log_id); |
+ |
+ EXPECT_TRUE(load_timing_info.proxy_resolve_start.is_null()); |
+ EXPECT_TRUE(load_timing_info.proxy_resolve_end.is_null()); |
+ |
+ net::ExpectConnectTimingHasTimes(load_timing_info.connect_timing, |
+ net::CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); |
+ EXPECT_LE(load_timing_info.connect_timing.connect_end, |
+ load_timing_info.send_start); |
+ |
+ EXPECT_LE(load_timing_info.send_start, load_timing_info.send_end); |
+ |
+ // Set by URLRequest / URLRequestHttpJob, at a higher level. |
+ EXPECT_TRUE(load_timing_info.request_start_time.is_null()); |
+ EXPECT_TRUE(load_timing_info.request_start.is_null()); |
+ EXPECT_TRUE(load_timing_info.receive_headers_end.is_null()); |
+} |
+ |
+// Tests the load timing values of a request that receives a cached response. |
+void TestLoadTimingCachedResponse(const net::LoadTimingInfo& load_timing_info) { |
+ EXPECT_FALSE(load_timing_info.socket_reused); |
+ EXPECT_EQ(net::NetLog::Source::kInvalidId, load_timing_info.socket_log_id); |
+ |
+ EXPECT_TRUE(load_timing_info.proxy_resolve_start.is_null()); |
+ EXPECT_TRUE(load_timing_info.proxy_resolve_end.is_null()); |
+ |
+ net::ExpectConnectTimingHasNoTimes(load_timing_info.connect_timing); |
+ |
+ // Only the send start / end times should be sent, and they should have the |
+ // same value. |
+ EXPECT_FALSE(load_timing_info.send_start.is_null()); |
+ EXPECT_EQ(load_timing_info.send_start, load_timing_info.send_end); |
+ |
+ // Set by URLRequest / URLRequestHttpJob, at a higher level. |
+ EXPECT_TRUE(load_timing_info.request_start_time.is_null()); |
+ EXPECT_TRUE(load_timing_info.request_start.is_null()); |
+ EXPECT_TRUE(load_timing_info.receive_headers_end.is_null()); |
+} |
+ |
class DeleteCacheCompletionCallback : public net::TestCompletionCallbackBase { |
public: |
explicit DeleteCacheCompletionCallback(MockHttpCache* cache) |
@@ -127,14 +172,15 @@ |
const int kNoDelegateTransactionCheck = -1; |
-void RunTransactionTestWithRequestAndLogAndDelegate( |
+void RunTransactionTestWithRequestAndDelegateAndGetTiming( |
net::HttpCache* cache, |
const MockTransaction& trans_info, |
const MockHttpRequest& request, |
net::HttpResponseInfo* response_info, |
+ int num_cache_delegate_actions, |
+ int num_network_delegate_actions, |
const net::BoundNetLog& net_log, |
- int num_cache_delegate_actions, |
- int num_network_delegate_actions) { |
+ net::LoadTimingInfo* load_timing_info) { |
net::TestCompletionCallback callback; |
// write to the cache |
@@ -166,38 +212,61 @@ |
if (response_info) |
*response_info = *response; |
+ if (load_timing_info) { |
+ // If a fake network connection is used, need a NetLog to get a fake socket |
+ // ID. |
+ EXPECT_TRUE(net_log.net_log()); |
+ *load_timing_info = net::LoadTimingInfo(); |
+ trans->GetLoadTimingInfo(load_timing_info); |
+ } |
+ |
ReadAndVerifyTransaction(trans.get(), trans_info); |
} |
+void RunTransactionTestWithRequestAndDelegate( |
+ net::HttpCache* cache, |
+ const MockTransaction& trans_info, |
+ const MockHttpRequest& request, |
+ net::HttpResponseInfo* response_info, |
+ int num_cache_delegate_actions, |
+ int num_network_delegate_actions) { |
+ RunTransactionTestWithRequestAndDelegateAndGetTiming( |
+ cache, trans_info, request, response_info, num_cache_delegate_actions, |
+ num_network_delegate_actions, net::BoundNetLog(), NULL); |
+} |
+ |
void RunTransactionTestWithRequest(net::HttpCache* cache, |
const MockTransaction& trans_info, |
const MockHttpRequest& request, |
net::HttpResponseInfo* response_info) { |
- RunTransactionTestWithRequestAndLogAndDelegate( |
- cache, trans_info, request, response_info, net::BoundNetLog(), |
- kNoDelegateTransactionCheck, kNoDelegateTransactionCheck); |
+ RunTransactionTestWithRequestAndDelegate( |
+ cache, trans_info, request, response_info, kNoDelegateTransactionCheck, |
+ kNoDelegateTransactionCheck); |
} |
-void RunTransactionTestWithLog(net::HttpCache* cache, |
- const MockTransaction& trans_info, |
- const net::BoundNetLog& log) { |
- RunTransactionTestWithRequestAndLogAndDelegate( |
- cache, trans_info, MockHttpRequest(trans_info), NULL, log, |
- kNoDelegateTransactionCheck, kNoDelegateTransactionCheck); |
+void RunTransactionTestAndGetTiming( |
+ net::HttpCache* cache, |
+ const MockTransaction& trans_info, |
+ const net::BoundNetLog& log, |
+ net::LoadTimingInfo* load_timing_info) { |
+ RunTransactionTestWithRequestAndDelegateAndGetTiming( |
+ cache, trans_info, MockHttpRequest(trans_info), NULL, |
+ kNoDelegateTransactionCheck, kNoDelegateTransactionCheck, log, |
+ load_timing_info); |
} |
void RunTransactionTestWithDelegate(net::HttpCache* cache, |
const MockTransaction& trans_info, |
int num_cache_delegate_actions, |
int num_network_delegate_actions) { |
- RunTransactionTestWithRequestAndLogAndDelegate( |
- cache, trans_info, MockHttpRequest(trans_info), NULL, net::BoundNetLog(), |
+ RunTransactionTestWithRequestAndDelegate( |
+ cache, trans_info, MockHttpRequest(trans_info), NULL, |
num_cache_delegate_actions, num_network_delegate_actions); |
} |
void RunTransactionTest(net::HttpCache* cache, |
const MockTransaction& trans_info) { |
- RunTransactionTestWithLog(cache, trans_info, net::BoundNetLog()); |
+ RunTransactionTestAndGetTiming(cache, trans_info, net::BoundNetLog(), NULL); |
} |
void RunTransactionTestWithResponseInfo(net::HttpCache* cache, |
@@ -207,6 +276,18 @@ |
cache, trans_info, MockHttpRequest(trans_info), response); |
} |
+void RunTransactionTestWithResponseInfoAndGetTiming( |
+ net::HttpCache* cache, |
+ const MockTransaction& trans_info, |
+ net::HttpResponseInfo* response, |
+ const net::BoundNetLog& log, |
+ net::LoadTimingInfo* load_timing_info) { |
+ RunTransactionTestWithRequestAndDelegateAndGetTiming( |
+ cache, trans_info, MockHttpRequest(trans_info), response, |
+ kNoDelegateTransactionCheck, kNoDelegateTransactionCheck, log, |
+ load_timing_info); |
+} |
+ |
void RunTransactionTestWithResponse(net::HttpCache* cache, |
const MockTransaction& trans_info, |
std::string* response_headers) { |
@@ -215,6 +296,20 @@ |
response.headers->GetNormalizedHeaders(response_headers); |
} |
+void RunTransactionTestWithResponseAndGetTiming( |
+ net::HttpCache* cache, |
+ const MockTransaction& trans_info, |
+ std::string* response_headers, |
+ const net::BoundNetLog& log, |
+ net::LoadTimingInfo* load_timing_info) { |
+ net::HttpResponseInfo response; |
+ RunTransactionTestWithRequestAndDelegateAndGetTiming( |
+ cache, trans_info, MockHttpRequest(trans_info), &response, |
+ kNoDelegateTransactionCheck, kNoDelegateTransactionCheck, |
+ log, load_timing_info); |
+ response.headers->GetNormalizedHeaders(response_headers); |
+} |
+ |
// This class provides a handler for kFastNoStoreGET_Transaction so that the |
// no-store header can be included on demand. |
class FastTransactionServer { |
@@ -507,13 +602,17 @@ |
TEST(HttpCache, SimpleGET) { |
MockHttpCache cache; |
+ net::CapturingBoundNetLog log; |
+ net::LoadTimingInfo load_timing_info; |
- // write to the cache |
- RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); |
+ // Write to the cache. |
+ RunTransactionTestAndGetTiming(cache.http_cache(), kSimpleGET_Transaction, |
+ log.bound(), &load_timing_info); |
EXPECT_EQ(1, cache.network_layer()->transaction_count()); |
EXPECT_EQ(0, cache.disk_cache()->open_count()); |
EXPECT_EQ(1, cache.disk_cache()->create_count()); |
+ TestLoadTimingNetworkRequest(load_timing_info); |
} |
TEST(HttpCache, SimpleGETNoDiskCache) { |
@@ -523,10 +622,11 @@ |
net::CapturingBoundNetLog log; |
log.SetLogLevel(net::NetLog::LOG_BASIC); |
+ net::LoadTimingInfo load_timing_info; |
// Read from the network, and don't use the cache. |
- RunTransactionTestWithLog(cache.http_cache(), kSimpleGET_Transaction, |
- log.bound()); |
+ RunTransactionTestAndGetTiming(cache.http_cache(), kSimpleGET_Transaction, |
+ log.bound(), &load_timing_info); |
// Check that the NetLog was filled as expected. |
// (We attempted to both Open and Create entries, but both failed). |
@@ -550,6 +650,7 @@ |
EXPECT_EQ(1, cache.network_layer()->transaction_count()); |
EXPECT_EQ(0, cache.disk_cache()->open_count()); |
EXPECT_EQ(0, cache.disk_cache()->create_count()); |
+ TestLoadTimingNetworkRequest(load_timing_info); |
} |
TEST(HttpCache, SimpleGETNoDiskCache2) { |
@@ -694,10 +795,12 @@ |
// This prevents a number of write events from being logged. |
log.SetLogLevel(net::NetLog::LOG_BASIC); |
- // write to the cache |
- RunTransactionTestWithLog(cache.http_cache(), kSimpleGET_Transaction, |
- log.bound()); |
+ net::LoadTimingInfo load_timing_info; |
+ // Write to the cache. |
+ RunTransactionTestAndGetTiming(cache.http_cache(), kSimpleGET_Transaction, |
+ log.bound(), &load_timing_info); |
+ |
// Check that the NetLog was filled as expected. |
net::CapturingNetLog::CapturedEntryList entries; |
log.GetEntries(&entries); |
@@ -720,13 +823,16 @@ |
EXPECT_TRUE(net::LogContainsEndEvent( |
entries, 7, net::NetLog::TYPE_HTTP_CACHE_ADD_TO_ENTRY)); |
- // force this transaction to read from the cache |
+ TestLoadTimingNetworkRequest(load_timing_info); |
+ |
+ // Force this transaction to read from the cache. |
MockTransaction transaction(kSimpleGET_Transaction); |
transaction.load_flags |= net::LOAD_ONLY_FROM_CACHE; |
log.Clear(); |
- RunTransactionTestWithLog(cache.http_cache(), transaction, log.bound()); |
+ RunTransactionTestAndGetTiming(cache.http_cache(), transaction, log.bound(), |
+ &load_timing_info); |
// Check that the NetLog was filled as expected. |
log.GetEntries(&entries); |
@@ -752,6 +858,7 @@ |
EXPECT_EQ(1, cache.network_layer()->transaction_count()); |
EXPECT_EQ(1, cache.disk_cache()->open_count()); |
EXPECT_EQ(1, cache.disk_cache()->create_count()); |
+ TestLoadTimingCachedResponse(load_timing_info); |
} |
TEST(HttpCache, SimpleGET_LoadOnlyFromCache_Miss) { |
@@ -851,11 +958,15 @@ |
// the network again. |
transaction.load_flags |= net::LOAD_PREFERRING_CACHE; |
transaction.request_headers = "Foo: none\r\n"; |
- RunTransactionTest(cache.http_cache(), transaction); |
+ net::CapturingBoundNetLog log; |
+ net::LoadTimingInfo load_timing_info; |
+ RunTransactionTestAndGetTiming(cache.http_cache(), transaction, log.bound(), |
+ &load_timing_info); |
EXPECT_EQ(2, cache.network_layer()->transaction_count()); |
EXPECT_EQ(1, cache.disk_cache()->open_count()); |
EXPECT_EQ(1, cache.disk_cache()->create_count()); |
+ TestLoadTimingNetworkRequest(load_timing_info); |
RemoveMockTransaction(&transaction); |
} |
@@ -1013,8 +1124,11 @@ |
// This prevents a number of write events from being logged. |
log.SetLogLevel(net::NetLog::LOG_BASIC); |
+ net::LoadTimingInfo load_timing_info; |
- RunTransactionTestWithLog(cache.http_cache(), transaction, log.bound()); |
+ // Write to the cache. |
+ RunTransactionTestAndGetTiming(cache.http_cache(), transaction, log.bound(), |
+ &load_timing_info); |
// Check that the NetLog was filled as expected. |
net::CapturingNetLog::CapturedEntryList entries; |
@@ -1041,6 +1155,7 @@ |
EXPECT_EQ(2, cache.network_layer()->transaction_count()); |
EXPECT_EQ(0, cache.disk_cache()->open_count()); |
EXPECT_EQ(2, cache.disk_cache()->create_count()); |
+ TestLoadTimingNetworkRequest(load_timing_info); |
} |
TEST(HttpCache, SimpleGET_LoadBypassCache_Implicit) { |
@@ -1080,24 +1195,28 @@ |
TEST(HttpCache, SimpleGET_LoadValidateCache) { |
MockHttpCache cache; |
- // write to the cache |
+ // Write to the cache. |
RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); |
- // read from the cache |
+ // Read from the cache. |
RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); |
- // force this transaction to validate the cache |
+ // Force this transaction to validate the cache. |
MockTransaction transaction(kSimpleGET_Transaction); |
transaction.load_flags |= net::LOAD_VALIDATE_CACHE; |
net::HttpResponseInfo response_info; |
- RunTransactionTestWithResponseInfo(cache.http_cache(), transaction, |
- &response_info); |
+ net::CapturingBoundNetLog log; |
+ net::LoadTimingInfo load_timing_info; |
+ RunTransactionTestWithResponseInfoAndGetTiming( |
+ cache.http_cache(), transaction, &response_info, log.bound(), |
+ &load_timing_info); |
EXPECT_EQ(2, cache.network_layer()->transaction_count()); |
EXPECT_EQ(1, cache.disk_cache()->open_count()); |
EXPECT_EQ(1, cache.disk_cache()->create_count()); |
EXPECT_TRUE(response_info.network_accessed); |
+ TestLoadTimingNetworkRequest(load_timing_info); |
} |
TEST(HttpCache, SimpleGET_LoadValidateCache_Implicit) { |
@@ -1866,13 +1985,17 @@ |
EXPECT_EQ(0, cache.disk_cache()->open_count()); |
EXPECT_EQ(1, cache.disk_cache()->create_count()); |
- // get the same URL again, but this time we expect it to result |
+ // Get the same URL again, but this time we expect it to result |
gavinp
2013/05/10 20:23:03
Awesome!
mmenke
2013/05/10 20:44:00
The fact that I capitalized Get, or the sheer numb
|
// in a conditional request. |
- RunTransactionTest(cache.http_cache(), kTypicalGET_Transaction); |
+ net::CapturingBoundNetLog log; |
+ net::LoadTimingInfo load_timing_info; |
+ RunTransactionTestAndGetTiming(cache.http_cache(), kTypicalGET_Transaction, |
+ log.bound(), &load_timing_info); |
EXPECT_EQ(2, cache.network_layer()->transaction_count()); |
EXPECT_EQ(1, cache.disk_cache()->open_count()); |
EXPECT_EQ(1, cache.disk_cache()->create_count()); |
+ TestLoadTimingNetworkRequest(load_timing_info); |
} |
static void ETagGet_ConditionalRequest_Handler( |
@@ -1899,15 +2022,19 @@ |
EXPECT_EQ(0, cache.disk_cache()->open_count()); |
EXPECT_EQ(1, cache.disk_cache()->create_count()); |
- // get the same URL again, but this time we expect it to result |
+ // Get the same URL again, but this time we expect it to result |
// in a conditional request. |
transaction.load_flags = net::LOAD_VALIDATE_CACHE; |
transaction.handler = ETagGet_ConditionalRequest_Handler; |
- RunTransactionTest(cache.http_cache(), transaction); |
+ net::CapturingBoundNetLog log; |
+ net::LoadTimingInfo load_timing_info; |
+ RunTransactionTestAndGetTiming(cache.http_cache(), transaction, log.bound(), |
+ &load_timing_info); |
EXPECT_EQ(2, cache.network_layer()->transaction_count()); |
EXPECT_EQ(1, cache.disk_cache()->open_count()); |
EXPECT_EQ(1, cache.disk_cache()->create_count()); |
+ TestLoadTimingNetworkRequest(load_timing_info); |
} |
class RevalidationServer { |
@@ -1974,13 +2101,17 @@ |
// Read from the cache. |
RevalidationServer server; |
transaction.handler = server.Handler; |
- RunTransactionTest(cache.http_cache(), transaction); |
+ net::CapturingBoundNetLog log; |
+ net::LoadTimingInfo load_timing_info; |
+ RunTransactionTestAndGetTiming(cache.http_cache(), transaction, log.bound(), |
+ &load_timing_info); |
EXPECT_TRUE(server.EtagUsed()); |
EXPECT_TRUE(server.LastModifiedUsed()); |
EXPECT_EQ(2, cache.network_layer()->transaction_count()); |
EXPECT_EQ(1, cache.disk_cache()->open_count()); |
EXPECT_EQ(1, cache.disk_cache()->create_count()); |
+ TestLoadTimingNetworkRequest(load_timing_info); |
RemoveMockTransaction(&transaction); |
} |
@@ -2004,13 +2135,17 @@ |
RevalidationServer server; |
transaction.handler = server.Handler; |
transaction.request_headers = "Foo: none\r\n"; |
- RunTransactionTest(cache.http_cache(), transaction); |
+ net::CapturingBoundNetLog log; |
+ net::LoadTimingInfo load_timing_info; |
+ RunTransactionTestAndGetTiming(cache.http_cache(), transaction, log.bound(), |
+ &load_timing_info); |
EXPECT_TRUE(server.EtagUsed()); |
EXPECT_FALSE(server.LastModifiedUsed()); |
EXPECT_EQ(2, cache.network_layer()->transaction_count()); |
EXPECT_EQ(1, cache.disk_cache()->open_count()); |
EXPECT_EQ(1, cache.disk_cache()->create_count()); |
+ TestLoadTimingNetworkRequest(load_timing_info); |
RemoveMockTransaction(&transaction); |
} |
@@ -2033,13 +2168,17 @@ |
RevalidationServer server; |
transaction.handler = server.Handler; |
transaction.request_headers = "Foo: none\r\n"; |
- RunTransactionTest(cache.http_cache(), transaction); |
+ net::CapturingBoundNetLog log; |
+ net::LoadTimingInfo load_timing_info; |
+ RunTransactionTestAndGetTiming(cache.http_cache(), transaction, log.bound(), |
+ &load_timing_info); |
EXPECT_FALSE(server.EtagUsed()); |
EXPECT_FALSE(server.LastModifiedUsed()); |
EXPECT_EQ(2, cache.network_layer()->transaction_count()); |
EXPECT_EQ(1, cache.disk_cache()->open_count()); |
EXPECT_EQ(1, cache.disk_cache()->create_count()); |
+ TestLoadTimingNetworkRequest(load_timing_info); |
RemoveMockTransaction(&transaction); |
} |
@@ -3240,12 +3379,18 @@ |
// Write and read from the cache (20-59). |
transaction.request_headers = "Range: bytes = 20-59\r\n" EXTRA_HEADER; |
transaction.data = "rg: 20-29 rg: 30-39 rg: 40-49 rg: 50-59 "; |
- RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); |
+ net::CapturingBoundNetLog log; |
+ net::LoadTimingInfo load_timing_info; |
+ RunTransactionTestWithResponseAndGetTiming( |
+ cache.http_cache(), transaction, &headers, log.bound(), |
+ &load_timing_info); |
Verify206Response(headers, 20, 59); |
+ |
EXPECT_EQ(4, cache.network_layer()->transaction_count()); |
EXPECT_EQ(3, cache.disk_cache()->open_count()); |
EXPECT_EQ(1, cache.disk_cache()->create_count()); |
+ TestLoadTimingNetworkRequest(load_timing_info); |
RemoveMockTransaction(&kRangeGET_TransactionOK); |
} |
@@ -3295,12 +3440,17 @@ |
// Write and read from the cache (20-59). |
transaction.request_headers = "Range: bytes = 20-59\r\n" EXTRA_HEADER; |
transaction.data = "rg: 20-29 rg: 30-39 rg: 40-49 rg: 50-59 "; |
- RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); |
+ net::CapturingBoundNetLog log; |
+ net::LoadTimingInfo load_timing_info; |
+ RunTransactionTestWithResponseAndGetTiming( |
+ cache.http_cache(), transaction, &headers, log.bound(), |
+ &load_timing_info); |
Verify206Response(headers, 20, 59); |
EXPECT_EQ(4, cache.network_layer()->transaction_count()); |
EXPECT_EQ(2, cache.disk_cache()->open_count()); |
EXPECT_EQ(1, cache.disk_cache()->create_count()); |
+ TestLoadTimingNetworkRequest(load_timing_info); |
RemoveMockTransaction(&transaction); |
} |
@@ -3327,21 +3477,29 @@ |
EXPECT_EQ(1, cache.disk_cache()->create_count()); |
// Read from the cache (40-49). |
- RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); |
+ net::CapturingBoundNetLog log; |
+ net::LoadTimingInfo load_timing_info; |
+ RunTransactionTestWithResponseAndGetTiming( |
+ cache.http_cache(), transaction, &headers, log.bound(), |
+ &load_timing_info); |
+ |
Verify206Response(headers, 40, 49); |
- |
EXPECT_EQ(1, cache.network_layer()->transaction_count()); |
EXPECT_EQ(1, cache.disk_cache()->open_count()); |
EXPECT_EQ(1, cache.disk_cache()->create_count()); |
+ TestLoadTimingCachedResponse(load_timing_info); |
// Read again forcing the revalidation. |
transaction.load_flags |= net::LOAD_VALIDATE_CACHE; |
- RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); |
+ RunTransactionTestWithResponseAndGetTiming( |
+ cache.http_cache(), transaction, &headers, log.bound(), |
+ &load_timing_info); |
Verify206Response(headers, 40, 49); |
EXPECT_EQ(2, cache.network_layer()->transaction_count()); |
EXPECT_EQ(1, cache.disk_cache()->open_count()); |
EXPECT_EQ(1, cache.disk_cache()->create_count()); |
+ TestLoadTimingNetworkRequest(load_timing_info); |
RemoveMockTransaction(&transaction); |
} |
@@ -3576,27 +3734,35 @@ |
MockHttpCache cache; |
AddMockTransaction(&kRangeGET_TransactionOK); |
std::string headers; |
+ net::CapturingBoundNetLog log; |
+ net::LoadTimingInfo load_timing_info; |
// Write to the cache (40-49). |
- RunTransactionTestWithResponse(cache.http_cache(), kRangeGET_TransactionOK, |
- &headers); |
+ RunTransactionTestWithResponseAndGetTiming( |
+ cache.http_cache(), kRangeGET_TransactionOK, &headers, log.bound(), |
+ &load_timing_info); |
Verify206Response(headers, 40, 49); |
+ |
EXPECT_EQ(1, cache.network_layer()->transaction_count()); |
EXPECT_EQ(0, cache.disk_cache()->open_count()); |
EXPECT_EQ(1, cache.disk_cache()->create_count()); |
+ TestLoadTimingNetworkRequest(load_timing_info); |
// Write and read from the cache (0-79), when not asked for a range. |
MockTransaction transaction(kRangeGET_TransactionOK); |
transaction.request_headers = EXTRA_HEADER; |
transaction.data = "rg: 00-09 rg: 10-19 rg: 20-29 rg: 30-39 rg: 40-49 " |
"rg: 50-59 rg: 60-69 rg: 70-79 "; |
- RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); |
+ RunTransactionTestWithResponseAndGetTiming( |
+ cache.http_cache(), transaction, &headers, log.bound(), |
+ &load_timing_info); |
EXPECT_EQ(0U, headers.find("HTTP/1.1 200 OK\n")); |
EXPECT_EQ(3, cache.network_layer()->transaction_count()); |
EXPECT_EQ(1, cache.disk_cache()->open_count()); |
EXPECT_EQ(1, cache.disk_cache()->create_count()); |
+ TestLoadTimingNetworkRequest(load_timing_info); |
RemoveMockTransaction(&kRangeGET_TransactionOK); |
} |
@@ -3609,34 +3775,46 @@ |
MockTransaction transaction(kRangeGET_TransactionOK); |
AddMockTransaction(&transaction); |
std::string headers; |
+ net::CapturingBoundNetLog log; |
+ net::LoadTimingInfo load_timing_info; |
// Write to the cache (0-9). |
transaction.request_headers = "Range: bytes = 0-9\r\n" EXTRA_HEADER; |
transaction.data = "rg: 00-09 "; |
- RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); |
+ RunTransactionTestWithResponseAndGetTiming( |
+ cache.http_cache(), transaction, &headers, log.bound(), |
+ &load_timing_info); |
Verify206Response(headers, 0, 9); |
+ TestLoadTimingNetworkRequest(load_timing_info); |
// Write to the cache (70-79). |
transaction.request_headers = "Range: bytes = 70-79\r\n" EXTRA_HEADER; |
transaction.data = "rg: 70-79 "; |
- RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); |
+ RunTransactionTestWithResponseAndGetTiming( |
+ cache.http_cache(), transaction, &headers, log.bound(), |
+ &load_timing_info); |
Verify206Response(headers, 70, 79); |
EXPECT_EQ(2, cache.network_layer()->transaction_count()); |
EXPECT_EQ(1, cache.disk_cache()->open_count()); |
EXPECT_EQ(1, cache.disk_cache()->create_count()); |
+ TestLoadTimingNetworkRequest(load_timing_info); |
// Read from the cache (0-9), write and read from cache (10 - 79). |
transaction.load_flags |= net::LOAD_VALIDATE_CACHE; |
transaction.request_headers = "Foo: bar\r\n" EXTRA_HEADER; |
transaction.data = "rg: 00-09 rg: 10-19 rg: 20-29 rg: 30-39 rg: 40-49 " |
- "rg: 50-59 rg: 60-69 rg: 70-79 "; |
- RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); |
+ "rg: 50-59 rg: 60-69 rg: 70-79 "; |
+ RunTransactionTestWithResponseAndGetTiming( |
+ cache.http_cache(), transaction, &headers, log.bound(), |
+ &load_timing_info); |
EXPECT_EQ(0U, headers.find("HTTP/1.1 200 OK\n")); |
+ |
EXPECT_EQ(4, cache.network_layer()->transaction_count()); |
EXPECT_EQ(2, cache.disk_cache()->open_count()); |
EXPECT_EQ(1, cache.disk_cache()->create_count()); |
+ TestLoadTimingNetworkRequest(load_timing_info); |
RemoveMockTransaction(&transaction); |
} |
@@ -3669,12 +3847,17 @@ |
transaction2.data = "Not a range"; |
RangeTransactionServer handler; |
handler.set_modified(true); |
- RunTransactionTestWithResponse(cache.http_cache(), transaction2, &headers); |
+ net::CapturingBoundNetLog log; |
+ net::LoadTimingInfo load_timing_info; |
+ RunTransactionTestWithResponseAndGetTiming( |
+ cache.http_cache(), transaction2, &headers, log.bound(), |
+ &load_timing_info); |
EXPECT_EQ(0U, headers.find("HTTP/1.1 200 OK\n")); |
EXPECT_EQ(3, cache.network_layer()->transaction_count()); |
EXPECT_EQ(1, cache.disk_cache()->open_count()); |
EXPECT_EQ(1, cache.disk_cache()->create_count()); |
+ TestLoadTimingNetworkRequest(load_timing_info); |
// Verify that the previous request deleted the entry. |
RunTransactionTest(cache.http_cache(), transaction); |
@@ -3712,8 +3895,11 @@ |
// Now see that we don't use the stored entry. |
std::string headers; |
- RunTransactionTestWithResponse(cache.http_cache(), kSimpleGET_Transaction, |
- &headers); |
+ net::CapturingBoundNetLog log; |
+ net::LoadTimingInfo load_timing_info; |
+ RunTransactionTestWithResponseAndGetTiming( |
+ cache.http_cache(), kSimpleGET_Transaction, &headers, log.bound(), |
+ &load_timing_info); |
// We are expecting a 200. |
std::string expected_headers(kSimpleGET_Transaction.status); |
@@ -3723,6 +3909,7 @@ |
EXPECT_EQ(1, cache.network_layer()->transaction_count()); |
EXPECT_EQ(1, cache.disk_cache()->open_count()); |
EXPECT_EQ(2, cache.disk_cache()->create_count()); |
+ TestLoadTimingNetworkRequest(load_timing_info); |
} |
// Tests that we can handle cached 206 responses that are not sparse. This time |