| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 2723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2734 TEST(HttpCache, SimplePOST_SkipsCache) { | 2734 TEST(HttpCache, SimplePOST_SkipsCache) { |
| 2735 MockHttpCache cache; | 2735 MockHttpCache cache; |
| 2736 | 2736 |
| 2737 RunTransactionTest(cache.http_cache(), kSimplePOST_Transaction); | 2737 RunTransactionTest(cache.http_cache(), kSimplePOST_Transaction); |
| 2738 | 2738 |
| 2739 EXPECT_EQ(1, cache.network_layer()->transaction_count()); | 2739 EXPECT_EQ(1, cache.network_layer()->transaction_count()); |
| 2740 EXPECT_EQ(0, cache.disk_cache()->open_count()); | 2740 EXPECT_EQ(0, cache.disk_cache()->open_count()); |
| 2741 EXPECT_EQ(0, cache.disk_cache()->create_count()); | 2741 EXPECT_EQ(0, cache.disk_cache()->create_count()); |
| 2742 } | 2742 } |
| 2743 | 2743 |
| 2744 // Tests POST handling with a disabled cache (no DCHECK). |
| 2745 TEST(HttpCache, SimplePOST_DisabledCache) { |
| 2746 MockHttpCache cache; |
| 2747 cache.http_cache()->set_mode(net::HttpCache::Mode::DISABLE); |
| 2748 |
| 2749 RunTransactionTest(cache.http_cache(), kSimplePOST_Transaction); |
| 2750 |
| 2751 EXPECT_EQ(1, cache.network_layer()->transaction_count()); |
| 2752 EXPECT_EQ(0, cache.disk_cache()->open_count()); |
| 2753 EXPECT_EQ(0, cache.disk_cache()->create_count()); |
| 2754 } |
| 2755 |
| 2744 TEST(HttpCache, SimplePOST_LoadOnlyFromCache_Miss) { | 2756 TEST(HttpCache, SimplePOST_LoadOnlyFromCache_Miss) { |
| 2745 MockHttpCache cache; | 2757 MockHttpCache cache; |
| 2746 | 2758 |
| 2747 MockTransaction transaction(kSimplePOST_Transaction); | 2759 MockTransaction transaction(kSimplePOST_Transaction); |
| 2748 transaction.load_flags |= net::LOAD_ONLY_FROM_CACHE; | 2760 transaction.load_flags |= net::LOAD_ONLY_FROM_CACHE; |
| 2749 | 2761 |
| 2750 MockHttpRequest request(transaction); | 2762 MockHttpRequest request(transaction); |
| 2751 net::TestCompletionCallback callback; | 2763 net::TestCompletionCallback callback; |
| 2752 | 2764 |
| 2753 scoped_ptr<net::HttpTransaction> trans; | 2765 scoped_ptr<net::HttpTransaction> trans; |
| (...skipping 4575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7329 | 7341 |
| 7330 // Here the second transaction proceeds without reading the first body. | 7342 // Here the second transaction proceeds without reading the first body. |
| 7331 EXPECT_EQ(net::LOAD_STATE_WAITING_FOR_CACHE, second->trans->GetLoadState()); | 7343 EXPECT_EQ(net::LOAD_STATE_WAITING_FOR_CACHE, second->trans->GetLoadState()); |
| 7332 base::MessageLoop::current()->RunUntilIdle(); | 7344 base::MessageLoop::current()->RunUntilIdle(); |
| 7333 EXPECT_EQ(net::LOAD_STATE_IDLE, second->trans->GetLoadState()); | 7345 EXPECT_EQ(net::LOAD_STATE_IDLE, second->trans->GetLoadState()); |
| 7334 ASSERT_TRUE(second->trans->GetResponseInfo()); | 7346 ASSERT_TRUE(second->trans->GetResponseInfo()); |
| 7335 EXPECT_TRUE(second->trans->GetResponseInfo()->headers->HasHeaderValue( | 7347 EXPECT_TRUE(second->trans->GetResponseInfo()->headers->HasHeaderValue( |
| 7336 "Cache-Control", "no-store")); | 7348 "Cache-Control", "no-store")); |
| 7337 ReadAndVerifyTransaction(second->trans.get(), kSimpleGET_Transaction); | 7349 ReadAndVerifyTransaction(second->trans.get(), kSimpleGET_Transaction); |
| 7338 } | 7350 } |
| OLD | NEW |