diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-05 21:19:02 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-05 21:19:02 +0000 |
commit | 190be391c2c420310d95eda78b5fce0e00d069bf (patch) | |
tree | bb7921b70100dac4401c7a68ba3a3e6c7d6d5d36 /net/disk_cache | |
parent | 027f2fb27b6c2840feb15a3ee8964473075122bb (diff) | |
download | chromium_src-190be391c2c420310d95eda78b5fce0e00d069bf.zip chromium_src-190be391c2c420310d95eda78b5fce0e00d069bf.tar.gz chromium_src-190be391c2c420310d95eda78b5fce0e00d069bf.tar.bz2 |
Disk cache: Report more info from the current experiment.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/119218
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17772 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache')
-rw-r--r-- | net/disk_cache/backend_impl.cc | 29 | ||||
-rw-r--r-- | net/disk_cache/backend_impl.h | 17 | ||||
-rw-r--r-- | net/disk_cache/eviction.cc | 16 |
3 files changed, 43 insertions, 19 deletions
diff --git a/net/disk_cache/backend_impl.cc b/net/disk_cache/backend_impl.cc index f22f741..63db6b1 100644 --- a/net/disk_cache/backend_impl.cc +++ b/net/disk_cache/backend_impl.cc @@ -136,20 +136,19 @@ bool DelayedCacheCleanup(const std::wstring& full_path) { return true; } -// Sets |stored_value| for the current experiment. Returns false if the files +// Sets |current_group| for the current experiment. Returns false if the files // should be discarded. -bool InitExperiment(int* stored_value) { - if (*stored_value <= 2) { +bool InitExperiment(int* current_group) { + if (*current_group <= 2) { // Not taking part of this experiment. - *stored_value = 5; - return true; - } - - if (*stored_value < 5) { + *current_group = 5; + } else if (*current_group < 5) { // Discard current cache for groups 3 and 4. return false; } + UMA_HISTOGRAM_CACHE_ERROR("DiskCache.Experiment", *current_group); + // Current experiment already set. return true; } @@ -231,6 +230,7 @@ bool BackendImpl::Init() { #ifdef USE_NEW_EVICTION new_eviction_ = true; + user_flags_ |= kNewEviction; #endif bool create_files = false; @@ -566,6 +566,7 @@ bool BackendImpl::SetMaxSize(int max_bytes) { if (!max_bytes) return true; + user_flags_ |= kMaxSize; max_size_ = max_bytes; return true; } @@ -788,10 +789,6 @@ void BackendImpl::CriticalError(int error) { LogStats(); ReportError(error); - // Reset the mask_ if it was not given by the user. - if (static_cast<int>(mask_) == data_->header.table_len - 1) - mask_ = 0; - // Setting the index table length to an invalid value will force re-creation // of the cache files. data_->header.table_len = 1; @@ -843,14 +840,17 @@ void BackendImpl::DecrementIoCount() { } void BackendImpl::SetUnitTestMode() { + user_flags_ |= kUnitTestMode; unit_test_ = true; } void BackendImpl::SetUpgradeMode() { + user_flags_ |= kUpgradeMode; read_only_ = true; } void BackendImpl::SetNewEviction() { + user_flags_ |= kNewEviction; new_eviction_ = true; } @@ -988,9 +988,12 @@ void BackendImpl::RestartCache() { void BackendImpl::PrepareForRestart() { // Reset the mask_ if it was not given by the user. - if (static_cast<int>(mask_) == data_->header.table_len - 1) + if (!(user_flags_ & kMask)) mask_ = 0; + if (!(user_flags_ & kNewEviction)) + new_eviction_ = false; + data_->header.crash = 0; index_ = NULL; data_ = NULL; diff --git a/net/disk_cache/backend_impl.h b/net/disk_cache/backend_impl.h index 7270b30..a061feb 100644 --- a/net/disk_cache/backend_impl.h +++ b/net/disk_cache/backend_impl.h @@ -17,6 +17,14 @@ namespace disk_cache { +enum BackendFlags { + kMask = 1, + kMaxSize = 1 << 1, + kUnitTestMode = 1 << 2, + kUpgradeMode = 1 << 3, + kNewEviction = 1 << 4 +}; + // This class implements the Backend interface. An object of this // class handles the operations of the cache for a particular profile. class BackendImpl : public Backend { @@ -24,14 +32,14 @@ class BackendImpl : public Backend { public: explicit BackendImpl(const std::wstring& path) : path_(path), block_files_(path), mask_(0), max_size_(0), - cache_type_(net::DISK_CACHE), uma_report_(0), init_(false), - restarted_(false), unit_test_(false), read_only_(false), + cache_type_(net::DISK_CACHE), uma_report_(0), user_flags_(0), + init_(false), restarted_(false), unit_test_(false), read_only_(false), new_eviction_(false), first_timer_(true) {} // mask can be used to limit the usable size of the hash table, for testing. BackendImpl(const std::wstring& path, uint32 mask) : path_(path), block_files_(path), mask_(mask), max_size_(0), - cache_type_(net::DISK_CACHE), uma_report_(0), init_(false), - restarted_(false), unit_test_(false), read_only_(false), + cache_type_(net::DISK_CACHE), uma_report_(0), user_flags_(kMask), + init_(false), restarted_(false), unit_test_(false), read_only_(false), new_eviction_(false), first_timer_(true) {} ~BackendImpl(); @@ -235,6 +243,7 @@ class BackendImpl : public Backend { int num_pending_io_; // Number of pending IO operations. net::CacheType cache_type_; int uma_report_; // Controls transmision of UMA data. + uint32 user_flags_; // Flags set by the user. bool init_; // controls the initialization of the system. bool restarted_; bool unit_test_; diff --git a/net/disk_cache/eviction.cc b/net/disk_cache/eviction.cc index dab707d..cae5702 100644 --- a/net/disk_cache/eviction.cc +++ b/net/disk_cache/eviction.cc @@ -146,10 +146,22 @@ void Eviction::ReportTrimTimes(EntryImpl* entry) { ReportListStats(); } - if (header_->create_time && !header_->lru.filled) { + if (header_->lru.filled) + return; + + header_->lru.filled = 1; + + if (header_->create_time) { // This is the first entry that we have to evict, generate some noise. - header_->lru.filled = 1; backend_->FirstEviction(); + } else { + // This is an old file, but we may want more reports from this user so + // lets save some create_time. + Time::Exploded old = {0}; + old.year = 2009; + old.month = 3; + old.day_of_month = 1; + header_->create_time = Time::FromLocalExploded(old).ToInternalValue(); } } } |