Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Side by Side Diff: net/http/http_cache_unittest.cc

Issue 672773002: Http cache: Fix DCHECK with POSTs and a disabled cache. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 2722 matching lines...) Expand 10 before | Expand all | Expand 10 after
2733 TEST(HttpCache, SimplePOST_SkipsCache) { 2733 TEST(HttpCache, SimplePOST_SkipsCache) {
2734 MockHttpCache cache; 2734 MockHttpCache cache;
2735 2735
2736 RunTransactionTest(cache.http_cache(), kSimplePOST_Transaction); 2736 RunTransactionTest(cache.http_cache(), kSimplePOST_Transaction);
2737 2737
2738 EXPECT_EQ(1, cache.network_layer()->transaction_count()); 2738 EXPECT_EQ(1, cache.network_layer()->transaction_count());
2739 EXPECT_EQ(0, cache.disk_cache()->open_count()); 2739 EXPECT_EQ(0, cache.disk_cache()->open_count());
2740 EXPECT_EQ(0, cache.disk_cache()->create_count()); 2740 EXPECT_EQ(0, cache.disk_cache()->create_count());
2741 } 2741 }
2742 2742
2743 // Tests POST handling with a disabled cache (no DCHECK).
2744 TEST(HttpCache, SimplePOST_DisabledCache) {
2745 MockHttpCache cache;
2746 cache.http_cache()->set_mode(net::HttpCache::Mode::DISABLE);
2747
2748 RunTransactionTest(cache.http_cache(), kSimplePOST_Transaction);
2749
2750 EXPECT_EQ(1, cache.network_layer()->transaction_count());
2751 EXPECT_EQ(0, cache.disk_cache()->open_count());
2752 EXPECT_EQ(0, cache.disk_cache()->create_count());
2753 }
2754
2743 TEST(HttpCache, SimplePOST_LoadOnlyFromCache_Miss) { 2755 TEST(HttpCache, SimplePOST_LoadOnlyFromCache_Miss) {
2744 MockHttpCache cache; 2756 MockHttpCache cache;
2745 2757
2746 MockTransaction transaction(kSimplePOST_Transaction); 2758 MockTransaction transaction(kSimplePOST_Transaction);
2747 transaction.load_flags |= net::LOAD_ONLY_FROM_CACHE; 2759 transaction.load_flags |= net::LOAD_ONLY_FROM_CACHE;
2748 2760
2749 MockHttpRequest request(transaction); 2761 MockHttpRequest request(transaction);
2750 net::TestCompletionCallback callback; 2762 net::TestCompletionCallback callback;
2751 2763
2752 scoped_ptr<net::HttpTransaction> trans; 2764 scoped_ptr<net::HttpTransaction> trans;
(...skipping 4575 matching lines...) Expand 10 before | Expand all | Expand 10 after
7328 7340
7329 // Here the second transaction proceeds without reading the first body. 7341 // Here the second transaction proceeds without reading the first body.
7330 EXPECT_EQ(net::LOAD_STATE_WAITING_FOR_CACHE, second->trans->GetLoadState()); 7342 EXPECT_EQ(net::LOAD_STATE_WAITING_FOR_CACHE, second->trans->GetLoadState());
7331 base::MessageLoop::current()->RunUntilIdle(); 7343 base::MessageLoop::current()->RunUntilIdle();
7332 EXPECT_EQ(net::LOAD_STATE_IDLE, second->trans->GetLoadState()); 7344 EXPECT_EQ(net::LOAD_STATE_IDLE, second->trans->GetLoadState());
7333 ASSERT_TRUE(second->trans->GetResponseInfo()); 7345 ASSERT_TRUE(second->trans->GetResponseInfo());
7334 EXPECT_TRUE(second->trans->GetResponseInfo()->headers->HasHeaderValue( 7346 EXPECT_TRUE(second->trans->GetResponseInfo()->headers->HasHeaderValue(
7335 "Cache-Control", "no-store")); 7347 "Cache-Control", "no-store"));
7336 ReadAndVerifyTransaction(second->trans.get(), kSimpleGET_Transaction); 7348 ReadAndVerifyTransaction(second->trans.get(), kSimpleGET_Transaction);
7337 } 7349 }
OLDNEW
« net/http/http_cache_transaction.cc ('K') | « net/http/http_cache_transaction.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698