diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-01 00:58:01 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-01 00:58:01 +0000 |
commit | f1940b946ea9f8589ecd95f82879abad152b73e1 (patch) | |
tree | aca3f69422a631b18c3f2000aa35bed162810e1e | |
parent | 27d4a38d7a4f692b18a8ea3bec0660804f2b96ea (diff) | |
download | chromium_src-f1940b946ea9f8589ecd95f82879abad152b73e1.zip chromium_src-f1940b946ea9f8589ecd95f82879abad152b73e1.tar.gz chromium_src-f1940b946ea9f8589ecd95f82879abad152b73e1.tar.bz2 |
Disk cache: Open the disk cache experiment for new users.
Also, fix the code that makes the unit tests have
consistent results.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/160485
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22238 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | net/disk_cache/backend_impl.cc | 23 | ||||
-rw-r--r-- | net/disk_cache/backend_impl.h | 6 | ||||
-rw-r--r-- | net/disk_cache/disk_cache_test_base.cc | 5 |
3 files changed, 25 insertions, 9 deletions
diff --git a/net/disk_cache/backend_impl.cc b/net/disk_cache/backend_impl.cc index ea5caf3..506ab22 100644 --- a/net/disk_cache/backend_impl.cc +++ b/net/disk_cache/backend_impl.cc @@ -147,12 +147,6 @@ bool InitExperiment(int* current_group) { } if (*current_group <= 5) { -#if defined(UNIT_TEST) - // The unit test controls directly what to test. - *current_group = 0; - return true; -#endif - // Re-load the two groups. int option = base::RandInt(0, 9); @@ -294,8 +288,11 @@ bool BackendImpl::Init() { } init_ = true; - if (!InitExperiment(&data_->header.experiment)) - return false; + if (!(user_flags_ & disk_cache::kNoRandom)) { + // The unit test controls directly what to test. + if (!InitExperiment(&data_->header.experiment)) + return false; + } if (data_->header.experiment > 6 && data_->header.experiment < 9) new_eviction_ = true; @@ -949,6 +946,10 @@ void BackendImpl::SetNewEviction() { new_eviction_ = true; } +void BackendImpl::SetFlags(uint32 flags) { + user_flags_ |= flags; +} + void BackendImpl::ClearRefCountForTest() { num_refs_ = 0; } @@ -987,6 +988,12 @@ bool BackendImpl::CreateBackingStore(disk_cache::File* file) { IndexHeader header; header.table_len = DesiredIndexTableLen(max_size_); + // All new profiles are going to use the new eviction. + if (!(user_flags_ & disk_cache::kNoRandom)) { + header.experiment = 8; + new_eviction_ = true; + } + // We need file version 2.1 for the new eviction algorithm. if (new_eviction_) header.version = 0x20001; diff --git a/net/disk_cache/backend_impl.h b/net/disk_cache/backend_impl.h index 61639e6..242c0c5 100644 --- a/net/disk_cache/backend_impl.h +++ b/net/disk_cache/backend_impl.h @@ -23,7 +23,8 @@ enum BackendFlags { kMaxSize = 1 << 1, kUnitTestMode = 1 << 2, kUpgradeMode = 1 << 3, - kNewEviction = 1 << 4 + kNewEviction = 1 << 4, + kNoRandom = 1 << 5 }; // This class implements the Backend interface. An object of this @@ -170,6 +171,9 @@ class BackendImpl : public Backend { // Sets the eviction algorithm to version 2. void SetNewEviction(); + // Sets an explicit set of BackendFlags. + void SetFlags(uint32 flags); + // Clears the counter of references to test handling of corruptions. void ClearRefCountForTest(); diff --git a/net/disk_cache/disk_cache_test_base.cc b/net/disk_cache/disk_cache_test_base.cc index 986f3fb..db6af64 100644 --- a/net/disk_cache/disk_cache_test_base.cc +++ b/net/disk_cache/disk_cache_test_base.cc @@ -59,6 +59,10 @@ void DiskCacheTestWithCache::InitDiskCache() { if (!implementation_) { cache_ = disk_cache::CreateCacheBackend(path, force_creation_, size_, net::DISK_CACHE); + disk_cache::BackendImpl* impl = + static_cast<disk_cache::BackendImpl*>(cache_); + if (impl) + impl->SetFlags(disk_cache::kNoRandom); return; } @@ -80,6 +84,7 @@ void DiskCacheTestWithCache::InitDiskCacheImpl(const std::wstring& path) { if (new_eviction_) cache_impl_->SetNewEviction(); + cache_impl_->SetFlags(disk_cache::kNoRandom); ASSERT_TRUE(cache_impl_->Init()); } |