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

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

Issue 2517983002: [DevTools] Properly handle cache-only requests when cache is disabled (Closed)
Patch Set: Created 4 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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 6726 matching lines...) Expand 10 before | Expand all | Expand 10 after
6737 6737
6738 RunTransactionTestWithResponseInfo(cache.http_cache(), kSimpleGET_Transaction, 6738 RunTransactionTestWithResponseInfo(cache.http_cache(), kSimpleGET_Transaction,
6739 &response); 6739 &response);
6740 EXPECT_TRUE(response.metadata.get() == NULL); 6740 EXPECT_TRUE(response.metadata.get() == NULL);
6741 6741
6742 EXPECT_EQ(1, cache.network_layer()->transaction_count()); 6742 EXPECT_EQ(1, cache.network_layer()->transaction_count());
6743 EXPECT_EQ(2, cache.disk_cache()->open_count()); 6743 EXPECT_EQ(2, cache.disk_cache()->open_count());
6744 EXPECT_EQ(1, cache.disk_cache()->create_count()); 6744 EXPECT_EQ(1, cache.disk_cache()->create_count());
6745 } 6745 }
6746 6746
6747 TEST(HttpCache, InvalidLoadFlagCombination) {
6748 MockHttpCache cache;
6749
6750 // Put the resource in the cache.
6751 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction);
6752
6753 // Now try to fetch it again, but with a flag combination disallowing both
6754 // cache and network access.
6755 ScopedMockTransaction transaction(kSimpleGET_Transaction);
6756 // DevTools relies on this combination of flags for "disable cache" mode
6757 // when a resource is only supposed to be loaded from cache.
6758 transaction.load_flags = LOAD_ONLY_FROM_CACHE | LOAD_BYPASS_CACHE;
6759 transaction.return_code = ERR_CACHE_MISS;
6760 RunTransactionTest(cache.http_cache(), transaction);
6761 }
6762
6747 // Tests that we can read metadata after validating the entry and with READ mode 6763 // Tests that we can read metadata after validating the entry and with READ mode
6748 // transactions. 6764 // transactions.
6749 TEST(HttpCache, ReadMetadata) { 6765 TEST(HttpCache, ReadMetadata) {
6750 MockHttpCache cache; 6766 MockHttpCache cache;
6751 6767
6752 // Write to the cache 6768 // Write to the cache
6753 HttpResponseInfo response; 6769 HttpResponseInfo response;
6754 RunTransactionTestWithResponseInfo(cache.http_cache(), 6770 RunTransactionTestWithResponseInfo(cache.http_cache(),
6755 kTypicalGET_Transaction, &response); 6771 kTypicalGET_Transaction, &response);
6756 EXPECT_TRUE(response.metadata.get() == NULL); 6772 EXPECT_TRUE(response.metadata.get() == NULL);
(...skipping 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after
8102 RunTransactionTestWithResponseInfo(cache.http_cache(), 8118 RunTransactionTestWithResponseInfo(cache.http_cache(),
8103 kTypicalGET_Transaction, &response_info); 8119 kTypicalGET_Transaction, &response_info);
8104 8120
8105 EXPECT_FALSE(response_info.was_cached); 8121 EXPECT_FALSE(response_info.was_cached);
8106 EXPECT_TRUE(response_info.network_accessed); 8122 EXPECT_TRUE(response_info.network_accessed);
8107 EXPECT_EQ(CacheEntryStatus::ENTRY_CANT_CONDITIONALIZE, 8123 EXPECT_EQ(CacheEntryStatus::ENTRY_CANT_CONDITIONALIZE,
8108 response_info.cache_entry_status); 8124 response_info.cache_entry_status);
8109 } 8125 }
8110 8126
8111 } // namespace net 8127 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_cache_transaction.cc ('k') | third_party/WebKit/Source/core/inspector/InspectorNetworkAgent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698