summaryrefslogtreecommitdiffstats
path: root/net/disk_cache
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-16 00:26:24 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-16 00:26:24 +0000
commitb9b19173b9addd5de1f2c7a2a739c99a69b622a8 (patch)
tree56fa00b4d024ea91379ca22e063dca7e4bd59680 /net/disk_cache
parent9b4cb193328469789bf1408e653f218f2940a9fa (diff)
downloadchromium_src-b9b19173b9addd5de1f2c7a2a739c99a69b622a8.zip
chromium_src-b9b19173b9addd5de1f2c7a2a739c99a69b622a8.tar.gz
chromium_src-b9b19173b9addd5de1f2c7a2a739c99a69b622a8.tar.bz2
Disk cache: Fix the initialization order of the backend.
BUG=72963 TEST=net_unittests Review URL: http://codereview.chromium.org/6529007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75036 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache')
-rw-r--r--net/disk_cache/backend_impl.cc11
-rw-r--r--net/disk_cache/backend_unittest.cc23
2 files changed, 29 insertions, 5 deletions
diff --git a/net/disk_cache/backend_impl.cc b/net/disk_cache/backend_impl.cc
index 01c0136..dfa9e51 100644
--- a/net/disk_cache/backend_impl.cc
+++ b/net/disk_cache/backend_impl.cc
@@ -506,17 +506,18 @@ int BackendImpl::SyncInit() {
read_only_ = true;
}
+ // Setup load-time data only for the main cache.
+ if (!throttle_requests_ && cache_type() == net::DISK_CACHE)
+ throttle_requests_ = SetFieldTrialInfo(GetSizeGroup());
+
+ eviction_.Init(this);
+
// stats_ and rankings_ may end up calling back to us so we better be enabled.
disabled_ = false;
if (!stats_.Init(this, &data_->header.stats))
return net::ERR_FAILED;
disabled_ = !rankings_.Init(this, new_eviction_);
- eviction_.Init(this);
-
- // Setup load-time data only for the main cache.
- if (!throttle_requests_ && cache_type() == net::DISK_CACHE)
- throttle_requests_ = SetFieldTrialInfo(GetSizeGroup());
return disabled_ ? net::ERR_FAILED : net::OK;
}
diff --git a/net/disk_cache/backend_unittest.cc b/net/disk_cache/backend_unittest.cc
index 1760837..0a693be 100644
--- a/net/disk_cache/backend_unittest.cc
+++ b/net/disk_cache/backend_unittest.cc
@@ -48,6 +48,7 @@ class DiskCacheBackendTest : public DiskCacheTestWithCache {
void BackendTransaction(const std::string& name, int num_entries, bool load);
void BackendRecoverInsert();
void BackendRecoverRemove();
+ void BackendRecoverWithEviction();
void BackendInvalidEntry2();
void BackendInvalidEntry3();
void BackendNotMarkedButDirty(const std::string& name);
@@ -1272,6 +1273,28 @@ TEST_F(DiskCacheBackendTest, NewEvictionRecoverRemove) {
BackendRecoverRemove();
}
+void DiskCacheBackendTest::BackendRecoverWithEviction() {
+ success_ = false;
+ ASSERT_TRUE(CopyTestCache("insert_load1"));
+ DisableFirstCleanup();
+
+ SetMask(0xf);
+ SetMaxSize(0x1000);
+
+ // We should not crash here.
+ InitCache();
+ DisableIntegrityCheck();
+}
+
+TEST_F(DiskCacheBackendTest, RecoverWithEviction) {
+ BackendRecoverWithEviction();
+}
+
+TEST_F(DiskCacheBackendTest, NewEvictionRecoverWithEviction) {
+ SetNewEviction();
+ BackendRecoverWithEviction();
+}
+
// Tests dealing with cache files that cannot be recovered.
TEST_F(DiskCacheTest, DeleteOld) {
ASSERT_TRUE(CopyTestCache("wrong_version"));