summaryrefslogtreecommitdiffstats
path: root/net/http/http_cache_unittest.cc
diff options
context:
space:
mode:
authormbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-05 07:14:15 +0000
committermbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-05 07:14:15 +0000
commit98179700f91d242ce6a4edb5f0865e12d3a662c6 (patch)
treed0aba9403ec40c447e4adeecf030d9c37e6952fa /net/http/http_cache_unittest.cc
parentd96700fe4b8aa342d48c47aa3b1765760738bb47 (diff)
downloadchromium_src-98179700f91d242ce6a4edb5f0865e12d3a662c6.zip
chromium_src-98179700f91d242ce6a4edb5f0865e12d3a662c6.tar.gz
chromium_src-98179700f91d242ce6a4edb5f0865e12d3a662c6.tar.bz2
Add two small features to the HttpCache for benchmarking/debugging.
The first exposes a method to close all idle sockets. This allows me to create benchmark tests in the app which can close connections before starting the test for better simulations. The second change is to expose cache modes for cache disabled and cache bypassed. DISABLE sets the LOAD_DISABLE_CACHE on every request; BYPASS sets the LOAD_BYPASS_CACHE on every request. TEST=http_cache_unittest.cc BUG=6754 Review URL: http://codereview.chromium.org/119189 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17720 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_cache_unittest.cc')
-rw-r--r--net/http/http_cache_unittest.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc
index b58eb44..ae1ecaa 100644
--- a/net/http/http_cache_unittest.cc
+++ b/net/http/http_cache_unittest.cc
@@ -1314,3 +1314,23 @@ TEST(HttpCache, OutlivedTransactions) {
delete cache;
delete trans;
}
+
+// Test that the disabled mode works.
+TEST(HttpCache, CacheDisabledMode) {
+ MockHttpCache cache;
+
+ // write to the cache
+ RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction);
+
+ // go into disabled mode
+ cache.http_cache()->set_mode(net::HttpCache::DISABLE);
+
+ // force this transaction to write to the cache again
+ MockTransaction transaction(kSimpleGET_Transaction);
+
+ RunTransactionTest(cache.http_cache(), transaction);
+
+ EXPECT_EQ(2, cache.network_layer()->transaction_count());
+ EXPECT_EQ(0, cache.disk_cache()->open_count());
+ EXPECT_EQ(1, cache.disk_cache()->create_count());
+}