Lines Matching full:cache
177 explicit DeleteCacheCompletionCallback(std::unique_ptr<MockHttpCache> cache) in DeleteCacheCompletionCallback() argument
178 : cache_(std::move(cache)) {} in DeleteCacheCompletionCallback()
222 void RunTransactionTestBase(HttpCache* cache, in RunTransactionTestBase() argument
233 // write to the cache in RunTransactionTestBase()
236 int rv = cache->CreateTransaction(DEFAULT_PRIORITY, &trans); in RunTransactionTestBase()
273 void RunTransactionTestWithRequest(HttpCache* cache, in RunTransactionTestWithRequest() argument
277 RunTransactionTestBase(cache, trans_info, request, response_info, in RunTransactionTestWithRequest()
282 void RunTransactionTestAndGetTiming(HttpCache* cache, in RunTransactionTestAndGetTiming() argument
286 RunTransactionTestBase(cache, trans_info, MockHttpRequest(trans_info), in RunTransactionTestAndGetTiming()
292 HttpCache* cache, in RunTransactionTestAndGetTimingAndConnectedSocketAddress() argument
297 RunTransactionTestBase(cache, trans_info, MockHttpRequest(trans_info), in RunTransactionTestAndGetTimingAndConnectedSocketAddress()
302 void RunTransactionTest(HttpCache* cache, const MockTransaction& trans_info) { in RunTransactionTest() argument
303 RunTransactionTestAndGetTiming(cache, trans_info, NetLogWithSource(), in RunTransactionTest()
307 void RunTransactionTestWithLog(HttpCache* cache, in RunTransactionTestWithLog() argument
310 RunTransactionTestAndGetTiming(cache, trans_info, log, nullptr); in RunTransactionTestWithLog()
313 void RunTransactionTestWithResponseInfo(HttpCache* cache, in RunTransactionTestWithResponseInfo() argument
316 RunTransactionTestWithRequest(cache, trans_info, MockHttpRequest(trans_info), in RunTransactionTestWithResponseInfo()
321 HttpCache* cache, in RunTransactionTestWithResponseInfoAndGetTiming() argument
326 RunTransactionTestBase(cache, trans_info, MockHttpRequest(trans_info), in RunTransactionTestWithResponseInfoAndGetTiming()
331 void RunTransactionTestWithResponse(HttpCache* cache, in RunTransactionTestWithResponse() argument
335 RunTransactionTestWithResponseInfo(cache, trans_info, &response); in RunTransactionTestWithResponse()
340 HttpCache* cache, in RunTransactionTestWithResponseAndGetTiming() argument
346 RunTransactionTestBase(cache, trans_info, MockHttpRequest(trans_info), in RunTransactionTestWithResponseAndGetTiming()
372 *response_headers = "Cache-Control: no-store\n"; in FastNoStoreHandler()
388 "Cache-Control: max-age=10000\n",
632 void CreateTruncatedEntry(std::string raw_headers, MockHttpCache* cache) { in CreateTruncatedEntry() argument
633 // Create a disk cache entry that stores an incomplete resource. in CreateTruncatedEntry()
636 ASSERT_TRUE(cache->CreateBackendEntry(request.CacheKey(), &entry, nullptr)); in CreateTruncatedEntry()
657 void VerifyTruncatedFlag(MockHttpCache* cache, in VerifyTruncatedFlag() argument
662 ASSERT_TRUE(cache->OpenBackendEntry(key, &entry)); in VerifyTruncatedFlag()
741 // Gets the entries from |net_log| created by the cache layer and asserted on in
774 // Helper function, generating valid HTTP cache key from `url`.
793 int OpenEntry(HttpCache* cache, in OpenEntry() argument
797 return cache->OpenEntry(GenerateCacheKey(url), entry, trans); in OpenEntry()
800 int OpenOrCreateEntry(HttpCache* cache, in OpenOrCreateEntry() argument
804 return cache->OpenOrCreateEntry(GenerateCacheKey(url), entry, trans); in OpenOrCreateEntry()
807 int CreateEntry(HttpCache* cache, in CreateEntry() argument
811 return cache->CreateEntry(GenerateCacheKey(url), entry, trans); in CreateEntry()
814 int DoomEntry(HttpCache* cache, in DoomEntry() argument
817 return cache->DoomEntry(GenerateCacheKey(url), trans); in DoomEntry()
820 void DeactivateEntry(HttpCache* cache, ActiveEntry* entry) { in DeactivateEntry() argument
821 cache->DeactivateEntry(entry); in DeactivateEntry()
839 MockHttpCache cache; in ComputeCacheKey() local
840 return *cache.http_cache()->GenerateCacheKeyForRequest(&request_info); in ComputeCacheKey()
848 MockHttpCache cache; in TEST_F() local
851 EXPECT_THAT(cache.CreateTransaction(&trans), IsOk()); in TEST_F()
856 MockHttpCache cache(HttpCache::DefaultBackend::InMemory(0)); in TEST_F() local
861 int rv = cache.http_cache()->GetBackend(&backend, cb.callback()); in TEST_F()
866 MockHttpCache cache; in TEST_F() local
869 // Write to the cache. in TEST_F()
870 RunTransactionTestAndGetTiming(cache.http_cache(), kSimpleGET_Transaction, in TEST_F()
874 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
875 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
876 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
881 // called once for simple GET calls that traverse the cache.
883 MockHttpCache cache; in TEST_F() local
892 EXPECT_THAT(cache.CreateTransaction(&transaction), IsOk()); in TEST_F()
909 MockHttpCache cache; in TEST_F() local
914 EXPECT_THAT(cache.CreateTransaction(&transaction), IsOk()); in TEST_F()
930 // called once for requests that hit the cache.
932 MockHttpCache cache; in TEST_F() local
935 // Populate the cache. in TEST_F()
938 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
942 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
944 // Load from the cache (only), observe the callback being called. in TEST_F()
950 EXPECT_THAT(cache.CreateTransaction(&transaction), IsOk()); in TEST_F()
963 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
970 // is called for a request that hit the cache and returns an error, the cache
973 MockHttpCache cache; in TEST_F() local
976 // Populate the cache. in TEST_F()
979 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
985 // Attempt to read from cache entry, but abort transaction due to a in TEST_F()
991 EXPECT_THAT(cache.CreateTransaction(&transaction), IsOk()); in TEST_F()
1002 // Used the cache entry only. in TEST_F()
1008 // Request the same resource once more, observe that it is read from cache. in TEST_F()
1012 EXPECT_THAT(cache.CreateTransaction(&transaction), IsOk()); in TEST_F()
1023 // Used the cache entry only. in TEST_F()
1030 // returns `ERR_INCONSISTENT_IP_ADDRESS_SPACE`, the cache entry is invalidated.
1033 MockHttpCache cache; in TEST_F() local
1038 // Populate the cache. in TEST_F()
1039 RunTransactionTest(cache.http_cache(), mock_transaction); in TEST_F()
1044 // Attempt to read from cache entry, but abort transaction due to a in TEST_F()
1050 EXPECT_THAT(cache.CreateTransaction(&transaction), IsOk()); in TEST_F()
1062 // Used the cache entry only. in TEST_F()
1069 // cache. in TEST_F()
1073 EXPECT_THAT(cache.CreateTransaction(&transaction), IsOk()); in TEST_F()
1093 // cache entry is invalidated, and we'll retry the connection from the network.
1097 MockHttpCache cache; in TEST_F() local
1102 // Populate the cache. in TEST_F()
1103 RunTransactionTest(cache.http_cache(), mock_transaction); in TEST_F()
1108 // Attempt to read from cache entry, but abort transaction due to a in TEST_F()
1115 EXPECT_THAT(cache.CreateTransaction(&transaction), IsOk()); in TEST_F()
1129 // Used the cache entry only. in TEST_F()
1136 // cache. in TEST_F()
1140 EXPECT_THAT(cache.CreateTransaction(&transaction), IsOk()); in TEST_F()
1161 MockHttpCache cache; in TEST_F() local
1167 // Populate the cache. in TEST_F()
1170 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
1174 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
1176 // Load from the cache (only), observe the callback being called. in TEST_F()
1182 EXPECT_THAT(cache.CreateTransaction(&transaction), IsOk()); in TEST_F()
1195 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
1197 // The transport info mentions both the cache and the original proxy. in TEST_F()
1260 MockHttpCache cache; in TEST_P() local
1270 // Attempt to populate the cache. in TEST_P()
1271 RunTransactionTestWithRequest(cache.http_cache(), transaction, request, in TEST_P()
1278 RunTransactionTestWithRequest(cache.http_cache(), transaction, request, in TEST_P()
1328 MockHttpCache cache; in TEST_F() local
1330 cache.disk_cache()->set_fail_requests(true); in TEST_F()
1335 // Read from the network, and don't use the cache. in TEST_F()
1336 RunTransactionTestAndGetTiming(cache.http_cache(), kSimpleGET_Transaction, in TEST_F()
1354 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
1355 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
1356 EXPECT_EQ(0, cache.disk_cache()->create_count()); in TEST_F()
1361 // This will initialize a cache object with NULL backend. in TEST_F()
1365 MockHttpCache cache(std::move(factory)); in TEST_F() local
1367 // Read from the network, and don't use the cache. in TEST_F()
1368 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
1370 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
1371 EXPECT_FALSE(cache.http_cache()->GetCurrentBackend()); in TEST_F()
1376 MockHttpCache cache; in TEST_F() local
1378 // Write to the cache. in TEST_F()
1379 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
1383 ASSERT_THAT(cache.CreateTransaction(&trans), IsOk()); in TEST_F()
1397 MockHttpCache cache; in TEST_F() local
1399 cache.disk_cache()->set_soft_failures_mask(MockDiskEntry::FAIL_ALL); in TEST_F()
1401 // Read from the network, and fail to write to the cache. in TEST_F()
1402 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
1404 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
1405 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
1406 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
1408 // This one should see an empty cache again. in TEST_F()
1409 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
1411 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
1412 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
1413 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
1419 MockHttpCache cache; in TEST_F() local
1424 int rv = cache.CreateTransaction(&c->trans); in TEST_F()
1432 cache.disk_cache()->set_soft_failures_mask(MockDiskEntry::FAIL_ALL); in TEST_F()
1436 ASSERT_TRUE(cache.OpenBackendEntry(request.CacheKey(), &en)); in TEST_F()
1442 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
1443 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
1444 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
1446 // This one should see an empty cache again. in TEST_F()
1447 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
1449 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
1450 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
1451 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
1454 // Tests that we handle failures to read from the cache.
1456 MockHttpCache cache; in TEST_F() local
1458 // Read from the network, and write to the cache. in TEST_F()
1459 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
1461 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
1462 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
1463 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
1465 cache.disk_cache()->set_soft_failures_mask(MockDiskEntry::FAIL_ALL); in TEST_F()
1469 // Now fail to read from the cache. in TEST_F()
1471 int rv = cache.CreateTransaction(&c->trans); in TEST_F()
1477 // Now verify that the entry was removed from the cache. in TEST_F()
1478 cache.disk_cache()->set_soft_failures_mask(0); in TEST_F()
1480 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
1481 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
1482 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
1484 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
1486 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
1487 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
1488 EXPECT_EQ(3, cache.disk_cache()->create_count()); in TEST_F()
1492 MockHttpCache cache; in TEST_F() local
1499 // Write to the cache. in TEST_F()
1500 RunTransactionTestAndGetTiming(cache.http_cache(), kSimpleGET_Transaction, in TEST_F()
1522 // Force this transaction to read from the cache. in TEST_F()
1528 RunTransactionTestAndGetTiming(cache.http_cache(), transaction, in TEST_F()
1552 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
1553 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
1554 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
1559 MockHttpCache cache; in TEST_F() local
1561 // force this transaction to read from the cache in TEST_F()
1569 ASSERT_THAT(cache.CreateTransaction(&trans), IsOk()); in TEST_F()
1578 EXPECT_EQ(0, cache.network_layer()->transaction_count()); in TEST_F()
1579 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
1580 EXPECT_EQ(0, cache.disk_cache()->create_count()); in TEST_F()
1584 MockHttpCache cache; in TEST_F() local
1586 // write to the cache in TEST_F()
1587 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
1589 // force this transaction to read from the cache if valid in TEST_F()
1593 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
1595 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
1596 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
1597 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
1601 MockHttpCache cache; in TEST_F() local
1603 // force this transaction to read from the cache if valid in TEST_F()
1607 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
1609 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
1610 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
1611 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
1616 MockHttpCache cache; in TEST_F() local
1618 // Write to the cache. in TEST_F()
1621 transaction.response_headers = "Cache-Control: max-age=10000\n" in TEST_F()
1624 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
1626 // Read from the cache. in TEST_F()
1628 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
1630 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
1631 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
1632 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
1638 MockHttpCache cache; in TEST_F() local
1640 // Write to the cache. in TEST_F()
1643 transaction.response_headers = "Cache-Control: max-age=10000\n" in TEST_F()
1646 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
1648 // Attempt to read from the cache... this is a vary mismatch that must reach in TEST_F()
1653 RunTransactionTestAndGetTiming(cache.http_cache(), transaction, in TEST_F()
1657 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
1658 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
1659 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
1666 MockHttpCache cache; in TEST_F() local
1668 // Write to the cache. in TEST_F()
1671 "Cache-Control: max-age=10000\n" in TEST_F()
1674 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
1676 // Attempt to read from the cache... we will still load it from network, in TEST_F()
1680 RunTransactionTestAndGetTiming(cache.http_cache(), transaction, in TEST_F()
1684 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
1685 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
1686 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
1694 MockHttpCache cache; in TEST_F() local
1695 cache.disk_cache()->set_support_in_memory_entry_data(use_memory_entry_data); in TEST_F()
1697 // Prime cache. in TEST_F()
1699 transaction.response_headers = "Cache-Control: no-cache\n"; in TEST_F()
1702 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
1703 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
1704 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
1705 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
1715 int rv = cache.http_cache()->CreateTransaction(DEFAULT_PRIORITY, &trans); in TEST_F()
1725 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
1728 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
1729 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
1732 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
1733 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
1744 MockHttpCache cache; in TEST_F() local
1745 cache.disk_cache()->set_support_in_memory_entry_data(true); in TEST_F()
1748 // Prime cache. in TEST_F()
1750 transaction.response_headers = "Cache-Control: no-cache\n"; in TEST_F()
1751 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
1752 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
1753 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
1754 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
1762 int rv = cache.http_cache()->CreateTransaction(DEFAULT_PRIORITY, &trans); in TEST_F()
1771 // Confirm if we have an empty cache, a read is marked as network verified.
1773 MockHttpCache cache; in TEST_F() local
1775 // write to the cache in TEST_F()
1777 RunTransactionTestWithResponseInfo(cache.http_cache(), kSimpleGET_Transaction, in TEST_F()
1780 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
1781 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
1782 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
1788 // Confirm if we have a fresh entry in cache, it isn't marked as
1791 MockHttpCache cache; in TEST_F() local
1793 // Prime cache. in TEST_F()
1796 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
1797 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
1798 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
1802 RunTransactionTestWithResponseInfo(cache.http_cache(), transaction, in TEST_F()
1805 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
1811 MockHttpCache cache; in TEST_F() local
1813 // Write to the cache. in TEST_F()
1814 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
1816 // Force this transaction to write to the cache again. in TEST_F()
1823 // Write to the cache. in TEST_F()
1824 RunTransactionTestAndGetTiming(cache.http_cache(), transaction, in TEST_F()
1849 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
1850 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
1851 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
1856 MockHttpCache cache; in TEST_F() local
1858 // write to the cache in TEST_F()
1859 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
1861 // force this transaction to write to the cache again in TEST_F()
1863 transaction.request_headers = "pragma: no-cache\r\n"; in TEST_F()
1865 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
1867 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
1868 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
1869 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
1873 MockHttpCache cache; in TEST_F() local
1875 // write to the cache in TEST_F()
1876 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
1878 // force this transaction to write to the cache again in TEST_F()
1880 transaction.request_headers = "cache-control: no-cache\r\n"; in TEST_F()
1882 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
1884 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
1885 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
1886 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
1890 MockHttpCache cache; in TEST_F() local
1892 // Write to the cache. in TEST_F()
1893 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
1895 // Read from the cache. in TEST_F()
1896 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
1898 // Force this transaction to validate the cache. in TEST_F()
1905 cache.http_cache(), transaction, &response_info, in TEST_F()
1908 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
1909 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
1910 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
1916 MockHttpCache cache; in TEST_F() local
1918 // write to the cache in TEST_F()
1919 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
1921 // read from the cache in TEST_F()
1922 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
1924 // force this transaction to validate the cache in TEST_F()
1926 transaction.request_headers = "cache-control: max-age=0\r\n"; in TEST_F()
1928 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
1930 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
1931 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
1932 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
1938 MockHttpCache cache; in TEST_F() local
1943 cache.http_cache(), kSimpleGET_Transaction, &response_info, in TEST_F()
1952 cache.http_cache(), prefetch_transaction, &response_info, in TEST_F()
1959 cache.http_cache(), prefetch_transaction, &response_info, in TEST_F()
1966 cache.http_cache(), kSimpleGET_Transaction, &response_info, in TEST_F()
1973 cache.http_cache(), kSimpleGET_Transaction, &response_info, in TEST_F()
1984 MockHttpCache cache; in TEST_F() local
1989 cache.http_cache(), kTypicalGET_Transaction, &response_info, in TEST_F()
2000 cache.http_cache(), prefetch_transaction, &response_info, in TEST_F()
2014 cache.http_cache(), can_use_restricted_prefetch_transaction, in TEST_F()
2022 cache.http_cache(), kSimpleGET_Transaction, &response_info, in TEST_F()
2030 MockHttpCache cache; in TEST_F() local
2038 cache.http_cache(), prefetch_transaction, &response_info, in TEST_F()
2048 cache.http_cache(), kSimpleGET_Transaction, &response_info, in TEST_F()
2055 // can use the entry in the cache now, since it has been evicted in favor of in TEST_F()
2058 cache.http_cache(), kSimpleGET_Transaction, &response_info, in TEST_F()
2066 MockHttpCache cache; in TEST_F() local
2073 cache.http_cache(), prefetch_transaction, &response_info, in TEST_F()
2079 cache.disk_cache()->set_soft_failures_mask(MockDiskEntry::FAIL_WRITE); in TEST_F()
2081 cache.http_cache(), kSimpleGET_Transaction, &response_info, in TEST_F()
2088 MockHttpCache cache; in TEST_F() local
2103 int rv = cache.CreateTransaction(&c.trans); in TEST_F()
2121 VerifyTruncatedFlag(&cache, request.CacheKey(), /*flag_value=*/true, in TEST_F()
2131 int rv = cache.CreateTransaction(&c.trans); in TEST_F()
2145 VerifyTruncatedFlag(&cache, request.CacheKey(), /*flag_value=*/true, in TEST_F()
2152 RunTransactionTestWithRequest(cache.http_cache(), transaction, request, in TEST_F()
2156 VerifyTruncatedFlag(&cache, request.CacheKey(), /*flag_value=*/false, in TEST_F()
2165 MockHttpCache cache; in TEST_F() local
2171 "Cache-Control: max-age=0, stale-while-revalidate=60\n" in TEST_F()
2181 int rv = cache.CreateTransaction(&c.trans); in TEST_F()
2199 VerifyTruncatedFlag(&cache, request.CacheKey(), /*flag_value=*/true, in TEST_F()
2208 int rv = cache.CreateTransaction(&c.trans); in TEST_F()
2222 VerifyTruncatedFlag(&cache, request.CacheKey(), /*flag_value=*/true, in TEST_F()
2229 RunTransactionTestWithRequest(cache.http_cache(), transaction, request, in TEST_F()
2233 VerifyTruncatedFlag(&cache, request.CacheKey(), /*flag_value=*/false, in TEST_F()
2248 MockHttpCache cache; in TEST_F() local
2249 cache.disk_cache()->set_support_in_memory_entry_data(use_memory_entry_data); in TEST_F()
2254 transaction.response_headers = "Cache-Control: max-age=0\n"; in TEST_F()
2258 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
2259 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
2261 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
2266 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
2267 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
2269 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
2270 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
2279 MockHttpCache cache; in TEST_F() local
2282 cache.disk_cache()->set_support_in_memory_entry_data(use_memory_entry_data); in TEST_F()
2284 // Write to the cache. in TEST_F()
2285 RunTransactionTest(cache.http_cache(), kETagGET_Transaction); in TEST_F()
2292 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
2294 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
2295 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
2296 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
2302 MockHttpCache cache; in TEST_F() local
2313 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
2331 EXPECT_EQ(kNumTransactions, cache.GetCountWriterTransactions(cache_key)); in TEST_F()
2333 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
2334 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
2335 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
2350 EXPECT_FALSE(cache.IsWriterPresent(cache_key)); in TEST_F()
2351 EXPECT_EQ(kNumTransactions - i, cache.GetCountReaders(cache_key)); in TEST_F()
2358 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
2359 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
2360 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
2364 MockHttpCache cache; in TEST_F() local
2374 RunTransactionTestWithRequest(cache.http_cache(), transaction_pre, in TEST_F()
2378 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
2379 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
2380 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
2396 RunTransactionTestWithRequest(cache.http_cache(), transaction_all, in TEST_F()
2401 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
2402 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
2403 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
2411 MockHttpCache cache; in TEST_F() local
2420 RunTransactionTestWithRequest(cache.http_cache(), transaction_pre, in TEST_F()
2424 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
2425 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
2426 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
2432 // cache and during validation it fails conditionalization. in TEST_F()
2433 cache.FailConditionalizations(); in TEST_F()
2442 RunTransactionTestWithRequest(cache.http_cache(), transaction_pre, in TEST_F()
2445 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
2446 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
2447 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
2452 MockHttpCache cache; in TEST_F() local
2462 RunTransactionTestWithRequest(cache.http_cache(), transaction_pre, in TEST_F()
2466 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
2467 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
2468 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
2482 RunTransactionTestWithRequest(cache.http_cache(), transaction_all, in TEST_F()
2487 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
2488 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
2489 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
2502 RunTransactionTestWithRequest(cache.http_cache(), transaction_all2, in TEST_F()
2507 // Only one more cache open, no new network traffic. in TEST_F()
2508 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
2509 EXPECT_EQ(2, cache.disk_cache()->open_count()); in TEST_F()
2510 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
2514 // This test verifies that the ConnectedCallback passed to a cache transaction
2516 // cache hit.
2518 MockHttpCache cache; in TEST_F() local
2520 // Request an infix range and populate the cache with it. in TEST_F()
2527 RunTransactionTest(cache.http_cache(), mock_transaction); in TEST_F()
2531 // per subrange, as split up by cache hits. in TEST_F()
2542 EXPECT_THAT(cache.CreateTransaction(&transaction), IsOk()); in TEST_F()
2576 // This test verifies that when the ConnectedCallback passed to a cache range
2578 // partial read from cache, then the cache entry is invalidated.
2580 MockHttpCache cache; in TEST_F() local
2582 // Request an infix range and populate the cache with it. in TEST_F()
2589 RunTransactionTest(cache.http_cache(), mock_transaction); in TEST_F()
2601 // 2. for the cached infix: from the cache in TEST_F()
2605 // the transaction fails partway and 3) is never created. The cache entry is in TEST_F()
2611 EXPECT_THAT(cache.CreateTransaction(&transaction), IsOk()); in TEST_F()
2638 // Request the same range again, observe that nothing is read from cache. in TEST_F()
2643 EXPECT_THAT(cache.CreateTransaction(&transaction), IsOk()); in TEST_F()
2660 // the cache entry was doomed during the last transaction so they are not in TEST_F()
2667 // This test verifies that when the ConnectedCallback passed to a cache range
2669 // network transaction, then the cache entry is invalidated.
2672 MockHttpCache cache; in TEST_F() local
2674 // Request a prefix range and populate the cache with it. in TEST_F()
2681 RunTransactionTest(cache.http_cache(), mock_transaction); in TEST_F()
2692 // 1. for the prefix: from the cache in TEST_F()
2698 EXPECT_THAT(cache.CreateTransaction(&transaction), IsOk()); in TEST_F()
2725 // Request the same range again, observe that nothing is read from cache. in TEST_F()
2730 EXPECT_THAT(cache.CreateTransaction(&transaction), IsOk()); in TEST_F()
2747 // the cache entry was doomed during the last transaction so they are not in TEST_F()
2754 // This test verifies that when the ConnectedCallback passed to a cache
2756 // the overall cache transaction fails with that error. The cache entry is still
2759 MockHttpCache cache; in TEST_F() local
2761 // Request an infix range and populate the cache with it. in TEST_F()
2768 RunTransactionTest(cache.http_cache(), mock_transaction); in TEST_F()
2780 // 2. for the cached infix: from the cache in TEST_F()
2785 // cached, such that the cache entry ends up with both the prefix and infix. in TEST_F()
2790 EXPECT_THAT(cache.CreateTransaction(&transaction), IsOk()); in TEST_F()
2820 // read from cache. Only the suffix is fetched from the network. in TEST_F()
2825 EXPECT_THAT(cache.CreateTransaction(&transaction), IsOk()); in TEST_F()
2836 // 1 call for the first range's cache transaction: the first 20 bytes were in TEST_F()
2851 // This test verifies that the ConnectedCallback passed to a cache transaction
2853 // cache hit, even when a prefix of the range is cached.
2855 MockHttpCache cache; in TEST_F() local
2857 // Request a prefix range and populate the cache with it. in TEST_F()
2864 RunTransactionTest(cache.http_cache(), mock_transaction); in TEST_F()
2868 // per subrange, as split up by cache hits. in TEST_F()
2879 EXPECT_THAT(cache.CreateTransaction(&transaction), IsOk()); in TEST_F()
2890 // 1 call for the first range from the cache, reported as coming from the in TEST_F()
2905 // the cache.
2907 MockHttpCache cache; in TEST_F() local
2913 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
2917 cache.disk_cache()->set_fail_requests(true); in TEST_F()
2924 EXPECT_FALSE(cache.IsWriterPresent(kRangeGET_TransactionOK.url)); in TEST_F()
2926 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
2927 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
2928 EXPECT_EQ(0, cache.disk_cache()->create_count()); in TEST_F()
2934 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
2935 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
2936 EXPECT_EQ(0, cache.disk_cache()->create_count()); in TEST_F()
2941 MockHttpCache cache; in TEST_F() local
2953 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
2971 EXPECT_TRUE(cache.IsWriterPresent(request.CacheKey())); in TEST_F()
2979 EXPECT_EQ(5, cache.network_layer()->transaction_count()); in TEST_F()
2980 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
2981 EXPECT_EQ(3, cache.disk_cache()->create_count()); in TEST_F()
2995 EXPECT_EQ(5, cache.network_layer()->transaction_count()); in TEST_F()
2996 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
2997 EXPECT_EQ(3, cache.disk_cache()->create_count()); in TEST_F()
3004 MockHttpCache cache; in TEST_F() local
3022 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
3039 // Continue the transactions. 2nd will pause at the cache reading state and in TEST_F()
3047 first_entry = cache.disk_cache()->GetDiskEntryRef(cache_key); in TEST_F()
3054 second_entry = cache.disk_cache()->GetDiskEntryRef(cache_key); in TEST_F()
3059 // Resume cache read by 1st transaction which will lead to dooming the entry in TEST_F()
3070 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
3071 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
3072 EXPECT_EQ(3, cache.disk_cache()->create_count()); in TEST_F()
3082 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
3083 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
3084 EXPECT_EQ(3, cache.disk_cache()->create_count()); in TEST_F()
3090 MockHttpCache cache; in TEST_F() local
3107 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
3115 cache.disk_cache()->SetDefer(MockDiskEntry::DEFER_CREATE); in TEST_F()
3126 // Continue the transactions. 2nd will pause at the cache reading state and in TEST_F()
3134 first_entry = cache.disk_cache()->GetDiskEntryRef(request.CacheKey()); in TEST_F()
3144 // Resume cache read by 2nd transaction which will lead to dooming the entry in TEST_F()
3151 cache.disk_cache()->ResumeCacheOperation(); in TEST_F()
3159 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
3160 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
3161 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
3171 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
3172 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
3173 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
3178 MockHttpCache cache; in TEST_F() local
3194 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
3202 // Start writing to the cache so that MockDiskEntry::CouldBeSparse() returns in TEST_F()
3222 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
3234 EXPECT_TRUE(cache.IsWriterPresent(cache_key)); in TEST_F()
3235 EXPECT_EQ(1, cache.GetCountDoneHeadersQueue(cache_key)); in TEST_F()
3237 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
3238 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
3239 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
3256 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
3257 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
3258 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
3260 // Fetch from the cache to check that ranges 30-49 have been successfully in TEST_F()
3267 RunTransactionTestWithResponse(cache.http_cache(), range_transaction, in TEST_F()
3272 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
3273 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
3274 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
3281 MockHttpCache cache; in TEST_F() local
3283 // Save a request in the cache so that the next request can become a in TEST_F()
3288 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
3295 context.result = cache.CreateTransaction(&context.trans); in TEST_F()
3301 EXPECT_EQ(1, cache.GetCountReaders(cache_key)); in TEST_F()
3311 range_context.result = cache.CreateTransaction(&range_context.trans); in TEST_F()
3317 EXPECT_EQ(1, cache.GetCountReaders(cache_key)); in TEST_F()
3318 EXPECT_FALSE(cache.IsWriterPresent(cache_key)); in TEST_F()
3319 EXPECT_EQ(1, cache.GetCountDoneHeadersQueue(cache_key)); in TEST_F()
3325 // when there is a cache lock timeout.
3327 MockHttpCache cache; in TEST_F() local
3343 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
3351 // Start writing to the cache so that MockDiskEntry::CouldBeSparse() returns in TEST_F()
3366 // Cache lock timeout will lead to dooming the entry since the transaction may in TEST_F()
3368 cache.SimulateCacheLockTimeoutAfterHeaders(); in TEST_F()
3375 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
3386 EXPECT_EQ(0, cache.GetCountDoneHeadersQueue(request1.CacheKey())); in TEST_F()
3388 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
3389 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
3390 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
3407 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
3408 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
3409 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
3416 MockHttpCache cache; in TEST_F() local
3422 // Remove the cache-control and other headers so that the response cannot be in TEST_F()
3434 // of the response and write in the cache. in TEST_F()
3440 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
3467 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
3479 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
3480 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
3481 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
3502 MockHttpCache cache; in TEST_F() local
3522 // of the response and write in the cache. in TEST_F()
3528 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
3555 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
3566 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
3567 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
3568 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
3586 MockHttpCache cache; in TEST_F() local
3602 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
3610 // Start writing to the cache so that MockDiskEntry::CouldBeSparse() returns in TEST_F()
3630 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
3642 EXPECT_TRUE(cache.IsWriterPresent(cache_key)); in TEST_F()
3643 EXPECT_EQ(1, cache.GetCountDoneHeadersQueue(cache_key)); in TEST_F()
3646 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
3647 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
3648 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
3665 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
3666 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
3667 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
3669 // Fetch from the cache to check that ranges 30-49 have been successfully in TEST_F()
3676 RunTransactionTestWithResponse(cache.http_cache(), range_transaction, in TEST_F()
3681 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
3682 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
3683 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
3689 MockHttpCache cache; in TEST_F() local
3706 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
3714 // Start writing to the cache so that MockDiskEntry::CouldBeSparse() returns in TEST_F()
3734 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
3746 EXPECT_TRUE(cache.IsWriterPresent(cache_key)); in TEST_F()
3747 EXPECT_EQ(1, cache.GetCountDoneHeadersQueue(cache_key)); in TEST_F()
3749 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
3750 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
3751 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
3762 // 30-39 will be read from network, 40-49 from the cache and 50-59 from the in TEST_F()
3764 EXPECT_EQ(4, cache.network_layer()->transaction_count()); in TEST_F()
3765 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
3766 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
3768 // Fetch from the cache to check that ranges 30-49 have been successfully in TEST_F()
3775 RunTransactionTestWithResponse(cache.http_cache(), range_transaction, in TEST_F()
3780 EXPECT_EQ(4, cache.network_layer()->transaction_count()); in TEST_F()
3781 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
3782 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
3790 MockHttpCache cache; in TEST_F() local
3800 // Write to the cache. in TEST_F()
3803 ASSERT_THAT(cache.CreateTransaction(&trans), IsOk()); in TEST_F()
3821 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
3822 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
3823 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
3825 // Active entries in the cache are not retired synchronously. Make in TEST_F()
3830 // Read from the cache. in TEST_F()
3833 ASSERT_THAT(cache.CreateTransaction(&trans), IsOk()); in TEST_F()
3851 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
3852 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
3853 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
3859 ASSERT_THAT(cache.CreateTransaction(&trans), IsOk()); in TEST_F()
3877 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
3879 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
3880 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
3887 MockHttpCache cache; in TEST_F() local
3892 // Create and run the first, successful, transaction to prime the cache. in TEST_F()
3895 c1->result = cache.CreateTransaction(&c1->trans); in TEST_F()
3903 EXPECT_TRUE(cache.IsWriterPresent(request.CacheKey())); in TEST_F()
3904 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
3905 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
3906 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
3912 c2->result = cache.CreateTransaction(&c2->trans); in TEST_F()
3918 // Active Entry that c1 created instead of waiting on the cache to open the in TEST_F()
3922 cache.disk_cache()->set_fail_requests(true); in TEST_F()
3941 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
3942 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
3943 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
3948 MockHttpCache cache; in TEST_F() local
3956 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
3974 EXPECT_TRUE(cache.IsWriterPresent(request.CacheKey())); in TEST_F()
3976 EXPECT_EQ(5, cache.network_layer()->transaction_count()); in TEST_F()
3977 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
3978 EXPECT_EQ(5, cache.disk_cache()->create_count()); in TEST_F()
3992 EXPECT_EQ(5, cache.network_layer()->transaction_count()); in TEST_F()
3993 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
3994 EXPECT_EQ(5, cache.disk_cache()->create_count()); in TEST_F()
4008 MockHttpCache cache(std::move(backend_factory)); in TEST_F() local
4021 RunTransactionTestWithRequest(cache.http_cache(), transaction, request, in TEST_F()
4025 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
4038 RunTransactionTestWithRequest(cache.http_cache(), transaction, request, in TEST_F()
4042 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
4045 // Can't actually cache it due to backend limitations. If the network in TEST_F()
4056 RunTransactionTestWithRequest(cache.http_cache(), transaction, request, in TEST_F()
4060 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
4067 MockHttpCache cache; in TEST_F() local
4078 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
4101 cache.GetCountWriterTransactions(validate_request.CacheKey())); in TEST_F()
4103 EXPECT_EQ(1, cache.disk_cache()->doomed_count()); in TEST_F()
4105 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
4106 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
4107 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
4120 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
4121 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
4122 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
4128 MockHttpCache cache; in TEST_F() local
4147 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
4166 EXPECT_TRUE(cache.disk_cache()->IsDiskEntryDoomed(request.CacheKey())); in TEST_F()
4168 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
4169 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
4170 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
4184 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
4185 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
4186 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
4192 MockHttpCache cache; in TEST_F() local
4207 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
4219 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
4220 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
4221 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
4224 EXPECT_EQ(1, cache.GetCountWriterTransactions(cache_key)); in TEST_F()
4225 EXPECT_EQ(1, cache.GetCountDoneHeadersQueue(cache_key)); in TEST_F()
4229 EXPECT_EQ(0, cache.GetCountDoneHeadersQueue(cache_key)); in TEST_F()
4238 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
4239 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
4240 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
4246 MockHttpCache cache; in TEST_F() local
4257 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
4267 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
4268 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
4269 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
4273 EXPECT_EQ(kNumTransactions, cache.GetCountWriterTransactions(cache_key)); in TEST_F()
4277 EXPECT_EQ(kNumTransactions - 1, cache.GetCountWriterTransactions(cache_key)); in TEST_F()
4286 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
4287 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
4288 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
4294 MockHttpCache cache; in TEST_F() local
4312 cache.SimulateCacheLockTimeoutAfterHeaders(); in TEST_F()
4315 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
4329 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
4330 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
4331 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
4334 EXPECT_TRUE(cache.IsWriterPresent(cache_key)); in TEST_F()
4335 EXPECT_EQ(0, cache.GetCountDoneHeadersQueue(cache_key)); in TEST_F()
4349 MockHttpCache cache; in TEST_F() local
4364 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
4380 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
4381 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
4382 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
4386 EXPECT_EQ(kNumTransactions - 1, cache.GetCountWriterTransactions(cache_key)); in TEST_F()
4387 EXPECT_TRUE(cache.IsHeadersTransactionPresent(cache_key)); in TEST_F()
4394 EXPECT_FALSE(cache.IsWriterPresent(cache_key)); in TEST_F()
4395 EXPECT_EQ(kNumTransactions - 2, cache.GetCountReaders(cache_key)); in TEST_F()
4396 EXPECT_EQ(0, cache.GetCountDoneHeadersQueue(cache_key)); in TEST_F()
4397 EXPECT_TRUE(cache.IsHeadersTransactionPresent(cache_key)); in TEST_F()
4406 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
4413 EXPECT_EQ(2, cache.GetCountAddToEntryQueue(cache_key)); in TEST_F()
4419 EXPECT_EQ(1, cache.GetCountReaders(cache_key)); in TEST_F()
4420 EXPECT_EQ(2, cache.GetCountAddToEntryQueue(cache_key)); in TEST_F()
4421 EXPECT_TRUE(cache.IsHeadersTransactionPresent(cache_key)); in TEST_F()
4430 EXPECT_EQ(3, cache.GetCountWriterTransactions(cache_key)); in TEST_F()
4438 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
4439 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
4440 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
4464 // Read the second byte, but leave the cache write hanging. in TEST_F()
4478 // waiting to be written to the cache. Destroy the transaction and make sure in TEST_F()
4489 MockHttpCache cache; in TEST_F() local
4504 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
4520 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
4521 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
4522 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
4525 EXPECT_TRUE(cache.IsHeadersTransactionPresent(cache_key)); in TEST_F()
4526 EXPECT_EQ(2, cache.GetCountWriterTransactions(cache_key)); in TEST_F()
4556 EXPECT_EQ(1, cache.GetCountWriterTransactions(cache_key)); in TEST_F()
4570 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
4571 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
4572 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
4578 MockHttpCache cache; in TEST_F() local
4597 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
4613 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
4614 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
4615 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
4618 EXPECT_EQ(3, cache.GetCountWriterTransactions(cache_key)); in TEST_F()
4619 EXPECT_EQ(1, cache.GetCountDoneHeadersQueue(cache_key)); in TEST_F()
4645 EXPECT_FALSE(cache.IsWriterPresent(cache_key)); in TEST_F()
4655 // Tests the case when cache write failure happens. Idle and waiting
4658 MockHttpCache cache; in TEST_F() local
4673 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
4687 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
4688 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
4689 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
4692 EXPECT_EQ(3, cache.GetCountWriterTransactions(cache_key)); in TEST_F()
4693 EXPECT_EQ(1, cache.GetCountDoneHeadersQueue(cache_key)); in TEST_F()
4695 // Initiate Read from two writers and let the first get a cache write failure. in TEST_F()
4696 cache.disk_cache()->set_soft_failures_mask(MockDiskEntry::FAIL_ALL); in TEST_F()
4699 cache.OpenBackendEntry(cache_key, &en); in TEST_F()
4731 EXPECT_FALSE(cache.IsWriterPresent(cache_key)); in TEST_F()
4740 // without writing to the cache. in TEST_F()
4747 // writing to the cache. Note that two POSTs only map to the same entry if their
4755 MockHttpCache cache; in TEST_F() local
4780 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
4792 EXPECT_EQ(1, cache.GetCountDoneHeadersQueue(cache_key)); in TEST_F()
4793 EXPECT_EQ(1, cache.GetCountWriterTransactions(cache_key)); in TEST_F()
4801 EXPECT_EQ(1, cache.GetCountReaders(cache_key)); in TEST_F()
4802 EXPECT_EQ(0, cache.GetCountDoneHeadersQueue(cache_key)); in TEST_F()
4806 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
4807 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
4808 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
4816 MockHttpCache cache; in TEST_F() local
4831 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
4845 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
4846 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
4847 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
4850 EXPECT_EQ(3, cache.GetCountWriterTransactions(cache_key)); in TEST_F()
4851 EXPECT_EQ(1, cache.GetCountDoneHeadersQueue(cache_key)); in TEST_F()
4876 // without writing to the cache. in TEST_F()
4883 EXPECT_EQ(3, cache.GetCountReaders(cache_key)); in TEST_F()
4896 // Tests the case when parallel writing involves things bigger than what cache
4899 MockHttpCache cache; in TEST_F() local
4900 cache.disk_cache()->set_max_file_size(10); in TEST_F()
4917 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
4928 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
4929 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
4930 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
4933 EXPECT_EQ(1, cache.GetCountWriterTransactions(cache_key)); in TEST_F()
4934 EXPECT_EQ(kNumTransactions - 1, cache.GetCountDoneHeadersQueue(cache_key)); in TEST_F()
4961 EXPECT_EQ(kNumTransactions, cache.network_layer()->transaction_count()); in TEST_F()
4972 MockHttpCache cache; in TEST_F() local
4983 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
4993 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
4994 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
4995 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
4998 EXPECT_EQ(2, cache.GetCountWriterTransactions(cache_key)); in TEST_F()
4999 EXPECT_EQ(0, cache.GetCountDoneHeadersQueue(cache_key)); in TEST_F()
5010 EXPECT_EQ(1, cache.GetCountReaders(cache_key)); in TEST_F()
5025 MockHttpCache cache; in TEST_F() local
5029 c.result = cache.CreateTransaction(&c.trans); in TEST_F()
5037 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
5038 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
5039 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
5042 EXPECT_EQ(1, cache.GetCountWriterTransactions(cache_key)); in TEST_F()
5043 EXPECT_EQ(0, cache.GetCountDoneHeadersQueue(cache_key)); in TEST_F()
5057 MockHttpCache cache; in TEST_F() local
5073 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
5083 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
5084 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
5085 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
5088 EXPECT_EQ(kNumTransactions, cache.GetCountWriterTransactions(cache_key)); in TEST_F()
5107 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
5108 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
5109 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
5122 MockHttpCache cache; in TEST_F() local
5137 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
5152 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
5153 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
5154 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
5157 EXPECT_EQ(kNumTransactions - 1, cache.GetCountWriterTransactions(cache_key)); in TEST_F()
5158 EXPECT_EQ(1, cache.GetCountDoneHeadersQueue(cache_key)); in TEST_F()
5177 MockHttpCache cache; in TEST_F() local
5192 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
5208 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
5209 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
5210 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
5213 EXPECT_TRUE(cache.IsHeadersTransactionPresent(cache_key)); in TEST_F()
5214 EXPECT_EQ(kNumTransactions - 1, cache.GetCountWriterTransactions(cache_key)); in TEST_F()
5226 EXPECT_EQ(1, cache.GetCountWriterTransactions(cache_key)); in TEST_F()
5235 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
5236 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
5237 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
5243 MockHttpCache cache; in TEST_F() local
5254 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
5267 EXPECT_TRUE(cache.IsHeadersTransactionPresent(cache_key)); in TEST_F()
5268 EXPECT_EQ(1, cache.GetCountAddToEntryQueue(cache_key)); in TEST_F()
5270 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
5271 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
5272 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
5286 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
5287 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
5288 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
5291 // Similar to the above test, except here cache write fails and the
5294 MockHttpCache cache; in TEST_F() local
5305 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
5323 EXPECT_EQ(kNumTransactions, cache.GetCountWriterTransactions(cache_key)); in TEST_F()
5331 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
5332 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
5333 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
5336 cache.disk_cache()->set_soft_failures_mask(MockDiskEntry::FAIL_ALL); in TEST_F()
5339 cache.OpenBackendEntry(cache_key, &en); in TEST_F()
5348 EXPECT_TRUE(cache.disk_cache()->IsDiskEntryDoomed(cache_key)); in TEST_F()
5352 // Consumer gets the response even if cache write failed. in TEST_F()
5371 MockHttpCache cache; in TEST_F() local
5384 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
5401 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
5402 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
5403 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
5441 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
5442 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
5443 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
5450 // We need simultaneous doomed / not_doomed entries so let's use a real cache. in TEST_F()
5451 MockHttpCache cache(HttpCache::DefaultBackend::InMemory(1024 * 1024)); in TEST_F() local
5464 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
5480 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
5499 MockHttpCache cache; in TEST_F() local
5500 cache.disk_cache()->set_support_in_memory_entry_data(true); in TEST_F()
5502 // Request 1 is a normal one to a no-cache/no-etag resource, to potentially in TEST_F()
5503 // set a "this is unvalidatable" hint in the cache. We also need it to in TEST_F()
5507 no_cache_transaction.response_headers = "Cache-Control: no-cache\n"; in TEST_F()
5512 c1.result = cache.CreateTransaction(&c1.trans); in TEST_F()
5530 c2.result = cache.CreateTransaction(&c2.trans); in TEST_F()
5545 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
5546 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
5547 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
5549 // Request 3 tries to read from cache, and it should successfully do so. It's in TEST_F()
5551 // cooperate with them, and is entirely driven by the state of the cache. in TEST_F()
5554 context3.result = cache.CreateTransaction(&context3.trans); in TEST_F()
5563 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
5564 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
5565 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
5572 MockHttpCache cache; in TEST_F() local
5586 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
5600 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
5601 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
5602 EXPECT_EQ(3, cache.disk_cache()->create_count()); in TEST_F()
5615 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
5616 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
5617 EXPECT_EQ(3, cache.disk_cache()->create_count()); in TEST_F()
5623 MockHttpCache cache; in TEST_F() local
5634 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
5645 *cache.http_cache()->GenerateCacheKeyForRequest(&request); in TEST_F()
5646 EXPECT_EQ(kNumTransactions, cache.GetCountWriterTransactions(cache_key)); in TEST_F()
5650 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
5651 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
5652 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
5672 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
5673 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
5674 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
5678 // cache entry.
5680 MockHttpCache cache; in TEST_F() local
5691 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
5698 // The first request should be creating the disk cache entry and the others in TEST_F()
5701 EXPECT_EQ(0, cache.network_layer()->transaction_count()); in TEST_F()
5702 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
5703 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
5723 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
5724 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
5725 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
5728 // Tests that we can cancel a single request to open a disk cache entry.
5730 MockHttpCache cache; in TEST_F() local
5736 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
5743 // Release the reference that the mock disk cache keeps for this entry, so in TEST_F()
5744 // that we test that the http cache handles the cancellation correctly. in TEST_F()
5745 cache.disk_cache()->ReleaseAll(); in TEST_F()
5749 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
5754 MockHttpCache cache; in TEST_F() local
5766 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
5773 // The first request should be deleting the disk cache entry and the others in TEST_F()
5776 EXPECT_EQ(0, cache.network_layer()->transaction_count()); in TEST_F()
5777 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
5778 EXPECT_EQ(0, cache.disk_cache()->create_count()); in TEST_F()
5789 EXPECT_EQ(5, cache.network_layer()->transaction_count()); in TEST_F()
5790 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
5791 EXPECT_EQ(5, cache.disk_cache()->create_count()); in TEST_F()
5794 // Tests that a (simulated) timeout allows transactions waiting on the cache
5797 MockHttpCache cache; in TEST_F() local
5798 cache.SimulateCacheLockTimeout(); in TEST_F()
5802 ASSERT_THAT(cache.CreateTransaction(&c1.trans), IsOk()); in TEST_F()
5805 ASSERT_THAT(cache.CreateTransaction(&c2.trans), IsOk()); in TEST_F()
5819 // Tests that a (simulated) timeout allows transactions waiting on the cache
5822 MockHttpCache cache; in TEST_F() local
5825 cache.SimulateCacheLockTimeout(); in TEST_F()
5829 ASSERT_THAT(cache.CreateTransaction(&c1.trans), IsOk()); in TEST_F()
5834 ASSERT_THAT(cache.CreateTransaction(&c2.trans), IsOk()); in TEST_F()
5848 MockHttpCache cache; in TEST_F() local
5850 // write to the cache in TEST_F()
5851 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
5857 ASSERT_THAT(cache.CreateTransaction(&trans), IsOk()); in TEST_F()
5867 // Test that destroying the transaction while it is reading from the cache in TEST_F()
5879 auto cache = std::make_unique<MockHttpCache>( in TEST_F() local
5891 c->result = cache->CreateTransaction(&c->trans); in TEST_F()
5898 // The first request should be creating the disk cache entry and the others in TEST_F()
5901 EXPECT_EQ(0, cache->network_layer()->transaction_count()); in TEST_F()
5902 EXPECT_EQ(0, cache->disk_cache()->open_count()); in TEST_F()
5903 EXPECT_EQ(0, cache->disk_cache()->create_count()); in TEST_F()
5905 cache.reset(); in TEST_F()
5912 MockHttpCache cache(std::move(factory)); in TEST_F() local
5925 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
5939 // The first request should be creating the disk cache. in TEST_F()
5945 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
5946 EXPECT_EQ(3, cache.disk_cache()->create_count()); in TEST_F()
5959 MockHttpCache cache(std::move(factory)); in TEST_F() local
5972 c->result = cache.CreateTransaction(&c->trans); in TEST_F()
5986 // The first request should be creating the disk cache. in TEST_F()
6002 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
6003 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
6010 auto cache = std::make_unique<MockHttpCache>(std::move(factory)); in TEST_F() local
6015 c->result = cache->CreateTransaction(&c->trans); in TEST_F()
6023 // The request should be creating the disk cache. in TEST_F()
6028 // that's owned by `cache`. in TEST_F()
6031 cache.reset(); in TEST_F()
6038 // Tests that we can delete the cache while creating the backend, from within
6043 auto cache = std::make_unique<MockHttpCache>(std::move(factory)); in TEST_F() local
6044 auto* cache_ptr = cache.get(); in TEST_F()
6046 DeleteCacheCompletionCallback cb(std::move(cache)); in TEST_F()
6075 // The cache should be gone by now. in TEST_F()
6082 MockHttpCache cache; in TEST_F() local
6084 // write to the cache in TEST_F()
6085 RunTransactionTest(cache.http_cache(), kTypicalGET_Transaction); in TEST_F()
6087 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
6088 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
6089 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
6094 RunTransactionTestAndGetTiming(cache.http_cache(), kTypicalGET_Transaction, in TEST_F()
6098 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
6099 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
6100 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
6116 MockHttpCache cache; in TEST_F() local
6120 // write to the cache in TEST_F()
6121 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
6123 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
6124 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
6125 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
6134 cache.http_cache(), transaction, in TEST_F()
6138 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
6139 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
6140 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
6192 MockHttpCache cache; in TEST_F() local
6194 // Write to the cache. in TEST_F()
6201 "Cache-Control: max-age=0\n" in TEST_F()
6204 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
6206 // Read from the cache. in TEST_F()
6210 RunTransactionTestAndGetTiming(cache.http_cache(), transaction, in TEST_F()
6216 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
6217 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
6218 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
6225 MockHttpCache cache; in TEST_F() local
6227 // Write to the cache. in TEST_F()
6234 "Cache-Control: max-age=0\n" in TEST_F()
6237 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
6239 // Read from the cache and revalidate the entry. in TEST_F()
6244 RunTransactionTestAndGetTiming(cache.http_cache(), transaction, in TEST_F()
6250 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
6251 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
6252 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
6259 MockHttpCache cache; in TEST_F() local
6261 // Write to the cache. in TEST_F()
6267 "Cache-Control: max-age=0\n" in TEST_F()
6270 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
6272 // Read from the cache and revalidate the entry. in TEST_F()
6276 RunTransactionTestAndGetTiming(cache.http_cache(), transaction, in TEST_F()
6282 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
6283 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
6284 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
6291 MockHttpCache cache; in TEST_F() local
6293 // Write to the cache. in TEST_F()
6299 "Cache-Control: max-age=0\n" in TEST_F()
6302 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
6304 // Read from the cache and don't revalidate the entry. in TEST_F()
6309 RunTransactionTestAndGetTiming(cache.http_cache(), transaction, in TEST_F()
6315 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
6316 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
6317 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
6324 MockHttpCache cache; in TEST_F() local
6326 // Write to the cache. in TEST_F()
6331 "Cache-Control: max-age=0\n" in TEST_F()
6333 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
6340 "Cache-Control: max-age=3600\n" in TEST_F()
6342 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
6344 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
6345 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
6346 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
6353 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
6355 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
6356 EXPECT_EQ(2, cache.disk_cache()->open_count()); in TEST_F()
6357 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
6363 MockHttpCache cache; in TEST_F() local
6365 // Write to the cache. in TEST_F()
6370 "Cache-Control: max-age=3600\n" in TEST_F()
6372 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
6377 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
6379 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
6380 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
6381 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
6388 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
6390 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
6391 EXPECT_EQ(2, cache.disk_cache()->open_count()); in TEST_F()
6392 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
6398 MockHttpCache cache; in TEST_F() local
6400 // Write to the cache. in TEST_F()
6405 "Cache-Control: max-age=0\n" in TEST_F()
6407 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
6413 "Cache-Control: max-age=3600\n"; in TEST_F()
6414 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
6416 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
6417 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
6418 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
6425 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
6427 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
6428 EXPECT_EQ(2, cache.disk_cache()->open_count()); in TEST_F()
6429 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
6435 MockHttpCache cache; in TEST_F() local
6437 // Write to the cache. in TEST_F()
6442 "Cache-Control: max-age=3600\n" in TEST_F()
6444 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
6451 "Cache-Control: max-age=3600\n"; in TEST_F()
6452 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
6454 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
6455 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
6456 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
6463 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
6465 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
6466 EXPECT_EQ(2, cache.disk_cache()->open_count()); in TEST_F()
6467 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
6479 MockHttpCache cache; in TEST_F() local
6484 // Write to the cache. in TEST_F()
6485 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
6487 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
6488 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
6489 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
6494 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
6496 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
6497 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
6498 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
6502 MockHttpCache cache; in TEST_F() local
6507 // Write to the cache. in TEST_F()
6508 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
6510 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
6511 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
6512 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
6518 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
6520 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
6521 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
6522 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
6533 response_headers->assign("Cache-Control: no-store\n"); in ETagGet_ConditionalRequest_NoStore_Handler()
6538 MockHttpCache cache; in TEST_F() local
6542 // Write to the cache. in TEST_F()
6543 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
6545 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
6546 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
6547 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
6553 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
6555 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
6556 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
6557 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
6561 // Write to the cache again. This should create a new entry. in TEST_F()
6562 RunTransactionTest(cache.http_cache(), transaction2); in TEST_F()
6564 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
6565 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
6566 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
6572 // (2) loads |kUrl| from cache only -- expects |net_response_1| to be returned.
6575 // (4) loads |kUrl| from cache only -- expects |cached_response_2| to be
6584 MockHttpCache cache; in ConditionalizedRequestUpdatesCacheHelper() local
6603 // receive |kNetResponse1|, which it saves into the HTTP cache. in ConditionalizedRequestUpdatesCacheHelper()
6615 cache.http_cache(), request, &response_headers); in ConditionalizedRequestUpdatesCacheHelper()
6618 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in ConditionalizedRequestUpdatesCacheHelper()
6619 EXPECT_EQ(0, cache.disk_cache()->open_count()); in ConditionalizedRequestUpdatesCacheHelper()
6620 EXPECT_EQ(1, cache.disk_cache()->create_count()); in ConditionalizedRequestUpdatesCacheHelper()
6623 // cache, so we don't hit the network. in ConditionalizedRequestUpdatesCacheHelper()
6631 cache.http_cache(), request, &response_headers); in ConditionalizedRequestUpdatesCacheHelper()
6634 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in ConditionalizedRequestUpdatesCacheHelper()
6635 EXPECT_EQ(1, cache.disk_cache()->open_count()); in ConditionalizedRequestUpdatesCacheHelper()
6636 EXPECT_EQ(1, cache.disk_cache()->create_count()); in ConditionalizedRequestUpdatesCacheHelper()
6650 cache.http_cache(), request, &response_headers); in ConditionalizedRequestUpdatesCacheHelper()
6653 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in ConditionalizedRequestUpdatesCacheHelper()
6654 EXPECT_EQ(1, cache.disk_cache()->open_count()); in ConditionalizedRequestUpdatesCacheHelper()
6655 EXPECT_EQ(1, cache.disk_cache()->create_count()); in ConditionalizedRequestUpdatesCacheHelper()
6658 // the cache. Moreover, the value in the cache should be |kNetResponse2| in ConditionalizedRequestUpdatesCacheHelper()
6660 // value in the cache with the modified response. in ConditionalizedRequestUpdatesCacheHelper()
6669 cache.http_cache(), request, &response_headers); in ConditionalizedRequestUpdatesCacheHelper()
6672 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in ConditionalizedRequestUpdatesCacheHelper()
6673 EXPECT_EQ(2, cache.disk_cache()->open_count()); in ConditionalizedRequestUpdatesCacheHelper()
6674 EXPECT_EQ(1, cache.disk_cache()->create_count()); in ConditionalizedRequestUpdatesCacheHelper()
6770 // and there is no corresponding cache entry, a new cache entry is NOT
6773 MockHttpCache cache; in TEST_F() local
6803 cache.http_cache(), request, &response_headers); in TEST_F()
6806 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
6807 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
6808 EXPECT_EQ(0, cache.disk_cache()->create_count()); in TEST_F()
6814 // and there is no corresponding cache entry, a new cache entry is NOT
6817 MockHttpCache cache; in TEST_F() local
6847 cache.http_cache(), request, &response_headers); in TEST_F()
6850 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
6851 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
6852 EXPECT_EQ(0, cache.disk_cache()->create_count()); in TEST_F()
6858 // if the date does not match the cache entry's last-modified date,
6859 // then we do NOT use the response (304) to update the cache.
6860 // (the if-modified-since date is 2 days AFTER the cache's modification date).
6889 // if the etag does not match the cache entry's etag, then we do not use the
6890 // response (304) to update the cache.
6917 // and if-modified-since updates the cache.
6945 // and if-modified-since does not update the cache with only one match.
6974 // and if-modified-since does not update the cache with only one match.
7003 MockHttpCache cache; in TEST_F() local
7005 // Do a typical GET request -- should write an entry into our cache. in TEST_F()
7007 RunTransactionTest(cache.http_cache(), trans); in TEST_F()
7009 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
7010 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
7011 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7014 // Since the cache key strips the hash sections, this should be a cache hit. in TEST_F()
7019 RunTransactionTest(cache.http_cache(), trans); in TEST_F()
7021 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
7022 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
7023 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7026 // Tests that we skip the cache for POST requests that do not have an upload
7029 MockHttpCache cache; in TEST_F() local
7031 RunTransactionTest(cache.http_cache(), kSimplePOST_Transaction); in TEST_F()
7033 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
7034 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
7035 EXPECT_EQ(0, cache.disk_cache()->create_count()); in TEST_F()
7038 // Tests POST handling with a disabled cache (no DCHECK).
7040 MockHttpCache cache; in TEST_F() local
7041 cache.http_cache()->set_mode(HttpCache::Mode::DISABLE); in TEST_F()
7043 RunTransactionTest(cache.http_cache(), kSimplePOST_Transaction); in TEST_F()
7045 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
7046 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
7047 EXPECT_EQ(0, cache.disk_cache()->create_count()); in TEST_F()
7051 MockHttpCache cache; in TEST_F() local
7060 ASSERT_THAT(cache.CreateTransaction(&trans), IsOk()); in TEST_F()
7068 EXPECT_EQ(0, cache.network_layer()->transaction_count()); in TEST_F()
7069 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
7070 EXPECT_EQ(0, cache.disk_cache()->create_count()); in TEST_F()
7074 MockHttpCache cache; in TEST_F() local
7076 // Test that we hit the cache for POST requests. in TEST_F()
7090 // Populate the cache. in TEST_F()
7091 RunTransactionTestWithRequest(cache.http_cache(), transaction, request, in TEST_F()
7094 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
7095 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
7096 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7098 // Load from cache. in TEST_F()
7100 RunTransactionTestWithRequest(cache.http_cache(), transaction, request, in TEST_F()
7103 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
7104 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
7105 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7108 // Test that we don't hit the cache for POST requests if there is a byte range.
7110 MockHttpCache cache; in TEST_F() local
7126 // Attempt to populate the cache. in TEST_F()
7127 RunTransactionTestWithRequest(cache.http_cache(), transaction, request, in TEST_F()
7130 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
7131 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
7132 EXPECT_EQ(0, cache.disk_cache()->create_count()); in TEST_F()
7137 MockHttpCache cache; in TEST_F() local
7148 RunTransactionTestWithRequest(cache.http_cache(), transaction, req1, nullptr); in TEST_F()
7150 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
7151 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
7152 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7157 RunTransactionTestWithRequest(cache.http_cache(), transaction, req2, nullptr); in TEST_F()
7159 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
7160 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
7161 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
7166 MockHttpCache cache; in TEST_F() local
7172 // Attempt to populate the cache. in TEST_F()
7173 RunTransactionTestWithRequest(cache.http_cache(), transaction, req1, nullptr); in TEST_F()
7175 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
7176 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
7177 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7189 RunTransactionTestWithRequest(cache.http_cache(), transaction, req2, nullptr); in TEST_F()
7191 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
7192 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
7193 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
7195 RunTransactionTestWithRequest(cache.http_cache(), transaction, req1, nullptr); in TEST_F()
7197 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
7198 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
7199 EXPECT_EQ(3, cache.disk_cache()->create_count()); in TEST_F()
7204 // with cache split by top-frame origin.
7210 MockHttpCache cache; in TEST_P() local
7219 // Attempt to populate the cache. in TEST_P()
7220 RunTransactionTestWithRequest(cache.http_cache(), transaction, req1, nullptr); in TEST_P()
7227 RunTransactionTestWithRequest(cache.http_cache(), transaction, req1b, in TEST_P()
7230 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_P()
7231 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_P()
7232 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_P()
7247 RunTransactionTestWithRequest(cache.http_cache(), transaction, req2, nullptr); in TEST_P()
7249 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_P()
7250 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_P()
7251 EXPECT_EQ(3, cache.disk_cache()->create_count()); in TEST_P()
7255 RunTransactionTestWithRequest(cache.http_cache(), transaction, req1b, in TEST_P()
7257 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_P()
7258 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_P()
7259 EXPECT_EQ(3, cache.disk_cache()->create_count()); in TEST_P()
7262 RunTransactionTestWithRequest(cache.http_cache(), transaction, req1, nullptr); in TEST_P()
7263 EXPECT_EQ(4, cache.network_layer()->transaction_count()); in TEST_P()
7264 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_P()
7265 EXPECT_EQ(4, cache.disk_cache()->create_count()); in TEST_P()
7273 MockHttpCache cache; in TEST_F() local
7279 // Attempt to populate the cache. in TEST_F()
7280 RunTransactionTestWithRequest(cache.http_cache(), transaction, req1, nullptr); in TEST_F()
7282 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
7283 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
7284 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7296 RunTransactionTestWithRequest(cache.http_cache(), transaction, req2, nullptr); in TEST_F()
7298 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
7299 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
7300 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7302 RunTransactionTestWithRequest(cache.http_cache(), transaction, req1, nullptr); in TEST_F()
7304 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
7305 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
7306 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
7312 // This will initialize a cache object with NULL backend. in TEST_F()
7316 MockHttpCache cache(std::move(factory)); in TEST_F() local
7328 RunTransactionTestWithRequest(cache.http_cache(), transaction, req, nullptr); in TEST_F()
7335 MockHttpCache cache; in TEST_F() local
7341 // Attempt to populate the cache. in TEST_F()
7342 RunTransactionTestWithRequest(cache.http_cache(), transaction, req1, nullptr); in TEST_F()
7344 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
7345 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
7346 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7358 RunTransactionTestWithRequest(cache.http_cache(), transaction, req2, nullptr); in TEST_F()
7360 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
7361 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
7362 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
7364 RunTransactionTestWithRequest(cache.http_cache(), transaction, req1, nullptr); in TEST_F()
7366 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
7367 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
7368 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
7374 MockHttpCache cache; in TEST_F() local
7384 ASSERT_THAT(cache.CreateTransaction(&trans), IsOk()); in TEST_F()
7392 EXPECT_EQ(0, cache.network_layer()->transaction_count()); in TEST_F()
7393 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
7394 EXPECT_EQ(0, cache.disk_cache()->create_count()); in TEST_F()
7400 MockHttpCache cache; in TEST_F() local
7404 // Populate the cache. in TEST_F()
7405 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
7407 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
7408 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
7409 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7411 // Load from cache. in TEST_F()
7415 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
7417 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
7418 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
7419 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7423 // Tests that a read-only request served from the cache preserves CL.
7425 MockHttpCache cache; in TEST_F() local
7430 // Populate the cache. in TEST_F()
7431 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
7433 // Load from cache. in TEST_F()
7439 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
7445 // Tests that a read-write request served from the cache preserves CL.
7447 MockHttpCache cache; in TEST_F() local
7454 // Populate the cache. in TEST_F()
7455 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
7457 // Load from cache. in TEST_F()
7462 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
7468 // Tests that a HEAD request that includes byte ranges bypasses the cache.
7470 MockHttpCache cache; in TEST_F() local
7474 // Populate the cache. in TEST_F()
7475 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
7477 // Load from cache. in TEST_F()
7482 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
7484 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
7485 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7491 MockHttpCache cache; in TEST_F() local
7494 // Write to the cache (40-49). in TEST_F()
7495 RunTransactionTest(cache.http_cache(), kRangeGET_TransactionOK); in TEST_F()
7506 // Load from cache. in TEST_F()
7507 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
7512 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
7513 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
7514 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7520 MockHttpCache cache; in TEST_F() local
7528 CreateTruncatedEntry(raw_headers, &cache); in TEST_F()
7539 // Load from cache. in TEST_F()
7540 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
7545 EXPECT_EQ(0, cache.network_layer()->transaction_count()); in TEST_F()
7546 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
7547 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7553 MockHttpCache cache; in TEST_F() local
7557 // Populate the cache. in TEST_F()
7558 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
7560 // Update the cache. in TEST_F()
7566 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
7570 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
7578 // Load from the cache. in TEST_F()
7580 RunTransactionTestWithResponse(cache.http_cache(), transaction2, &headers); in TEST_F()
7583 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
7584 EXPECT_EQ(2, cache.disk_cache()->open_count()); in TEST_F()
7585 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7589 // Tests that an externally conditionalized HEAD request updates the cache.
7591 MockHttpCache cache; in TEST_F() local
7595 // Populate the cache. in TEST_F()
7596 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
7598 // Update the cache. in TEST_F()
7606 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
7610 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
7618 // Load from the cache. in TEST_F()
7620 RunTransactionTestWithResponse(cache.http_cache(), transaction2, &headers); in TEST_F()
7623 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
7624 EXPECT_EQ(2, cache.disk_cache()->open_count()); in TEST_F()
7625 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7631 MockHttpCache cache; in TEST_F() local
7635 // Populate the cache. in TEST_F()
7636 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
7638 // Update the cache. in TEST_F()
7641 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
7642 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
7644 // Load from the cache. in TEST_F()
7648 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
7653 // Tests that we do not cache the response of a PUT.
7655 MockHttpCache cache; in TEST_F() local
7668 // Attempt to populate the cache. in TEST_F()
7669 RunTransactionTestWithRequest(cache.http_cache(), transaction, request, in TEST_F()
7672 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
7673 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
7674 EXPECT_EQ(0, cache.disk_cache()->create_count()); in TEST_F()
7679 MockHttpCache cache; in TEST_F() local
7684 // Attempt to populate the cache. in TEST_F()
7685 RunTransactionTestWithRequest(cache.http_cache(), transaction, req1, nullptr); in TEST_F()
7687 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
7688 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
7689 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7700 RunTransactionTestWithRequest(cache.http_cache(), transaction, req2, nullptr); in TEST_F()
7702 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
7703 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
7704 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7706 RunTransactionTestWithRequest(cache.http_cache(), transaction, req1, nullptr); in TEST_F()
7708 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
7709 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
7710 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
7715 MockHttpCache cache; in TEST_F() local
7721 // Attempt to populate the cache. in TEST_F()
7722 RunTransactionTestWithRequest(cache.http_cache(), transaction, req1, nullptr); in TEST_F()
7724 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
7725 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
7726 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7738 RunTransactionTestWithRequest(cache.http_cache(), transaction, req2, nullptr); in TEST_F()
7740 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
7741 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
7742 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7744 RunTransactionTestWithRequest(cache.http_cache(), transaction, req1, nullptr); in TEST_F()
7746 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
7747 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
7748 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
7754 MockHttpCache cache; in TEST_F() local
7760 // Attempt to populate the cache. in TEST_F()
7761 RunTransactionTestWithRequest(cache.http_cache(), transaction, req1, nullptr); in TEST_F()
7763 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
7764 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
7765 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7777 RunTransactionTestWithRequest(cache.http_cache(), transaction, req2, nullptr); in TEST_F()
7779 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
7780 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
7781 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7783 RunTransactionTestWithRequest(cache.http_cache(), transaction, req1, nullptr); in TEST_F()
7785 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
7786 EXPECT_EQ(2, cache.disk_cache()->open_count()); in TEST_F()
7787 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7791 // Tests that we do not cache the response of a DELETE.
7793 MockHttpCache cache; in TEST_F() local
7806 // Attempt to populate the cache. in TEST_F()
7807 RunTransactionTestWithRequest(cache.http_cache(), transaction, request, in TEST_F()
7810 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
7811 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
7812 EXPECT_EQ(0, cache.disk_cache()->create_count()); in TEST_F()
7817 MockHttpCache cache; in TEST_F() local
7822 // Attempt to populate the cache. in TEST_F()
7823 RunTransactionTestWithRequest(cache.http_cache(), transaction, req1, nullptr); in TEST_F()
7825 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
7826 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
7827 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7838 RunTransactionTestWithRequest(cache.http_cache(), transaction, req2, nullptr); in TEST_F()
7840 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
7841 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
7842 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7844 RunTransactionTestWithRequest(cache.http_cache(), transaction, req1, nullptr); in TEST_F()
7846 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
7847 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
7848 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
7853 MockHttpCache cache; in TEST_F() local
7858 // Attempt to populate the cache. in TEST_F()
7859 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
7861 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
7862 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
7863 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7868 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
7870 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
7871 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
7872 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7875 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
7877 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
7878 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
7879 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
7885 MockHttpCache cache; in TEST_F() local
7890 // Attempt to populate the cache. in TEST_F()
7891 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
7893 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
7894 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
7895 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7900 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
7902 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
7903 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
7904 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7908 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
7910 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
7911 EXPECT_EQ(2, cache.disk_cache()->open_count()); in TEST_F()
7912 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7918 MockHttpCache cache; in TEST_F() local
7923 // Attempt to populate the cache. in TEST_F()
7924 RunTransactionTestWithRequest(cache.http_cache(), transaction, req1, nullptr); in TEST_F()
7926 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
7927 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
7928 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7939 RunTransactionTestWithRequest(cache.http_cache(), transaction, req2, nullptr); in TEST_F()
7941 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
7942 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
7943 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7945 RunTransactionTestWithRequest(cache.http_cache(), transaction, req1, nullptr); in TEST_F()
7947 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
7948 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
7949 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
7954 MockHttpCache cache; in TEST_F() local
7959 // Attempt to populate the cache. in TEST_F()
7960 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
7962 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
7963 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
7964 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7969 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
7971 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
7972 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
7973 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
7976 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
7978 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
7979 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
7980 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
7986 MockHttpCache cache; in TEST_F() local
7991 // Attempt to populate the cache. in TEST_F()
7992 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
7994 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
7995 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
7996 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8001 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
8003 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
8004 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
8005 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8009 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
8011 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
8012 EXPECT_EQ(2, cache.disk_cache()->open_count()); in TEST_F()
8013 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8019 MockHttpCache cache; in TEST_F() local
8021 // Populate the cache. in TEST_F()
8022 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
8023 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
8031 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
8032 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
8038 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
8041 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
8046 MockHttpCache cache; in TEST_F() local
8048 // Test that we skip the cache for range GET requests. Eventually, we will in TEST_F()
8049 // want to cache these, but we'll still have cases where skipping the cache in TEST_F()
8052 RunTransactionTest(cache.http_cache(), kRangeGET_Transaction); in TEST_F()
8054 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
8055 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
8056 EXPECT_EQ(0, cache.disk_cache()->create_count()); in TEST_F()
8060 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
8062 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
8063 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
8064 EXPECT_EQ(0, cache.disk_cache()->create_count()); in TEST_F()
8068 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
8070 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
8071 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
8072 EXPECT_EQ(0, cache.disk_cache()->create_count()); in TEST_F()
8075 // Test that we skip the cache for range requests that include a validation
8078 MockHttpCache cache; in TEST_F() local
8084 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
8086 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
8087 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
8088 EXPECT_EQ(0, cache.disk_cache()->create_count()); in TEST_F()
8094 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
8096 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
8097 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
8098 EXPECT_EQ(0, cache.disk_cache()->create_count()); in TEST_F()
8103 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
8105 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
8106 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
8107 EXPECT_EQ(0, cache.disk_cache()->create_count()); in TEST_F()
8111 MockHttpCache cache; in TEST_F() local
8114 RunTransactionTestWithLog(cache.http_cache(), kSimpleGET_Transaction, in TEST_F()
8122 MockHttpCache cache; in TEST_F() local
8125 RunTransactionTestWithLog(cache.http_cache(), kRangeGET_Transaction, in TEST_F()
8133 MockHttpCache cache; in TEST_F() local
8138 RunTransactionTestWithLog(cache.http_cache(), transaction, in TEST_F()
8146 MockHttpCache cache; in TEST_F() local
8150 transaction.request_headers = "cache-control: no-cache\r\n" EXTRA_HEADER; in TEST_F()
8151 RunTransactionTestWithLog(cache.http_cache(), transaction, in TEST_F()
8160 MockHttpCache cache; in TEST_F() local
8162 // Write to the cache. in TEST_F()
8167 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
8169 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
8170 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
8171 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8174 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
8176 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
8177 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
8178 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
8184 MockHttpCache cache; in TEST_F() local
8186 // Write to the cache. in TEST_F()
8190 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
8192 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
8193 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
8194 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8201 MockHttpCache cache; in TEST_F() local
8204 // Attempt to write to the cache (40-49). in TEST_F()
8207 "Cache-Control: max-age=3600\n" in TEST_F()
8209 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8212 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
8213 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
8214 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8217 RunTransactionTestWithResponse(cache.http_cache(), kRangeGET_TransactionOK, in TEST_F()
8221 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
8222 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
8223 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
8228 MockHttpCache cache; in TEST_F() local
8229 cache.FailConditionalizations(); in TEST_F()
8232 // Write to the cache (40-49). in TEST_F()
8236 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8239 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
8240 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
8241 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8244 RunTransactionTestWithResponse(cache.http_cache(), kRangeGET_TransactionOK, in TEST_F()
8248 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
8249 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
8250 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
8256 MockHttpCache cache; in TEST_F() local
8257 cache.FailConditionalizations(); in TEST_F()
8259 // Write to the cache (40-49). in TEST_F()
8263 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
8267 RunTransactionTestWithLog(cache.http_cache(), kRangeGET_TransactionOK, in TEST_F()
8278 MockHttpCache cache; in TEST_F() local
8279 cache.disk_cache()->set_support_in_memory_entry_data(use_memory_entry_data); in TEST_F()
8280 cache.FailConditionalizations(); in TEST_F()
8283 // Write to the cache (40-49). in TEST_F()
8288 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8291 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
8292 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
8293 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8296 // Don't ask for a range. The cache will attempt to use the cached data but in TEST_F()
8301 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8304 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
8305 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
8306 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
8309 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
8310 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
8312 // The cache entry isn't really useful, since when in TEST_F()
8318 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
8319 EXPECT_EQ(3, cache.disk_cache()->create_count()); in TEST_F()
8321 EXPECT_EQ(2, cache.disk_cache()->open_count()); in TEST_F()
8322 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
8328 // require the cache to modify the range to ask, result in a network request
8331 MockHttpCache cache; in TEST_F() local
8332 cache.FailConditionalizations(); in TEST_F()
8335 // Write to the cache (40-49). in TEST_F()
8339 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8342 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
8343 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
8344 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8348 // cache would normally mix data from three sources. After deleting the entry, in TEST_F()
8353 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8356 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
8357 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
8358 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
8361 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
8362 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
8363 EXPECT_EQ(2, cache.disk_cache()->open_count()); in TEST_F()
8364 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
8367 // Tests that we cache partial responses that lack content-length.
8369 MockHttpCache cache; in TEST_F() local
8372 // Attempt to write to the cache (40-49). in TEST_F()
8379 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8381 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
8382 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
8383 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8387 RunTransactionTestWithResponse(cache.http_cache(), kRangeGET_TransactionOK, in TEST_F()
8391 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
8392 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
8393 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8398 // Tests that we can cache range requests and fetch random blocks from the
8399 // cache and the network.
8401 MockHttpCache cache; in TEST_F() local
8405 // Write to the cache (40-49). in TEST_F()
8406 RunTransactionTestWithResponse(cache.http_cache(), kRangeGET_TransactionOK, in TEST_F()
8410 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
8411 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
8412 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8414 // Read from the cache (40-49). in TEST_F()
8415 RunTransactionTestWithResponse(cache.http_cache(), kRangeGET_TransactionOK, in TEST_F()
8419 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
8420 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
8421 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8426 // Write to the cache (30-39). in TEST_F()
8430 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8433 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
8434 EXPECT_EQ(2, cache.disk_cache()->open_count()); in TEST_F()
8435 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8440 // Write and read from the cache (20-59). in TEST_F()
8445 cache.http_cache(), transaction, &headers, in TEST_F()
8449 EXPECT_EQ(4, cache.network_layer()->transaction_count()); in TEST_F()
8450 EXPECT_EQ(3, cache.disk_cache()->open_count()); in TEST_F()
8451 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8458 // Tests recovery on cache read error on range request. in TEST_F()
8459 MockHttpCache cache; in TEST_F() local
8463 // Write to the cache (40-49). in TEST_F()
8464 RunTransactionTestWithResponse(cache.http_cache(), kRangeGET_TransactionOK, in TEST_F()
8468 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
8469 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
8470 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8472 cache.disk_cache()->set_soft_failures_one_instance(MockDiskEntry::FAIL_ALL); in TEST_F()
8474 // Try to read from the cache (40-49), which will fail quickly enough to in TEST_F()
8477 RunTransactionTestWithResponse(cache.http_cache(), kRangeGET_TransactionOK, in TEST_F()
8481 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
8482 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
8483 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
8491 MockHttpCache cache; in TEST_F() local
8495 {kRangeGET_TransactionOK.response_headers, "Cache-Control: no-store\n"}); in TEST_F()
8500 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8503 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
8504 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
8505 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8512 MockHttpCache cache; in TEST_F() local
8516 {kRangeGET_TransactionOK.response_headers, "Cache-Control: max-age=0\n"}); in TEST_F()
8521 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8524 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
8525 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
8526 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8529 {kRangeGET_TransactionOK.response_headers, "Cache-Control: no-store\n"}); in TEST_F()
8531 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8534 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
8535 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
8536 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8538 // Fetch again, this one should be from newly created cache entry, due to in TEST_F()
8541 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8542 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
8543 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
8544 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
8550 // Tests that we can cache range requests and fetch random blocks from the
8551 // cache and the network, with synchronous responses.
8553 MockHttpCache cache; in TEST_F() local
8559 // Write to the cache (40-49). in TEST_F()
8561 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8564 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
8565 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
8566 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8568 // Read from the cache (40-49). in TEST_F()
8569 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8572 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
8573 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
8574 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8579 // Write to the cache (30-39). in TEST_F()
8582 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8585 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
8586 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
8587 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8592 // Write and read from the cache (20-59). in TEST_F()
8597 cache.http_cache(), transaction, &headers, in TEST_F()
8601 EXPECT_EQ(4, cache.network_layer()->transaction_count()); in TEST_F()
8602 EXPECT_EQ(2, cache.disk_cache()->open_count()); in TEST_F()
8603 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8613 MockHttpCache cache; in TEST_F() local
8618 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
8624 *cache.http_cache()->GenerateCacheKeyForRequest(&request); in TEST_F()
8625 ASSERT_TRUE(cache.OpenBackendEntry(cache_key, &entry)); in TEST_F()
8629 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
8635 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
8642 MockHttpCache cache; in TEST_F() local
8645 // Write to the cache (40-49). in TEST_F()
8654 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8657 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
8658 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
8659 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8661 // Read from the cache (40-49). in TEST_F()
8665 RunTransactionTestWithResponseAndGetTiming(cache.http_cache(), transaction, in TEST_F()
8670 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
8671 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
8672 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8677 RunTransactionTestWithResponseAndGetTiming(cache.http_cache(), transaction, in TEST_F()
8682 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
8683 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
8684 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8692 MockHttpCache cache; in TEST_F() local
8695 // Write to the cache (40-49). in TEST_F()
8704 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8707 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
8708 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
8709 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8711 // Read from the cache (40-49). in TEST_F()
8712 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8715 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
8716 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
8717 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8724 MockHttpCache cache; in TEST_F() local
8728 // Write to the cache (40-49). in TEST_F()
8729 RunTransactionTestWithResponse(cache.http_cache(), kRangeGET_TransactionOK, in TEST_F()
8733 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
8734 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
8735 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8737 // Read from the cache (40-49). in TEST_F()
8742 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8745 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
8746 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
8747 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8754 MockHttpCache cache; in TEST_F() local
8758 // Write to the cache (40-49). in TEST_F()
8759 RunTransactionTestWithResponse(cache.http_cache(), kRangeGET_TransactionOK, in TEST_F()
8763 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
8764 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
8765 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8767 // Attempt to read from the cache (40-49). in TEST_F()
8772 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8775 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
8776 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
8777 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8780 RunTransactionTest(cache.http_cache(), kRangeGET_TransactionOK); in TEST_F()
8781 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
8782 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
8783 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
8789 // and there is nothing stored in the cache, the returned response is passed to
8794 MockHttpCache cache; in TEST_F() local
8807 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8810 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
8811 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
8812 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8816 // and there was an entry stored in the cache, the cache gets out of the way.
8818 MockHttpCache cache; in TEST_F() local
8821 // Write to the cache (70-79). in TEST_F()
8825 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8828 // Request a large range (40-79). The cache will ask the server for 40-59. in TEST_F()
8829 // The server returns 40-49. The cache should consider the server confused and in TEST_F()
8839 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8841 // Two new network requests were issued, one from the cache and another after in TEST_F()
8844 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
8845 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
8846 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8849 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
8850 EXPECT_EQ(4, cache.network_layer()->transaction_count()); in TEST_F()
8851 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
8852 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
8856 // and there was an entry stored in the cache, the cache gets out of the way,
8859 MockHttpCache cache; in TEST_F() local
8862 // Write to the cache (70-79). in TEST_F()
8866 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8869 // Don't ask for a range. The cache will ask the server for 0-69. in TEST_F()
8870 // The server returns 40-49. The cache should consider the server confused and in TEST_F()
8876 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8879 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
8880 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
8881 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8884 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
8885 EXPECT_EQ(4, cache.network_layer()->transaction_count()); in TEST_F()
8886 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
8887 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
8891 // nothing stored in the cache, the returned response is passed to the caller
8897 MockHttpCache cache; in TEST_F() local
8910 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8913 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
8914 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
8915 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8918 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
8919 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
8920 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
8921 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
8925 // an entry stored in the cache, the cache gets out of the way.
8927 MockHttpCache cache; in TEST_F() local
8930 // Write to the cache (70-79). in TEST_F()
8934 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8937 // Request a large range (30-79). The cache will ask the server for 30-69. in TEST_F()
8938 // The server returns 40-49. The cache should consider the server confused and in TEST_F()
8948 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8951 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
8952 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
8953 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8956 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
8957 EXPECT_EQ(4, cache.network_layer()->transaction_count()); in TEST_F()
8958 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
8959 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
8962 // Tests that when a caller asks for a range beyond EOF, with an empty cache,
8965 MockHttpCache cache; in TEST_F() local
8972 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8975 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
8976 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
8977 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
8979 RunTransactionTest(cache.http_cache(), kRangeGET_TransactionOK); in TEST_F()
8980 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
8984 // the cache automatically fixes the request.
8986 MockHttpCache cache; in TEST_F() local
8989 // Write to the cache (40-49). in TEST_F()
8991 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8996 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
8999 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
9000 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
9001 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9004 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
9005 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
9006 EXPECT_EQ(2, cache.disk_cache()->open_count()); in TEST_F()
9007 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9013 MockHttpCache cache; in TEST_F() local
9021 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
9024 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
9025 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
9026 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9029 RunTransactionTest(cache.http_cache(), kRangeGET_TransactionOK); in TEST_F()
9030 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
9033 // Tests that we cache 301s for range requests.
9035 MockHttpCache cache; in TEST_F() local
9042 // Write to the cache. in TEST_F()
9043 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
9044 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
9045 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
9046 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9048 // Read from the cache. in TEST_F()
9049 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
9050 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
9051 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
9052 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9055 // Tests that we can cache range requests when the start or end is unknown.
9058 MockHttpCache cache; in TEST_F() local
9062 // Write to the cache (70-79). in TEST_F()
9066 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
9069 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
9070 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
9071 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9076 // Write and read from the cache (60-79). in TEST_F()
9079 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
9082 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
9083 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
9084 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9089 // Tests that we can cache range requests when the start or end is unknown.
9091 // We'll also verify that synchronous cache responses work as intended.
9093 MockHttpCache cache; in TEST_F() local
9102 // Write to the cache (70-79). in TEST_F()
9105 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
9108 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
9109 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
9110 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9115 // Write and read from the cache (60-79). in TEST_F()
9118 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
9121 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
9122 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
9123 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9131 MockHttpCache cache; in TEST_F() local
9136 "Cache-Control: max-age=10000\n" in TEST_F()
9143 // Write the empty resource to the cache. in TEST_F()
9144 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
9149 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
9150 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
9151 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9156 // Write and read from the cache. This used to trigger a DCHECK in TEST_F()
9159 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
9164 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
9165 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
9166 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9170 // cache 302, which is notably bodiless.
9172 MockHttpCache cache; in TEST_F() local
9178 "Cache-Control: max-age=0\n" in TEST_F()
9188 // Write the empty resource to the cache. in TEST_F()
9189 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
9193 "Cache-Control: max-age=0\n" in TEST_F()
9197 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
9198 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
9199 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9204 // Try to read from the cache. This should send a network request to in TEST_F()
9207 "Cache-Control: max-age=0\n" in TEST_F()
9210 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
9214 "Cache-Control: max-age=0\n" in TEST_F()
9218 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
9219 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
9221 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
9225 // cache 302, which is notably bodiless, where the 302 is replaced with an
9228 MockHttpCache cache; in TEST_F() local
9234 "Cache-Control: max-age=0\n" in TEST_F()
9243 // Write the empty resource to the cache. in TEST_F()
9244 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
9248 "Cache-Control: max-age=0\n" in TEST_F()
9252 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
9253 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
9254 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9259 // Try to read from the cache. This should send a network request to in TEST_F()
9267 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
9274 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
9275 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
9277 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
9283 MockHttpCache cache; in TEST_F() local
9295 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
9297 // We just bypass the cache. in TEST_F()
9299 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
9300 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
9301 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9303 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
9304 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
9311 MockHttpCache cache; in TEST_F() local
9318 // Write to the cache (40-49). in TEST_F()
9320 cache.http_cache(), kRangeGET_TransactionOK, &headers, in TEST_F()
9324 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
9325 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
9326 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9329 // Write and read from the cache (0-79), when not asked for a range. in TEST_F()
9333 RunTransactionTestWithResponseAndGetTiming(cache.http_cache(), transaction, in TEST_F()
9338 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
9339 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
9340 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9349 MockHttpCache cache; in TEST_F() local
9359 // Write to the cache (0-9). in TEST_F()
9362 RunTransactionTestWithResponseAndGetTiming(cache.http_cache(), transaction, in TEST_F()
9368 // Write to the cache (70-79). in TEST_F()
9371 RunTransactionTestWithResponseAndGetTiming(cache.http_cache(), transaction, in TEST_F()
9376 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
9377 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
9378 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9381 // Read from the cache (0-9), write and read from cache (10 - 79). in TEST_F()
9385 RunTransactionTestWithResponseAndGetTiming(cache.http_cache(), transaction, in TEST_F()
9390 EXPECT_EQ(4, cache.network_layer()->transaction_count()); in TEST_F()
9391 EXPECT_EQ(2, cache.disk_cache()->open_count()); in TEST_F()
9392 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9401 MockHttpCache cache; in TEST_F() local
9405 // Write to the cache (0-9). in TEST_F()
9409 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
9412 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
9413 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
9414 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9428 cache.http_cache(), transaction2, &headers, in TEST_F()
9432 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
9433 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
9434 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9438 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
9439 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
9446 MockHttpCache cache; in TEST_F() local
9449 // Create a disk cache entry that stores 206 headers while not being sparse. in TEST_F()
9451 ASSERT_TRUE(cache.CreateBackendEntry(request.CacheKey(), &entry, nullptr)); in TEST_F()
9474 cache.http_cache(), kSimpleGET_Transaction, &headers, in TEST_F()
9482 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
9483 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
9484 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
9491 MockHttpCache cache; in TEST_F() local
9494 // Create a disk cache entry that stores 206 headers while not being sparse. in TEST_F()
9497 ASSERT_TRUE(cache.CreateBackendEntry(request.CacheKey(), &entry, nullptr)); in TEST_F()
9518 RunTransactionTestWithResponse(cache.http_cache(), kRangeGET_TransactionOK, in TEST_F()
9523 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
9524 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
9525 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
9532 MockHttpCache cache; in TEST_F() local
9535 // Create a disk cache entry that stores 206 headers. in TEST_F()
9537 ASSERT_TRUE(cache.CreateBackendEntry(request.CacheKey(), &entry, nullptr)); in TEST_F()
9559 RunTransactionTestWithResponse(cache.http_cache(), kSimpleGET_Transaction, in TEST_F()
9567 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
9568 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
9569 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
9574 MockHttpCache cache; in TEST_F() local
9581 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
9582 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
9583 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
9584 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9594 RunTransactionTestWithResponse(cache.http_cache(), transaction2, &headers); in TEST_F()
9598 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
9599 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
9600 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9610 RunTransactionTestWithResponse(cache.http_cache(), transaction3, &headers); in TEST_F()
9611 EXPECT_EQ(2, cache.disk_cache()->open_count()); in TEST_F()
9620 RunTransactionTest(cache.http_cache(), transaction2); in TEST_F()
9621 EXPECT_EQ(3, cache.disk_cache()->open_count()); in TEST_F()
9629 RunTransactionTestWithResponse(cache.http_cache(), transaction2, &headers); in TEST_F()
9631 EXPECT_EQ(4, cache.network_layer()->transaction_count()); in TEST_F()
9632 EXPECT_EQ(4, cache.disk_cache()->open_count()); in TEST_F()
9633 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9635 RunTransactionTest(cache.http_cache(), transaction2); in TEST_F()
9636 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
9643 MockHttpCache cache; in TEST_F() local
9647 // Write to the cache (70-79). in TEST_F()
9651 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
9654 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
9655 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
9656 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9667 RunTransactionTestWithResponse(cache.http_cache(), transaction2, &headers); in TEST_F()
9673 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
9674 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
9675 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9683 MockHttpCache cache; in TEST_F() local
9687 // Write to the cache (40-49). in TEST_F()
9688 RunTransactionTestWithResponse(cache.http_cache(), kRangeGET_TransactionOK, in TEST_F()
9692 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
9693 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
9694 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9700 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
9703 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
9704 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
9705 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9707 RunTransactionTest(cache.http_cache(), kRangeGET_TransactionOK); in TEST_F()
9708 EXPECT_EQ(2, cache.disk_cache()->open_count()); in TEST_F()
9709 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9716 MockHttpCache cache; in TEST_F() local
9722 int rv = cache.CreateTransaction(&c->trans); in TEST_F()
9729 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
9730 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
9731 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9746 ASSERT_TRUE(cache.OpenBackendEntry(request.CacheKey(), &entry)); in TEST_F()
9754 MockHttpCache cache; in TEST_F() local
9760 int rv = cache.CreateTransaction(&context->trans); in TEST_F()
9768 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
9769 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
9770 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9786 VerifyTruncatedFlag(&cache, request.CacheKey(), false, 0); in TEST_F()
9793 MockHttpCache cache; in TEST_F() local
9796 RunTransactionTest(cache.http_cache(), kRangeGET_TransactionOK); in TEST_F()
9801 int rv = cache.CreateTransaction(&c->trans); in TEST_F()
9808 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
9809 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
9810 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9812 // Make sure that we revalidate the entry and read from the cache (a single in TEST_F()
9828 RunTransactionTest(cache.http_cache(), kRangeGET_TransactionOK); in TEST_F()
9830 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
9831 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
9832 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9839 MockHttpCache cache; in TEST_F() local
9842 RunTransactionTest(cache.http_cache(), kRangeGET_TransactionOK); in TEST_F()
9847 int rv = cache.CreateTransaction(&c->trans); in TEST_F()
9854 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
9855 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
9856 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9858 // Make sure that we revalidate the entry and read from the cache (a single in TEST_F()
9875 rv = cache.CreateTransaction(&c->trans); in TEST_F()
9891 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
9892 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
9893 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9899 MockHttpCache cache; in TEST_F() local
9907 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
9914 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
9915 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
9916 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9921 EXPECT_FALSE(cache.OpenBackendEntry(request.CacheKey(), &entry)); in TEST_F()
9928 MockHttpCache cache; in TEST_F() local
9936 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
9943 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
9944 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
9945 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9950 EXPECT_FALSE(cache.OpenBackendEntry(request.CacheKey(), &entry)); in TEST_F()
9958 MockHttpCache cache; in TEST_F() local
9968 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
9971 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
9972 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
9973 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9980 RunTransactionTestWithResponse(cache.http_cache(), kRangeGET_TransactionOK, in TEST_F()
9984 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
9985 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
9986 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
9989 RunTransactionTest(cache.http_cache(), kRangeGET_TransactionOK); in TEST_F()
9990 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
9991 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
9997 // We need a real sparse cache for this test. in TEST_F()
9998 MockHttpCache cache(HttpCache::DefaultBackend::InMemory(1024 * 1024)); in TEST_F() local
10010 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
10017 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
10022 ASSERT_TRUE(cache.OpenBackendEntry(request.CacheKey(), &en)); in TEST_F()
10028 // Tests that we don't crash with a range request if the disk cache was not
10034 MockHttpCache cache(std::move(factory)); in TEST_F() local
10038 RunTransactionTest(cache.http_cache(), kRangeGET_TransactionOK); in TEST_F()
10039 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
10044 // Tests that we handle byte range requests that skip the cache.
10046 MockHttpCache cache; in TEST_F() local
10055 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
10058 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
10059 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
10060 EXPECT_EQ(0, cache.disk_cache()->create_count()); in TEST_F()
10065 // Tests that we don't crash when after reading from the cache we issue a
10068 MockHttpCache cache; in TEST_F() local
10075 // Write to the cache. in TEST_F()
10076 RunTransactionTest(cache.http_cache(), kRangeGET_TransactionOK); in TEST_F()
10078 // And now read from the cache and the network. in TEST_F()
10083 RunTransactionTestWithLog(cache.http_cache(), transaction, in TEST_F()
10086 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_F()
10087 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
10088 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
10096 MockHttpCache cache; in TEST_F() local
10098 // First, check with an empty cache (WRITE mode). in TEST_F()
10109 // Write to the cache. in TEST_F()
10110 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
10112 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
10113 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
10114 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
10124 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
10126 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
10127 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
10128 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
10134 MockHttpCache cache; in TEST_F() local
10137 // Write to the cache (40-49). in TEST_F()
10138 RunTransactionTest(cache.http_cache(), kRangeGET_TransactionOK); in TEST_F()
10139 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
10140 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
10141 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
10143 // Force this transaction to read from the cache. in TEST_F()
10151 int rv = cache.http_cache()->CreateTransaction(DEFAULT_PRIORITY, &trans); in TEST_F()
10162 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
10163 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
10164 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
10171 MockHttpCache cache; in TEST_F() local
10173 ASSERT_TRUE(cache.CreateBackendEntry( in TEST_F()
10223 MockHttpCache cache; in TEST_F() local
10228 int rv = cache.CreateTransaction(&c->trans); in TEST_F()
10235 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
10236 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
10237 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
10243 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
10245 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
10246 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
10247 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
10253 MockHttpCache cache; in TEST_F() local
10258 int rv = cache.CreateTransaction(&c->trans); in TEST_F()
10265 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
10266 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
10267 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
10280 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
10282 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
10283 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
10284 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
10290 MockHttpCache cache; in TEST_F() local
10302 int rv = cache.CreateTransaction(&c->trans); in TEST_F()
10309 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
10310 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
10311 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
10324 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
10326 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
10327 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
10328 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
10335 MockHttpCache cache; in TEST_F() local
10346 int rv = cache.CreateTransaction(&c->trans); in TEST_F()
10353 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
10354 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
10355 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
10380 VerifyTruncatedFlag(&cache, request.CacheKey(), true, 0); in TEST_F()
10386 MockHttpCache cache; in TEST_F() local
10398 int rv = cache.CreateTransaction(&c->trans); in TEST_F()
10405 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
10406 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
10407 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
10439 ASSERT_FALSE(cache.OpenBackendEntry(request.CacheKey(), &entry)); in TEST_F()
10444 MockHttpCache cache; in TEST_F() local
10454 int rv = cache.CreateTransaction(&c->trans); in TEST_F()
10470 VerifyTruncatedFlag(&cache, request.CacheKey(), false, 0); in TEST_F()
10475 MockHttpCache cache; in TEST_F() local
10483 int rv = cache.http_cache()->CreateTransaction(DEFAULT_PRIORITY, &trans); in TEST_F()
10496 VerifyTruncatedFlag(&cache, request->CacheKey(), false, 0); in TEST_F()
10502 MockHttpCache cache; in TEST_F() local
10510 int rv = cache.http_cache()->CreateTransaction(DEFAULT_PRIORITY, &trans); in TEST_F()
10523 VerifyTruncatedFlag(&cache, request->CacheKey(), false, 0); in TEST_F()
10528 MockHttpCache cache; in TEST_F() local
10536 CreateTruncatedEntry(raw_headers, &cache); in TEST_F()
10542 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
10553 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
10554 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
10555 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
10559 VerifyTruncatedFlag(&cache, request.CacheKey(), false, 80); in TEST_F()
10564 MockHttpCache cache; in TEST_F() local
10572 CreateTruncatedEntry(raw_headers, &cache); in TEST_F()
10579 response_headers += ("Cache-Control: no-store\n"); in TEST_F()
10585 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
10592 "Cache-Control: no-store\n" in TEST_F()
10597 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
10598 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
10599 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
10604 EXPECT_FALSE(cache.OpenBackendEntry(request.CacheKey(), &entry)); in TEST_F()
10610 MockHttpCache cache; in TEST_F() local
10618 CreateTruncatedEntry(raw_headers, &cache); in TEST_F()
10625 response_headers += ("Cache-Control: no-store\n"); in TEST_F()
10633 int rv = cache.CreateTransaction(&c->trans); in TEST_F()
10641 ASSERT_THAT(cache.CreateTransaction(&pending->trans), IsOk()); in TEST_F()
10660 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
10661 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
10662 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
10670 MockHttpCache cache; in TEST_F() local
10679 CreateTruncatedEntry(raw_headers, &cache); in TEST_F()
10687 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
10695 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
10696 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
10697 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
10702 ASSERT_FALSE(cache.OpenBackendEntry(request.CacheKey(), &entry)); in TEST_F()
10708 MockHttpCache cache; in TEST_F() local
10715 "Cache-Control: max-age= 36000\n" in TEST_F()
10718 CreateTruncatedEntry(raw_headers, &cache); in TEST_F()
10727 int rv = cache.CreateTransaction(&c->trans); in TEST_F()
10735 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
10736 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
10737 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
10744 MockHttpCache cache; in TEST_F() local
10752 CreateTruncatedEntry(raw_headers, &cache); in TEST_F()
10762 int rv = cache.CreateTransaction(&c->trans); in TEST_F()
10780 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
10784 ASSERT_TRUE(cache.OpenBackendEntry(request.CacheKey(), &entry)); in TEST_F()
10793 MockHttpCache cache; in TEST_F() local
10795 // Cache 0-9, so that we have data to read before failing. in TEST_F()
10800 // Write to the cache. in TEST_F()
10801 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
10802 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
10804 // And now read from the cache and the network. 10-19 will get a in TEST_F()
10813 int rv = cache.CreateTransaction(&c->trans); in TEST_F()
10826 // Tests that we cache a 200 response to the validation request.
10828 MockHttpCache cache; in TEST_F() local
10836 CreateTruncatedEntry(raw_headers, &cache); in TEST_F()
10844 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); in TEST_F()
10846 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
10847 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
10848 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
10852 VerifyTruncatedFlag(&cache, request.CacheKey(), false, 11); in TEST_F()
10858 MockHttpCache cache; in TEST_F() local
10866 CreateTruncatedEntry(raw_headers, &cache); in TEST_F()
10873 int rv = cache.CreateTransaction(&c->trans); in TEST_F()
10879 // Read 20 bytes from the cache, and 10 from the net. in TEST_F()
10890 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
10891 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
10892 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
10895 VerifyTruncatedFlag(&cache, request.CacheKey(), true, 30); in TEST_F()
10900 MockHttpCache cache; in TEST_F() local
10909 CreateTruncatedEntry(raw_headers, &cache); in TEST_F()
10913 RunTransactionTestWithResponse(cache.http_cache(), kRangeGET_TransactionOK, in TEST_F()
10917 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
10918 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
10919 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
10925 MockHttpCache cache; in TEST_F() local
10939 TestTransactionConsumer c1(DEFAULT_PRIORITY, cache.http_cache()), in TEST_F()
10940 c2(DEFAULT_PRIORITY, cache.http_cache()), in TEST_F()
10941 c3(DEFAULT_PRIORITY, cache.http_cache()); in TEST_F()
10963 MockHttpCache cache; in TEST_F() local
10968 // write to the cache in TEST_F()
10969 RunTransactionTest(cache.http_cache(), kETagGET_Transaction); in TEST_F()
10971 // force this transaction to validate the cache in TEST_F()
10974 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
10976 // read from the cache in TEST_F()
10977 RunTransactionTest(cache.http_cache(), kETagGET_Transaction); in TEST_F()
10981 MockHttpCache cache; in TEST_F() local
10990 // Write to the cache. in TEST_F()
10993 ASSERT_THAT(cache.CreateTransaction(&trans), IsOk()); in TEST_F()
11015 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
11016 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
11017 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
11019 // Active entries in the cache are not retired synchronously. Make in TEST_F()
11024 // Read from the cache. in TEST_F()
11027 ASSERT_THAT(cache.CreateTransaction(&trans), IsOk()); in TEST_F()
11049 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
11050 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
11051 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
11054 // Verify that no-cache resources are stored in cache, but are not fetched from
11055 // cache during normal loads.
11058 MockHttpCache cache; in TEST_F() local
11059 cache.disk_cache()->set_support_in_memory_entry_data(use_memory_entry_data); in TEST_F()
11062 transaction.response_headers = "cache-control: no-cache\n"; in TEST_F()
11065 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
11067 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
11068 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
11069 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
11072 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
11074 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
11076 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
11077 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
11079 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
11080 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
11085 EXPECT_TRUE(cache.OpenBackendEntry(request.CacheKey(), &entry)); in TEST_F()
11090 // Verify that no-cache resources are stored in cache and fetched from cache
11093 MockHttpCache cache; in TEST_F() local
11096 transaction.response_headers = "cache-control: no-cache\n"; in TEST_F()
11099 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
11101 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
11102 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
11103 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
11107 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
11109 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
11110 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
11111 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
11115 EXPECT_TRUE(cache.OpenBackendEntry(request.CacheKey(), &entry)); in TEST_F()
11120 MockHttpCache cache; in TEST_F() local
11123 transaction.response_headers = "cache-control: no-store\n"; in TEST_F()
11126 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
11128 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
11129 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
11130 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
11133 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
11135 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
11136 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
11137 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
11141 EXPECT_FALSE(cache.OpenBackendEntry(request.CacheKey(), &entry)); in TEST_F()
11148 MockHttpCache cache; in TEST_F() local
11153 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
11155 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
11156 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
11157 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
11161 transaction.response_headers = "cache-control: no-store\n"; in TEST_F()
11162 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
11164 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
11165 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
11166 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
11170 EXPECT_FALSE(cache.OpenBackendEntry(request.CacheKey(), &entry)); in TEST_F()
11176 // a good thing to verify that we still destroy the cache entry. in TEST_F()
11177 MockHttpCache cache; in TEST_F() local
11182 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
11184 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
11185 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
11186 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
11190 transaction.response_headers = "cache-control: no-store\n"; in TEST_F()
11192 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
11194 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
11195 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
11196 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
11200 EXPECT_FALSE(cache.OpenBackendEntry(request.CacheKey(), &entry)); in TEST_F()
11203 // Ensure that we don't cache requests served over bad HTTPS.
11205 MockHttpCache cache; in TEST_F() local
11211 // write to the cache in TEST_F()
11212 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
11221 ASSERT_THAT(cache.CreateTransaction(&trans), IsOk()); in TEST_F()
11231 auto cache = std::make_unique<MockHttpCache>(); in TEST_F() local
11234 EXPECT_THAT(cache->CreateTransaction(&trans), IsOk()); in TEST_F()
11236 cache.reset(); in TEST_F()
11242 MockHttpCache cache; in TEST_F() local
11244 // write to the cache in TEST_F()
11245 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
11248 cache.http_cache()->set_mode(HttpCache::DISABLE); in TEST_F()
11250 // force this transaction to write to the cache again in TEST_F()
11253 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
11255 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
11256 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
11257 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
11266 MockHttpCache cache; in TEST_F() local
11276 // Request |kUrl|, causing |kNetResponse1| to be written to the cache. in TEST_F()
11293 RunTransactionTest(cache.http_cache(), request); in TEST_F()
11295 // Request |kUrl| again, this time validating the cache and getting in TEST_F()
11315 RunTransactionTestWithResponseInfo(cache.http_cache(), request, &response); in TEST_F()
11333 MockHttpCache cache; in TEST_P() local
11342 // result in a cache miss. in TEST_P()
11346 RunTransactionTestWithRequest(cache.http_cache(), kSimpleGET_Transaction, in TEST_P()
11350 // The second request should result in a cache hit. in TEST_P()
11351 RunTransactionTestWithRequest(cache.http_cache(), kSimpleGET_Transaction, in TEST_P()
11355 // Now request with b.com as the subframe origin. It should result in a cache in TEST_P()
11360 RunTransactionTestWithRequest(cache.http_cache(), kSimpleGET_Transaction, in TEST_P()
11364 // The second request should result in a cache hit. in TEST_P()
11365 RunTransactionTestWithRequest(cache.http_cache(), kSimpleGET_Transaction, in TEST_P()
11370 // still result in a cache hit. in TEST_P()
11374 RunTransactionTestWithRequest(cache.http_cache(), kSimpleGET_Transaction, in TEST_P()
11379 // anything to be added to the cache when the NIK makes use of the frame site. in TEST_P()
11381 // won't be in the cache at first regardless of the NIK partitioning scheme. in TEST_P()
11392 RunTransactionTestWithRequest(cache.http_cache(), kSimpleGET_Transaction, in TEST_P()
11396 // On the second request, expect a cache miss if the NIK uses the frame site. in TEST_P()
11397 RunTransactionTestWithRequest(cache.http_cache(), kSimpleGET_Transaction, in TEST_P()
11420 RunTransactionTestWithRequest(cache.http_cache(), kSimplePOST_Transaction, in TEST_P()
11427 MockHttpCache cache; in TEST_F() local
11447 RunTransactionTestWithRequest(cache.http_cache(), transaction, trans_info, in TEST_F()
11461 RunTransactionTestWithRequest(cache.http_cache(), transaction, trans_info, in TEST_F()
11470 MockHttpCache cache; in TEST_F() local
11490 RunTransactionTestWithRequest(cache.http_cache(), transaction, trans_info, in TEST_F()
11504 RunTransactionTestWithRequest(cache.http_cache(), transaction, trans_info, in TEST_F()
11513 MockHttpCache cache; in TEST_F() local
11533 RunTransactionTestWithRequest(cache.http_cache(), transaction, trans_info, in TEST_F()
11547 RunTransactionTestWithRequest(cache.http_cache(), transaction, trans_info, in TEST_F()
11555 MockHttpCache cache; in TEST_P() local
11563 // added to the cache. in TEST_P()
11567 RunTransactionTestWithRequest(cache.http_cache(), kSimpleGET_Transaction, in TEST_P()
11571 RunTransactionTestWithRequest(cache.http_cache(), kSimpleGET_Transaction, in TEST_P()
11576 // result in a cache miss since the cached resource has a different top frame in TEST_P()
11582 RunTransactionTestWithRequest(cache.http_cache(), kSimpleGET_Transaction, in TEST_P()
11586 // The second request should result in a cache hit. in TEST_P()
11587 RunTransactionTestWithRequest(cache.http_cache(), kSimpleGET_Transaction, in TEST_P()
11592 // it should not be a cache hit. in TEST_P()
11595 RunTransactionTestWithRequest(cache.http_cache(), kSimpleGET_Transaction, in TEST_P()
11599 // Same request again should be a cache hit. in TEST_P()
11600 RunTransactionTestWithRequest(cache.http_cache(), kSimpleGET_Transaction, in TEST_P()
11604 // Now request with b.com as the top frame origin. It should be a cache miss. in TEST_P()
11608 RunTransactionTestWithRequest(cache.http_cache(), kSimpleGET_Transaction, in TEST_P()
11612 // The second request should be a cache hit. in TEST_P()
11613 RunTransactionTestWithRequest(cache.http_cache(), kSimpleGET_Transaction, in TEST_P()
11617 // Another request for a.com should still result in a cache hit. in TEST_P()
11620 RunTransactionTestWithRequest(cache.http_cache(), kSimpleGET_Transaction, in TEST_P()
11625 // a cache hit. in TEST_P()
11630 RunTransactionTestWithRequest(cache.http_cache(), kSimpleGET_Transaction, in TEST_P()
11634 // On the second request, it still shouldn't result in a cache hit. in TEST_P()
11635 RunTransactionTestWithRequest(cache.http_cache(), kSimpleGET_Transaction, in TEST_P()
11654 RunTransactionTestWithRequest(cache.http_cache(), kSimplePOST_Transaction, in TEST_P()
11664 MockHttpCache cache; in TEST_F() local
11674 RunTransactionTestWithRequest(cache.http_cache(), kSimpleGET_Transaction, in TEST_F()
11678 // Subsequent requests with the same NIK and different NIK will be a cache hit in TEST_F()
11680 RunTransactionTestWithRequest(cache.http_cache(), kSimpleGET_Transaction, in TEST_F()
11688 RunTransactionTestWithRequest(cache.http_cache(), kSimpleGET_Transaction, in TEST_F()
11706 MockHttpCache cache; in TEST_P() local
11717 RunTransactionTestWithRequest(cache.http_cache(), kSimpleGET_Transaction, in TEST_P()
11722 // should be a cache hit. in TEST_P()
11727 RunTransactionTestWithRequest(cache.http_cache(), kSimpleGET_Transaction, in TEST_P()
11731 // Request with a different registrable domain. It should be a cache miss. in TEST_P()
11737 RunTransactionTestWithRequest(cache.http_cache(), kSimpleGET_Transaction, in TEST_P()
11747 MockHttpCache cache; in TEST_F() local
11750 // A request without a top frame is added to the cache normally. in TEST_F()
11754 RunTransactionTestWithRequest(cache.http_cache(), kSimpleGET_Transaction, in TEST_F()
11758 // The second request should result in a cache hit. in TEST_F()
11759 RunTransactionTestWithRequest(cache.http_cache(), kSimpleGET_Transaction, in TEST_F()
11769 RunTransactionTestWithRequest(cache.http_cache(), kSimpleGET_Transaction, in TEST_F()
11775 MockHttpCache cache; in TEST_F() local
11777 // Write a simple vary transaction to the cache. in TEST_F()
11783 "Cache-Control: max-age=10000\n"; in TEST_F()
11784 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
11791 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
11796 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
11800 MockHttpCache cache; in TEST_F() local
11802 // Write a simple vary:* transaction to the cache. in TEST_F()
11808 "Cache-Control: max-age=10000\n"; in TEST_F()
11809 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
11815 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
11820 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
11826 MockHttpCache cache; in TEST_F() local
11828 cache.http_cache()->SetClockForTesting(&clock); in TEST_F()
11829 cache.network_layer()->SetClock(&clock); in TEST_F()
11833 transaction.response_headers = "Cache-Control: max-age=100\n"; in TEST_F()
11834 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
11839 // Skipping cache validation should still return a response. in TEST_F()
11841 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
11843 // If the cache entry is checked for validitiy, it should fail. in TEST_F()
11846 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
11850 MockHttpCache cache; in TEST_F() local
11852 // Put the resource in the cache. in TEST_F()
11853 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
11856 // cache and network access. in TEST_F()
11858 // DevTools relies on this combination of flags for "disable cache" mode in TEST_F()
11859 // when a resource is only supposed to be loaded from cache. in TEST_F()
11862 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
11868 MockHttpCache cache; in TEST_F() local
11874 ASSERT_THAT(cache.CreateTransaction(&trans), IsOk()); in TEST_F()
11890 // Read from the cache. in TEST_F()
11891 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
11893 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
11894 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
11895 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
11898 // Tests that we don't mark entries as truncated and release the cache
11902 MockHttpCache cache; in TEST_F() local
11910 ASSERT_THAT(cache.CreateTransaction(&trans), IsOk()); in TEST_F()
11921 // Read from the cache. This should not deadlock. in TEST_F()
11922 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
11924 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
11925 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
11926 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
11931 MockHttpCache cache; in TEST_F() local
11937 ASSERT_THAT(cache.CreateTransaction(&trans), IsOk()); in TEST_F()
11959 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
11961 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
11962 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
11963 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
11969 MockHttpCache cache; in TEST_F() local
11975 ASSERT_THAT(cache.CreateTransaction(&trans), IsOk()); in TEST_F()
12000 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
12002 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
12003 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
12004 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
12009 MockHttpCache cache; in TEST_F() local
12018 ASSERT_THAT(cache.CreateTransaction(&trans), IsOk()); in TEST_F()
12031 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
12033 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
12034 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
12035 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
12040 MockHttpCache cache; in TEST_F() local
12046 ASSERT_THAT(cache.CreateTransaction(&trans), IsOk()); in TEST_F()
12051 mock_transaction.response_headers = "Cache-Control: max-age=10000\n" in TEST_F()
12072 // VerifyTruncatedFlag(&cache, kSimpleGET_Transaction.url, true, 0); in TEST_F()
12074 cache.disk_cache()->IsDiskEntryDoomed(request.CacheKey()); in TEST_F()
12079 MockHttpCache cache; in TEST_F() local
12091 CreateTruncatedEntry(raw_headers, &cache); in TEST_F()
12096 ASSERT_THAT(cache.CreateTransaction(&trans), IsOk()); in TEST_F()
12118 VerifyTruncatedFlag(&cache, request.CacheKey(), false, 80); in TEST_F()
12141 // CacheInitializer callbacks. These are used to initialize the cache
12144 // Initializes a cache containing a truncated entry containing the first 20
12146 static void SetupTruncatedCacheEntry(MockHttpCache* cache);
12148 // Initializes a cache containing a sparse entry. The first 10 bytes are
12149 // present in the cache.
12150 static void SetupPrefixSparseCacheEntry(MockHttpCache* cache);
12152 // Initializes a cache containing a sparse entry. The 10 bytes at offset
12153 // 99990 are present in the cache.
12154 static void SetupInfixSparseCacheEntry(MockHttpCache* cache);
12242 void HttpCacheHugeResourceTest::SetupTruncatedCacheEntry(MockHttpCache* cache) { in SetupTruncatedCacheEntry() argument
12251 CreateTruncatedEntry(cached_headers, cache); in SetupTruncatedCacheEntry()
12256 MockHttpCache* cache) { in SetupPrefixSparseCacheEntry() argument
12268 RunTransactionTestWithResponse(cache->http_cache(), transaction, &headers); in SetupPrefixSparseCacheEntry()
12274 MockHttpCache* cache) { in SetupInfixSparseCacheEntry() argument
12286 RunTransactionTestWithResponse(cache->http_cache(), transaction, &headers); in SetupInfixSparseCacheEntry()
12320 // fetched via GET. Various combinations of cache state and when StopCaching()
12330 MockHttpCache cache; in TEST_P() local
12331 (*cache_initializer)(&cache); in TEST_P()
12342 int rv = cache.http_cache()->CreateTransaction(net::DEFAULT_PRIORITY, in TEST_P()
12398 MockHttpCache cache; in TEST_F() local
12403 transaction.response_headers = "Cache-Control: max-age=10000\n" in TEST_F()
12405 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
12408 // Read from the cache. in TEST_F()
12409 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
12411 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
12412 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
12413 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_F()
12419 MockHttpCache cache; in TEST_F() local
12424 transaction.response_headers = "Cache-Control: max-age=10000\n" in TEST_F()
12427 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
12432 VerifyTruncatedFlag(&cache, request.CacheKey(), true, 0); in TEST_F()
12435 // Make sure that calling SetPriority on a cache transaction passes on
12438 MockHttpCache cache; in TEST_F() local
12442 ASSERT_THAT(cache.http_cache()->CreateTransaction(IDLE, &trans), IsOk()); in TEST_F()
12447 EXPECT_FALSE(cache.network_layer()->last_transaction()); in TEST_F()
12449 cache.network_layer()->last_create_transaction_priority()); in TEST_F()
12456 EXPECT_TRUE(cache.network_layer()->last_transaction()); in TEST_F()
12457 if (cache.network_layer()->last_transaction()) { in TEST_F()
12458 EXPECT_EQ(LOW, cache.network_layer()->last_create_transaction_priority()); in TEST_F()
12459 EXPECT_EQ(LOW, cache.network_layer()->last_transaction()->priority()); in TEST_F()
12464 if (cache.network_layer()->last_transaction()) { in TEST_F()
12465 EXPECT_EQ(LOW, cache.network_layer()->last_create_transaction_priority()); in TEST_F()
12466 EXPECT_EQ(HIGHEST, cache.network_layer()->last_transaction()->priority()); in TEST_F()
12472 // Make sure that calling SetWebSocketHandshakeStreamCreateHelper on a cache
12475 MockHttpCache cache; in TEST_F() local
12480 ASSERT_THAT(cache.http_cache()->CreateTransaction(IDLE, &trans), IsOk()); in TEST_F()
12482 EXPECT_FALSE(cache.network_layer()->last_transaction()); in TEST_F()
12489 ASSERT_TRUE(cache.network_layer()->last_transaction()); in TEST_F()
12490 EXPECT_FALSE(cache.network_layer()->last_transaction()-> in TEST_F()
12494 cache.network_layer()->last_transaction()-> in TEST_F()
12499 // Make sure that a cache transaction passes on its priority to
12502 MockHttpCache cache; in TEST_F() local
12510 CreateTruncatedEntry(raw_headers, &cache); in TEST_F()
12519 ASSERT_THAT(cache.http_cache()->CreateTransaction(MEDIUM, &trans), IsOk()); in TEST_F()
12521 cache.network_layer()->last_create_transaction_priority()); in TEST_F()
12529 EXPECT_EQ(MEDIUM, cache.network_layer()->last_create_transaction_priority()); in TEST_F()
12536 EXPECT_EQ(HIGHEST, cache.network_layer()->last_create_transaction_priority()); in TEST_F()
12543 void RunTransactionAndGetNetworkBytes(MockHttpCache* cache, in RunTransactionAndGetNetworkBytes() argument
12548 cache->http_cache(), trans_info, MockHttpRequest(trans_info), nullptr, in RunTransactionAndGetNetworkBytes()
12555 MockHttpCache cache; in TEST_F() local
12559 RunTransactionAndGetNetworkBytes(&cache, transaction, &sent, &received); in TEST_F()
12563 RunTransactionAndGetNetworkBytes(&cache, transaction, &sent, &received); in TEST_F()
12569 MockHttpCache cache; in TEST_F() local
12573 RunTransactionAndGetNetworkBytes(&cache, transaction, &sent, &received); in TEST_F()
12579 RunTransactionAndGetNetworkBytes(&cache, transaction, &sent, &received); in TEST_F()
12585 MockHttpCache cache; in TEST_F() local
12593 "Cache-Control: max-age=0\n" in TEST_F()
12597 RunTransactionAndGetNetworkBytes(&cache, transaction, &sent, &received); in TEST_F()
12604 RunTransactionAndGetNetworkBytes(&cache, transaction, &sent, &received); in TEST_F()
12612 MockHttpCache cache; in TEST_F() local
12618 RunTransactionAndGetNetworkBytes(&cache, transaction, &sent, &received); in TEST_F()
12622 // Read bytes 40-49 from the cache. in TEST_F()
12623 RunTransactionAndGetNetworkBytes(&cache, transaction, &sent, &received); in TEST_F()
12631 RunTransactionAndGetNetworkBytes(&cache, transaction, &sent, &received); in TEST_F()
12636 // Read bytes 20-29 and 50-59 from the network, bytes 30-49 from the cache. in TEST_F()
12639 RunTransactionAndGetNetworkBytes(&cache, transaction, &sent, &received); in TEST_F()
12658 transaction_.response_headers = "Cache-Control: max-age=100\n"; in HttpCachePrefetchValidationTest()
12674 // the cache.
12755 MockHttpCache cache; in TEST_F() local
12763 "Cache-Control: max-age=0,stale-while-revalidate=86400\n"; in TEST_F()
12765 // Write to the cache. in TEST_F()
12766 RunTransactionTest(cache.http_cache(), stale_while_revalidate_transaction); in TEST_F()
12768 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
12773 cache.http_cache(), stale_while_revalidate_transaction, &response_info); in TEST_F()
12775 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
12780 MockHttpCache cache; in TEST_F() local
12782 cache.http_cache()->SetClockForTesting(&clock); in TEST_F()
12783 cache.network_layer()->SetClock(&clock); in TEST_F()
12793 "Cache-Control: max-age=0,stale-while-revalidate=86400\n"; in TEST_F()
12795 // Write to the cache. in TEST_F()
12796 RunTransactionTest(cache.http_cache(), stale_while_revalidate_transaction); in TEST_F()
12798 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
12803 cache.http_cache(), stale_while_revalidate_transaction, &response_info); in TEST_F()
12805 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
12814 cache.http_cache(), stale_while_revalidate_transaction, &response_info); in TEST_F()
12816 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
12821 MockHttpCache cache; in TEST_F() local
12823 cache.http_cache()->SetClockForTesting(&clock); in TEST_F()
12824 cache.network_layer()->SetClock(&clock); in TEST_F()
12834 "Cache-Control: max-age=0,stale-while-revalidate=86400\n"; in TEST_F()
12836 // Write to the cache. in TEST_F()
12837 RunTransactionTest(cache.http_cache(), stale_while_revalidate_transaction); in TEST_F()
12839 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
12844 cache.http_cache(), stale_while_revalidate_transaction, &response_info); in TEST_F()
12846 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
12855 cache.http_cache(), stale_while_revalidate_transaction, &response_info); in TEST_F()
12857 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
12867 // Write 304 to the cache. in TEST_F()
12869 cache.http_cache(), stale_while_revalidate_transaction, &response_info); in TEST_F()
12871 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
12877 MockHttpCache cache; in TEST_F() local
12886 "Cache-Control: max-age=0,stale-while-revalidate=1800\n"; in TEST_F()
12888 // Write to the cache. in TEST_F()
12889 RunTransactionTest(cache.http_cache(), stale_while_revalidate_transaction); in TEST_F()
12891 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
12896 cache.http_cache(), stale_while_revalidate_transaction, &response_info); in TEST_F()
12898 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
12903 MockHttpCache cache; in TEST_F() local
12905 cache.http_cache()->SetClockForTesting(&clock); in TEST_F()
12906 cache.network_layer()->SetClock(&clock); in TEST_F()
12916 "Cache-Control: max-age=0,stale-while-revalidate=86400\n"; in TEST_F()
12918 // Write to the cache. in TEST_F()
12919 RunTransactionTest(cache.http_cache(), stale_while_revalidate_transaction); in TEST_F()
12921 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
12925 cache.disk_cache()->set_soft_failures_mask(MockDiskEntry::FAIL_WRITE); in TEST_F()
12928 cache.http_cache(), stale_while_revalidate_transaction, &response_info); in TEST_F()
12930 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
12936 MockHttpCache cache; in TEST_F() local
12947 int rv = cache.http_cache()->CreateTransaction(DEFAULT_PRIORITY, &trans); in TEST_F()
12957 RunTransactionTest(cache.http_cache(), kRangeGET_TransactionOK); in TEST_F()
12971 MockHttpCache cache; in TEST_F() local
12978 RunTransactionTest(cache.http_cache(), transaction); in TEST_F()
12979 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
12980 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
12981 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
12993 int rv = cache.http_cache()->CreateTransaction(DEFAULT_PRIORITY, &trans); in TEST_F()
13003 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
13004 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
13005 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
13008 // Makes sure that a request stops using the cache when the response headers
13009 // with "Cache-Control: no-store" arrives. That means that another request for
13013 MockHttpCache cache; in TEST_F() local
13015 mock_transaction.response_headers = "Cache-Control: no-store\n"; in TEST_F()
13019 first->result = cache.CreateTransaction(&first->trans); in TEST_F()
13030 "Cache-Control", "no-store")); in TEST_F()
13035 second->result = cache.CreateTransaction(&second->trans); in TEST_F()
13047 "Cache-Control", "no-store")); in TEST_F()
13051 // Tests that serving a response entirely from cache replays the previous
13063 MockHttpCache cache; in TEST_F() local
13071 RunTransactionTestWithResponseInfo(cache.http_cache(), transaction, in TEST_F()
13074 // The request should have hit the network and a cache entry created. in TEST_F()
13075 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
13076 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
13077 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
13085 RunTransactionTestWithResponseInfo(cache.http_cache(), transaction, in TEST_F()
13089 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
13090 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
13091 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
13116 MockHttpCache cache; in TEST_F() local
13124 RunTransactionTestWithResponseInfo(cache.http_cache(), transaction, in TEST_F()
13127 // The request should have hit the network and a cache entry created. in TEST_F()
13128 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_F()
13129 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_F()
13130 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
13144 transaction.request_headers = "Cache-Control: max-age=0\r\n"; in TEST_F()
13145 RunTransactionTestWithResponseInfo(cache.http_cache(), transaction, in TEST_F()
13149 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_F()
13150 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_F()
13151 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_F()
13160 MockHttpCache cache; in TEST_F() local
13163 RunTransactionTestWithResponseInfo(cache.http_cache(), kRangeGET_Transaction, in TEST_F()
13172 MockHttpCache cache; in TEST_F() local
13175 RunTransactionTestWithResponseInfo(cache.http_cache(), kSimpleGET_Transaction, in TEST_F()
13185 MockHttpCache cache; in TEST_F() local
13186 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); in TEST_F()
13189 RunTransactionTestWithResponseInfo(cache.http_cache(), kSimpleGET_Transaction, in TEST_F()
13198 MockHttpCache cache; in TEST_F() local
13199 RunTransactionTest(cache.http_cache(), kETagGET_Transaction); in TEST_F()
13206 RunTransactionTestWithResponseInfo(cache.http_cache(), still_valid, in TEST_F()
13216 MockHttpCache cache; in TEST_F() local
13217 RunTransactionTest(cache.http_cache(), kETagGET_Transaction); in TEST_F()
13223 RunTransactionTestWithResponseInfo(cache.http_cache(), update, in TEST_F()
13232 MockHttpCache cache; in TEST_F() local
13233 cache.FailConditionalizations(); in TEST_F()
13234 RunTransactionTest(cache.http_cache(), kTypicalGET_Transaction); in TEST_F()
13237 RunTransactionTestWithResponseInfo(cache.http_cache(), in TEST_F()
13250 MockHttpCache cache; in TEST_F() local
13310 MockHttpCache cache; in TEST_F() local
13313 std::make_unique<Transaction>(DEFAULT_PRIORITY, cache.http_cache()); in TEST_F()
13319 cache.backend(); in TEST_F()
13327 cache.disk_cache()->set_force_fail_callback_later(true); in TEST_F()
13330 int rv = DoomEntry(cache.http_cache(), m_transaction.url, transaction.get()); in TEST_F()
13332 cache.disk_cache()->set_force_fail_callback_later(false); in TEST_F()
13333 rv = OpenEntry(cache.http_cache(), m_transaction.url, &entry1, in TEST_F()
13349 MockHttpCache cache; in TEST_F() local
13352 std::make_unique<Transaction>(DEFAULT_PRIORITY, cache.http_cache()); in TEST_F()
13358 cache.backend(); in TEST_F()
13366 cache.disk_cache()->set_force_fail_callback_later(true); in TEST_F()
13369 int rv = DoomEntry(cache.http_cache(), m_transaction.url, transaction.get()); in TEST_F()
13371 cache.disk_cache()->set_force_fail_callback_later(false); in TEST_F()
13372 rv = CreateEntry(cache.http_cache(), m_transaction.url, &entry1, in TEST_F()
13388 MockHttpCache cache; in TEST_F() local
13391 std::make_unique<Transaction>(DEFAULT_PRIORITY, cache.http_cache()); in TEST_F()
13397 cache.backend(); in TEST_F()
13403 cache.disk_cache()->set_force_fail_callback_later(true); in TEST_F()
13406 int rv = DoomEntry(cache.http_cache(), m_transaction.url, transaction.get()); in TEST_F()
13408 cache.disk_cache()->set_force_fail_callback_later(false); in TEST_F()
13409 rv = DoomEntry(cache.http_cache(), m_transaction.url, transaction.get()); in TEST_F()
13423 MockHttpCache cache; in TEST_F() local
13426 std::make_unique<Transaction>(DEFAULT_PRIORITY, cache.http_cache()); in TEST_F()
13432 cache.backend(); in TEST_F()
13441 cache.disk_cache()->set_force_fail_callback_later(true); in TEST_F()
13444 int rv = OpenEntry(cache.http_cache(), m_transaction.url, &entry1, in TEST_F()
13447 cache.disk_cache()->set_force_fail_callback_later(false); in TEST_F()
13448 rv = CreateEntry(cache.http_cache(), m_transaction.url, &entry2, in TEST_F()
13465 MockHttpCache cache; in TEST_F() local
13468 std::make_unique<Transaction>(DEFAULT_PRIORITY, cache.http_cache()); in TEST_F()
13474 cache.backend(); in TEST_F()
13483 cache.disk_cache()->set_force_fail_callback_later(true); in TEST_F()
13486 int rv = CreateEntry(cache.http_cache(), m_transaction.url, &entry1, in TEST_F()
13489 cache.disk_cache()->set_force_fail_callback_later(false); in TEST_F()
13490 rv = OpenEntry(cache.http_cache(), m_transaction.url, &entry2, in TEST_F()
13507 MockHttpCache cache; in TEST_F() local
13510 std::make_unique<Transaction>(DEFAULT_PRIORITY, cache.http_cache()); in TEST_F()
13516 cache.backend(); in TEST_F()
13525 cache.disk_cache()->set_force_fail_callback_later(true); in TEST_F()
13528 int rv = CreateEntry(cache.http_cache(), m_transaction.url, &entry1, in TEST_F()
13531 cache.disk_cache()->set_force_fail_callback_later(false); in TEST_F()
13532 rv = CreateEntry(cache.http_cache(), m_transaction.url, &entry2, in TEST_F()
13548 MockHttpCache cache; in TEST_F() local
13551 std::make_unique<Transaction>(DEFAULT_PRIORITY, cache.http_cache()); in TEST_F()
13557 cache.backend(); in TEST_F()
13567 int rv = CreateEntry(cache.http_cache(), m_transaction.url, &entry1, in TEST_F()
13570 rv = CreateEntry(cache.http_cache(), m_transaction.url, &entry2, in TEST_F()
13587 MockHttpCache cache; in TEST_F() local
13590 std::make_unique<Transaction>(DEFAULT_PRIORITY, cache.http_cache()); in TEST_F()
13596 cache.backend(); in TEST_F()
13607 int rv = CreateEntry(cache.http_cache(), m_transaction.url, &entry1, in TEST_F()
13610 rv = DoomEntry(cache.http_cache(), m_transaction.url, transaction.get()); in TEST_F()
13624 MockHttpCache cache; in TEST_F() local
13627 std::make_unique<Transaction>(DEFAULT_PRIORITY, cache.http_cache()); in TEST_F()
13633 cache.backend(); in TEST_F()
13643 int rv = CreateEntry(cache.http_cache(), m_transaction.url, &entry1, in TEST_F()
13646 rv = OpenOrCreateEntry(cache.http_cache(), m_transaction.url, &entry2, in TEST_F()
13664 MockHttpCache cache; in TEST_F() local
13667 std::make_unique<Transaction>(DEFAULT_PRIORITY, cache.http_cache()); in TEST_F()
13673 cache.backend(); in TEST_F()
13682 cache.disk_cache()->set_force_fail_callback_later(true); in TEST_F()
13685 int rv = CreateEntry(cache.http_cache(), m_transaction.url, &entry1, in TEST_F()
13688 cache.disk_cache()->set_force_fail_callback_later(false); in TEST_F()
13689 rv = OpenOrCreateEntry(cache.http_cache(), m_transaction.url, &entry2, in TEST_F()
13706 MockHttpCache cache; in TEST_F() local
13709 std::make_unique<Transaction>(DEFAULT_PRIORITY, cache.http_cache()); in TEST_F()
13715 cache.backend(); in TEST_F()
13726 int rv = CreateEntry(cache.http_cache(), m_transaction.url, &entry0, in TEST_F()
13735 DeactivateEntry(cache.http_cache(), entry0); in TEST_F()
13738 rv = OpenEntry(cache.http_cache(), m_transaction.url, &entry1, in TEST_F()
13741 rv = OpenOrCreateEntry(cache.http_cache(), m_transaction.url, &entry2, in TEST_F()
13759 MockHttpCache cache; in TEST_F() local
13762 std::make_unique<Transaction>(DEFAULT_PRIORITY, cache.http_cache()); in TEST_F()
13768 cache.backend(); in TEST_F()
13777 cache.disk_cache()->set_force_fail_callback_later(true); in TEST_F()
13780 int rv = OpenEntry(cache.http_cache(), m_transaction.url, &entry1, in TEST_F()
13783 cache.disk_cache()->set_force_fail_callback_later(false); in TEST_F()
13784 rv = OpenOrCreateEntry(cache.http_cache(), m_transaction.url, &entry2, in TEST_F()
13801 MockHttpCache cache; in TEST_F() local
13804 std::make_unique<Transaction>(DEFAULT_PRIORITY, cache.http_cache()); in TEST_F()
13810 cache.backend(); in TEST_F()
13820 int rv = OpenOrCreateEntry(cache.http_cache(), m_transaction.url, &entry1, in TEST_F()
13823 rv = CreateEntry(cache.http_cache(), m_transaction.url, &entry2, in TEST_F()
13840 MockHttpCache cache; in TEST_F() local
13843 std::make_unique<Transaction>(DEFAULT_PRIORITY, cache.http_cache()); in TEST_F()
13849 cache.backend(); in TEST_F()
13859 int rv = OpenOrCreateEntry(cache.http_cache(), m_transaction.url, &entry1, in TEST_F()
13862 rv = OpenOrCreateEntry(cache.http_cache(), m_transaction.url, &entry2, in TEST_F()
13879 MockHttpCache cache; in TEST_F() local
13882 std::make_unique<Transaction>(DEFAULT_PRIORITY, cache.http_cache()); in TEST_F()
13888 cache.backend(); in TEST_F()
13897 cache.disk_cache()->set_force_fail_callback_later(true); in TEST_F()
13900 int rv = OpenOrCreateEntry(cache.http_cache(), m_transaction.url, &entry1, in TEST_F()
13903 cache.disk_cache()->set_force_fail_callback_later(false); in TEST_F()
13904 rv = OpenOrCreateEntry(cache.http_cache(), m_transaction.url, &entry2, in TEST_F()
13921 MockHttpCache cache; in TEST_F() local
13926 RunTransactionTestWithResponseInfo(cache.http_cache(), transaction, in TEST_F()
13931 // The second request result in a cache hit and the response used without in TEST_F()
13935 RunTransactionTestWithResponseInfo(cache.http_cache(), transaction, in TEST_F()
13942 MockHttpCache cache; in TEST_F() local
13947 RunTransactionTestWithResponseInfo(cache.http_cache(), transaction, in TEST_F()
13952 // The second request should result in a cache hit and the response used in TEST_F()
13956 RunTransactionTestWithResponseInfo(cache.http_cache(), transaction, in TEST_F()
13963 MockHttpCache cache; in TEST_F() local
13969 "Cache-Control: max-age=0\n"; in TEST_F()
13972 RunTransactionTestWithResponseInfo(cache.http_cache(), transaction, in TEST_F()
13977 // On the second request, the cache should be revalidated. Change the aliases in TEST_F()
13980 transaction.response_headers = "Cache-Control: max-age=10000\n"; in TEST_F()
13982 RunTransactionTestWithResponseInfo(cache.http_cache(), transaction, in TEST_F()
13988 RunTransactionTestWithResponseInfo(cache.http_cache(), transaction, in TEST_F()
13995 MockHttpCache cache; in TEST_F() local
13999 RunTransactionTestWithResponseInfo(cache.http_cache(), transaction, in TEST_F()
14004 RunTransactionTestWithResponseInfo(cache.http_cache(), transaction, in TEST_F()
14010 MockHttpCache cache; in TEST_F() local
14015 RunTransactionTestWithResponseInfo(cache.http_cache(), transaction, in TEST_F()
14022 RunTransactionTestWithResponseInfo(cache.http_cache(), transaction, in TEST_F()
14028 MockHttpCache cache; in TEST_F() local
14033 RunTransactionTestWithResponseInfo(cache.http_cache(), transaction, in TEST_F()
14040 RunTransactionTestWithResponseInfo(cache.http_cache(), transaction, in TEST_F()
14046 MockHttpCache cache; in TEST_F() local
14050 RunTransactionTestWithResponseInfo(cache.http_cache(), transaction, in TEST_F()
14054 RunTransactionTestWithResponseInfo(cache.http_cache(), transaction, in TEST_F()
14060 MockHttpCache cache; in TEST_F() local
14080 RunTransactionTestWithResponseInfo(cache.http_cache(), transaction, in TEST_F()
14083 // On the second request, the cache is revalidated. in TEST_F()
14088 RunTransactionTestWithResponseInfo(cache.http_cache(), transaction, in TEST_F()
14103 // The single-keyed cache feature is meaningless when the split cache is not in CacheTransparencyHttpCacheTest()
14111 HttpCache* cache, in RunTransactionTestForSingleKeyedCache() argument
14125 RunTransactionTestWithRequest(cache, transaction, request, &response_info); in RunTransactionTestForSingleKeyedCache()
14129 HttpCache* cache, in RunSimpleTransactionTestForSingleKeyedCache() argument
14132 RunTransactionTestForSingleKeyedCache(cache, kSimpleGET_Transaction, in RunSimpleTransactionTestForSingleKeyedCache()
14157 MockHttpCache cache; in TEST_P() local
14158 // The first request adds the item to the cache. in TEST_P()
14162 cache.http_cache(), NetworkIsolationKey(site_a, site_a), in TEST_P()
14165 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_P()
14166 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_P()
14167 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_P()
14170 // The second request verifies that the same cache entry is used with a in TEST_P()
14175 cache.http_cache(), NetworkIsolationKey(site_b, site_b), in TEST_P()
14178 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_P()
14179 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_P()
14180 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_P()
14185 MockHttpCache cache; in TEST_P() local
14187 // The first request adds the item to the cache. in TEST_P()
14190 cache.http_cache(), NetworkIsolationKey(site_a, site_a), in TEST_P()
14193 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_P()
14194 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_P()
14195 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_P()
14199 // cache, but adds it to the split cache instead. in TEST_P()
14202 cache.http_cache(), NetworkIsolationKey(site_a, site_a), in TEST_P()
14205 // Fetches from the network again, this time into the split cache. in TEST_P()
14206 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_P()
14207 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_P()
14208 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_P()
14211 // The third request uses the split cache. in TEST_P()
14214 cache.http_cache(), NetworkIsolationKey(site_a, site_a), in TEST_P()
14217 // Fetches from the split cache. in TEST_P()
14218 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_P()
14219 EXPECT_EQ(3, cache.disk_cache()->open_count()); // opens both cache entries in TEST_P()
14220 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_P()
14225 MockHttpCache cache; in TEST_P() local
14229 // The first request adds the item to the single-keyed cache. in TEST_P()
14231 RunTransactionTestForSingleKeyedCache(cache.http_cache(), transaction, in TEST_P()
14235 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_P()
14236 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_P()
14237 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_P()
14240 // The second request verifies that the cache entry is not re-used in TEST_P()
14241 // but a new one is created in the split cache. in TEST_P()
14243 RunTransactionTestForSingleKeyedCache(cache.http_cache(), transaction, in TEST_P()
14247 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_P()
14248 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_P()
14249 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_P()
14257 MockHttpCache cache; in TEST_P() local
14261 // The first request adds the item to the single-keyed cache. in TEST_P()
14263 RunTransactionTestForSingleKeyedCache(cache.http_cache(), transaction, in TEST_P()
14267 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_P()
14268 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_P()
14269 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_P()
14272 // The second request verifies that the cache entry is not re-used in TEST_P()
14273 // but a new one is created in the split cache. in TEST_P()
14275 RunTransactionTestForSingleKeyedCache(cache.http_cache(), transaction, in TEST_P()
14279 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_P()
14280 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_P()
14281 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_P()
14286 MockHttpCache cache; in TEST_P() local
14294 RunTransactionTestForSingleKeyedCache(cache.http_cache(), transaction, in TEST_P()
14298 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_P()
14299 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_P()
14300 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_P()
14305 RunTransactionTestForSingleKeyedCache(cache.http_cache(), transaction, in TEST_P()
14309 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_P()
14310 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_P()
14311 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_P()
14316 MockHttpCache cache; in TEST_P() local
14318 // Add a cache control header to permit the entry to be cached, with max-age 0 in TEST_P()
14322 "Cache-Control: max-age=0\n"; in TEST_P()
14325 RunTransactionTestForSingleKeyedCache(cache.http_cache(), transaction, in TEST_P()
14329 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_P()
14330 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_P()
14331 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_P()
14341 "Cache-Control: max-age=10000\n"; in TEST_P()
14342 RunTransactionTestForSingleKeyedCache(cache.http_cache(), transaction, in TEST_P()
14346 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_P()
14347 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_P()
14348 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_P()
14354 // Load from cache again. in TEST_P()
14355 RunTransactionTestForSingleKeyedCache(cache.http_cache(), transaction, in TEST_P()
14359 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_P()
14360 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_P()
14361 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_P()
14366 MockHttpCache cache; in TEST_P() local
14368 // Add a cache control header to permit the entry to be cached, with max-age 0 in TEST_P()
14372 "Cache-Control: max-age=0\n"; in TEST_P()
14375 RunTransactionTestForSingleKeyedCache(cache.http_cache(), transaction, in TEST_P()
14379 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_P()
14380 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_P()
14381 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_P()
14392 "Cache-Control: max-age=10000\n" in TEST_P()
14394 RunTransactionTestForSingleKeyedCache(cache.http_cache(), transaction, in TEST_P()
14398 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_P()
14399 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_P()
14400 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_P()
14406 // Load from cache again. in TEST_P()
14407 RunTransactionTestForSingleKeyedCache(cache.http_cache(), transaction, in TEST_P()
14411 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_P()
14412 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_P()
14413 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_P()
14418 MockHttpCache cache; in TEST_P() local
14420 // Add a cache control header to permit the entry to be cached, with max-age 0 in TEST_P()
14424 "Cache-Control: max-age=0\n"; in TEST_P()
14427 RunTransactionTestForSingleKeyedCache(cache.http_cache(), transaction, in TEST_P()
14431 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_P()
14432 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_P()
14433 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_P()
14436 // The second request marks the single-keyed cache entry unusable because the in TEST_P()
14444 "Cache-Control: max-age=10000\n" in TEST_P()
14446 RunTransactionTestForSingleKeyedCache(cache.http_cache(), transaction, in TEST_P()
14450 EXPECT_EQ(2, cache.network_layer()->transaction_count()); in TEST_P()
14451 EXPECT_EQ(1, cache.disk_cache()->open_count()); in TEST_P()
14452 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_P()
14455 // The third request has to go to the network because the single-keyed cache in TEST_P()
14456 // entry is unusable. It writes a new entry to the split cache. in TEST_P()
14459 RunTransactionTestForSingleKeyedCache(cache.http_cache(), transaction, in TEST_P()
14463 EXPECT_EQ(3, cache.network_layer()->transaction_count()); in TEST_P()
14464 EXPECT_EQ(2, cache.disk_cache()->open_count()); in TEST_P()
14465 EXPECT_EQ(2, cache.disk_cache()->create_count()); in TEST_P()
14470 MockHttpCache cache; in TEST_P() local
14479 c.result = cache.CreateTransaction(&c.trans); in TEST_P()
14489 std::string cache_key = cache.http_cache() in TEST_P()
14493 EXPECT_EQ(kNumTransactions, cache.GetCountWriterTransactions(cache_key)); in TEST_P()
14497 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_P()
14498 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_P()
14499 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_P()
14506 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_P()
14507 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_P()
14508 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_P()
14512 MockHttpCache cache; in TEST_P() local
14522 c.result = cache.CreateTransaction(&c.trans); in TEST_P()
14532 std::string cache_key = cache.http_cache() in TEST_P()
14536 EXPECT_EQ(kNumTransactions, cache.GetCountWriterTransactions(cache_key)); in TEST_P()
14540 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_P()
14541 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_P()
14542 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_P()
14549 EXPECT_EQ(1, cache.network_layer()->transaction_count()); in TEST_P()
14550 EXPECT_EQ(0, cache.disk_cache()->open_count()); in TEST_P()
14551 EXPECT_EQ(1, cache.disk_cache()->create_count()); in TEST_P()