diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-22 19:00:04 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-22 19:00:04 +0000 |
commit | 43f1d1322ea1fee3f883463215ab1603398fe11d (patch) | |
tree | ebeecaaa0031c8f2a121076209fb17e1e4269458 /net | |
parent | 8e36b94f69066c25891b8b76d14317759b0f1d29 (diff) | |
download | chromium_src-43f1d1322ea1fee3f883463215ab1603398fe11d.zip chromium_src-43f1d1322ea1fee3f883463215ab1603398fe11d.tar.gz chromium_src-43f1d1322ea1fee3f883463215ab1603398fe11d.tar.bz2 |
Disk cache: Make sure that the index file is closed on the cache thread.
BUG=108354
TEST=net_unittests
Review URL: http://codereview.chromium.org/9016029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115569 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/disk_cache/backend_impl.cc | 1 | ||||
-rw-r--r-- | net/disk_cache/backend_unittest.cc | 14 |
2 files changed, 15 insertions, 0 deletions
diff --git a/net/disk_cache/backend_impl.cc b/net/disk_cache/backend_impl.cc index 5e652d7..c86d9a8 100644 --- a/net/disk_cache/backend_impl.cc +++ b/net/disk_cache/backend_impl.cc @@ -560,6 +560,7 @@ void BackendImpl::CleanupCache() { } } block_files_.CloseFiles(); + index_ = NULL; ptr_factory_.InvalidateWeakPtrs(); done_.Signal(); } diff --git a/net/disk_cache/backend_unittest.cc b/net/disk_cache/backend_unittest.cc index 9fa9f05..9f8eb2e 100644 --- a/net/disk_cache/backend_unittest.cc +++ b/net/disk_cache/backend_unittest.cc @@ -8,6 +8,7 @@ #include "base/stringprintf.h" #include "base/third_party/dynamic_annotations/dynamic_annotations.h" #include "base/threading/platform_thread.h" +#include "base/threading/thread_restrictions.h" #include "net/base/io_buffer.h" #include "net/base/net_errors.h" #include "net/base/test_completion_callback.h" @@ -235,6 +236,19 @@ TEST_F(DiskCacheTest, CreateBackend) { MessageLoop::current()->RunAllPending(); } +// Testst that re-creating the cache performs the expected cleanup. +TEST_F(DiskCacheBackendTest, CreateBackend_MissingFile) { + ASSERT_TRUE(CopyTestCache("bad_entry")); + FilePath filename = cache_path_.AppendASCII("data_1"); + file_util::Delete(filename, false); + DisableFirstCleanup(); + SetForceCreation(); + + bool prev = base::ThreadRestrictions::SetIOAllowed(false); + InitCache(); + base::ThreadRestrictions::SetIOAllowed(prev); +} + TEST_F(DiskCacheBackendTest, ExternalFiles) { InitCache(); // First, let's create a file on the folder. |