From 7abcaea438b6205b44c1c4a51ebc4fa15ca74f9c Mon Sep 17 00:00:00 2001 From: "rvargas@google.com" Date: Wed, 17 Nov 2010 21:34:17 +0000 Subject: Disk cache: A dirty entry can point to a list that is not the actual list where the entry is stored. This CL recognizes that case and hanldes removing that entry from the lists, without saying that there is critical corruption. BUG=38859 TEST=net_unittests Review URL: http://codereview.chromium.org/5119001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66518 0039d316-1c4b-4281-b951-d872f2087c98 --- net/disk_cache/backend_unittest.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'net/disk_cache/backend_unittest.cc') diff --git a/net/disk_cache/backend_unittest.cc b/net/disk_cache/backend_unittest.cc index 4298456..bfb78b6 100644 --- a/net/disk_cache/backend_unittest.cc +++ b/net/disk_cache/backend_unittest.cc @@ -1313,6 +1313,26 @@ TEST_F(DiskCacheBackendTest, NewEvictionInvalidEntry2) { BackendInvalidEntry2(); } +TEST_F(DiskCacheBackendTest, NewEvictionInvalidEntry3) { + ASSERT_TRUE(CopyTestCache("bad_rankings3")); + DisableFirstCleanup(); + SetNewEviction(); + InitCache(); + + // The second entry is dirty, but removing it should not corrupt the list. + disk_cache::Entry* entry; + ASSERT_NE(net::OK, OpenEntry("the second key", &entry)); + ASSERT_EQ(net::OK, OpenEntry("the first key", &entry)); + + // This should not delete the cache. + entry->Doom(); + FlushQueueForTest(); + entry->Close(); + + ASSERT_EQ(net::OK, OpenEntry("some other key", &entry)); + entry->Close(); +} + // We want to be able to deal with abnormal dirty entries. void DiskCacheBackendTest::BackendNotMarkedButDirty(const std::string& name) { ASSERT_TRUE(CopyTestCache(name)); -- cgit v1.1