Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/http/http_cache.h" | 5 #include "net/http/http_cache.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 5298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5309 EXPECT_EQ(location, "http://www.bar.com/"); | 5309 EXPECT_EQ(location, "http://www.bar.com/"); |
| 5310 | 5310 |
| 5311 // Destroy transaction when going out of scope. We have not actually | 5311 // Destroy transaction when going out of scope. We have not actually |
| 5312 // read the response body -- want to test that it is still getting cached. | 5312 // read the response body -- want to test that it is still getting cached. |
| 5313 } | 5313 } |
| 5314 EXPECT_EQ(1, cache.network_layer()->transaction_count()); | 5314 EXPECT_EQ(1, cache.network_layer()->transaction_count()); |
| 5315 EXPECT_EQ(1, cache.disk_cache()->open_count()); | 5315 EXPECT_EQ(1, cache.disk_cache()->open_count()); |
| 5316 EXPECT_EQ(1, cache.disk_cache()->create_count()); | 5316 EXPECT_EQ(1, cache.disk_cache()->create_count()); |
| 5317 } | 5317 } |
| 5318 | 5318 |
| 5319 // Verify that no-cache resources are stored in cache, but are not fetched from | |
|
Jun Mukai
2013/07/31 23:10:00
why these tests are removed?
oshima
2013/07/31 23:29:26
This change has already been reverted and shouldn'
| |
| 5320 // cache during normal loads. | |
| 5321 TEST(HttpCache, CacheControlNoCacheNormalLoad) { | |
| 5322 MockHttpCache cache; | |
| 5323 | |
| 5324 ScopedMockTransaction transaction(kSimpleGET_Transaction); | |
| 5325 transaction.response_headers = "cache-control: no-cache\n"; | |
| 5326 | |
| 5327 // Initial load. | |
| 5328 RunTransactionTest(cache.http_cache(), transaction); | |
| 5329 | |
| 5330 EXPECT_EQ(1, cache.network_layer()->transaction_count()); | |
| 5331 EXPECT_EQ(0, cache.disk_cache()->open_count()); | |
| 5332 EXPECT_EQ(1, cache.disk_cache()->create_count()); | |
| 5333 | |
| 5334 // Try loading again; it should result in a network fetch. | |
| 5335 RunTransactionTest(cache.http_cache(), transaction); | |
| 5336 | |
| 5337 EXPECT_EQ(2, cache.network_layer()->transaction_count()); | |
| 5338 EXPECT_EQ(1, cache.disk_cache()->open_count()); | |
| 5339 EXPECT_EQ(1, cache.disk_cache()->create_count()); | |
| 5340 | |
| 5341 disk_cache::Entry* entry; | |
| 5342 EXPECT_TRUE(cache.OpenBackendEntry(transaction.url, &entry)); | |
| 5343 } | |
| 5344 | |
| 5345 // Verify that no-cache resources are stored in cache and fetched from cache | |
| 5346 // when the LOAD_PREFERRING_CACHE flag is set. | |
| 5347 TEST(HttpCache, CacheControlNoCacheHistoryLoad) { | |
| 5348 MockHttpCache cache; | |
| 5349 | |
| 5350 ScopedMockTransaction transaction(kSimpleGET_Transaction); | |
| 5351 transaction.response_headers = "cache-control: no-cache\n"; | |
| 5352 | |
| 5353 // Initial load. | |
| 5354 RunTransactionTest(cache.http_cache(), transaction); | |
| 5355 | |
| 5356 EXPECT_EQ(1, cache.network_layer()->transaction_count()); | |
| 5357 EXPECT_EQ(0, cache.disk_cache()->open_count()); | |
| 5358 EXPECT_EQ(1, cache.disk_cache()->create_count()); | |
| 5359 | |
| 5360 // Try loading again with LOAD_PREFERRING_CACHE. | |
| 5361 transaction.load_flags = net::LOAD_PREFERRING_CACHE; | |
| 5362 RunTransactionTest(cache.http_cache(), transaction); | |
| 5363 | |
| 5364 EXPECT_EQ(1, cache.network_layer()->transaction_count()); | |
| 5365 EXPECT_EQ(1, cache.disk_cache()->open_count()); | |
| 5366 EXPECT_EQ(1, cache.disk_cache()->create_count()); | |
| 5367 | |
| 5368 disk_cache::Entry* entry; | |
| 5369 EXPECT_TRUE(cache.OpenBackendEntry(transaction.url, &entry)); | |
| 5370 } | |
| 5371 | |
| 5372 TEST(HttpCache, CacheControlNoStore) { | 5319 TEST(HttpCache, CacheControlNoStore) { |
| 5373 MockHttpCache cache; | 5320 MockHttpCache cache; |
| 5374 | 5321 |
| 5375 ScopedMockTransaction transaction(kSimpleGET_Transaction); | 5322 ScopedMockTransaction transaction(kSimpleGET_Transaction); |
| 5376 transaction.response_headers = "cache-control: no-store\n"; | 5323 transaction.response_headers = "cache-control: no-store\n"; |
| 5377 | 5324 |
| 5378 // initial load | 5325 // initial load |
| 5379 RunTransactionTest(cache.http_cache(), transaction); | 5326 RunTransactionTest(cache.http_cache(), transaction); |
| 5380 | 5327 |
| 5381 EXPECT_EQ(1, cache.network_layer()->transaction_count()); | 5328 EXPECT_EQ(1, cache.network_layer()->transaction_count()); |
| (...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6047 trans->SetPriority(net::HIGHEST); | 5994 trans->SetPriority(net::HIGHEST); |
| 6048 // Should trigger a new network transaction and pick up the new | 5995 // Should trigger a new network transaction and pick up the new |
| 6049 // priority. | 5996 // priority. |
| 6050 ReadAndVerifyTransaction(trans.get(), transaction); | 5997 ReadAndVerifyTransaction(trans.get(), transaction); |
| 6051 | 5998 |
| 6052 EXPECT_EQ(net::HIGHEST, | 5999 EXPECT_EQ(net::HIGHEST, |
| 6053 cache.network_layer()->last_create_transaction_priority()); | 6000 cache.network_layer()->last_create_transaction_priority()); |
| 6054 | 6001 |
| 6055 RemoveMockTransaction(&kRangeGET_TransactionOK); | 6002 RemoveMockTransaction(&kRangeGET_TransactionOK); |
| 6056 } | 6003 } |
| OLD | NEW |