From cfc076ec466fc48e91c309448c4e5be3467b42c7 Mon Sep 17 00:00:00 2001 From: "hclam@chromium.org" Date: Sat, 7 Nov 2009 02:27:23 +0000 Subject: Clear disk cache when the cache is not initialized BUG=24765 TEST=unit test, clear browsing data and the cache, media cache will be cleared even if a media object was not loaded. Since the disk cache backend in HttpCache is lazily initialized, clearing the cache before it receives the first transaction would have no effect. So initialize the disk cache explicitly when we clear the cache. Review URL: http://codereview.chromium.org/378015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31361 0039d316-1c4b-4281-b951-d872f2087c98 --- net/http/http_cache_unittest.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'net/http/http_cache_unittest.cc') diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc index 0378ca0..f7db18c 100644 --- a/net/http/http_cache_unittest.cc +++ b/net/http/http_cache_unittest.cc @@ -8,6 +8,7 @@ #include "base/message_loop.h" #include "base/scoped_vector.h" #include "base/string_util.h" +#include "net/base/cache_type.h" #include "net/base/net_errors.h" #include "net/base/load_flags.h" #include "net/base/load_log_unittest.h" @@ -458,7 +459,7 @@ class MockHttpCache { return static_cast(http_cache_.network_layer()); } MockDiskCache* disk_cache() { - return static_cast(http_cache_.disk_cache()); + return static_cast(http_cache_.GetBackend()); } private: @@ -768,6 +769,15 @@ TEST(HttpCache, CreateThenDestroy) { ASSERT_TRUE(trans.get()); } +TEST(HttpCache, GetBackend) { + // This will initialize a cache object with NULL backend. + MockHttpCache cache(NULL); + + // This will lazily initialize the backend. + cache.http_cache()->set_type(net::MEMORY_CACHE); + EXPECT_TRUE(cache.http_cache()->GetBackend()); +} + TEST(HttpCache, SimpleGET) { MockHttpCache cache; -- cgit v1.1