Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(875)

Unified Diff: net/http/infinite_cache.cc

Issue 11415222: Http cache: fix a bug that prevented the infinite cache simulation from saving (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/http/infinite_cache_unittest.cc » ('j') | net/http/infinite_cache_unittest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/infinite_cache.cc
===================================================================
--- net/http/infinite_cache.cc (revision 170114)
+++ net/http/infinite_cache.cc (working copy)
@@ -82,10 +82,10 @@
// Some constants related to the database file.
uint32 kMagicSignature = 0x1f00cace;
-uint32 kCurrentVersion = 0x10001;
+uint32 kCurrentVersion = 0x10002;
// Basic limits for the experiment.
-int kMaxNumEntries = 500 * 1000;
+int kMaxNumEntries = 200 * 1000;
tburkard 2012/11/30 19:00:54 Why reduce the size?
rvargas (doing something else) 2012/11/30 19:12:23 When I increased the size I was under the assumpti
int kMaxTrackingSize = 40 * 1024 * 1024;
// Settings that control how we generate histograms.
@@ -604,7 +604,7 @@
base::ClosePlatformFile(file);
if (header_->disabled) {
UMA_HISTOGRAM_BOOLEAN("InfiniteCache.Full", true);
- map_.clear();
+ InitializeData();
}
}
@@ -639,6 +639,7 @@
header_->magic = kMagicSignature;
header_->version = kCurrentVersion;
header_->creation_time = Time::Now().ToInternalValue();
+ map_.clear();
UMA_HISTOGRAM_BOOLEAN("InfiniteCache.Initialize", true);
init_ = true;
@@ -653,7 +654,7 @@
uint32 hash = adler32(0, Z_NULL, 0);
for (int remaining_records = header_->num_entries; remaining_records;) {
- int num_records = std::min(header_->num_entries,
+ int num_records = std::min(remaining_records,
static_cast<int>(kMaxRecordsToRead));
size_t num_bytes = num_records * kRecordSize;
remaining_records -= num_records;
@@ -703,7 +704,7 @@
DCHECK_EQ(header_->num_entries, static_cast<int32>(map_.size()));
KeyMap::iterator iterator = map_.begin();
for (int remaining_records = header_->num_entries; remaining_records;) {
- int num_records = std::min(header_->num_entries,
+ int num_records = std::min(remaining_records,
static_cast<int>(kMaxRecordsToRead));
size_t num_bytes = num_records * kRecordSize;
remaining_records -= num_records;
@@ -804,6 +805,7 @@
int entry_size = static_cast<int>(header_->total_size / kMaxNumEntries);
UMA_HISTOGRAM_COUNTS("InfiniteCache.FinalAvgEntrySize", entry_size);
header_->disabled = 1;
+ header_->num_entries = 0;
map_.clear();
}
}
« no previous file with comments | « no previous file | net/http/infinite_cache_unittest.cc » ('j') | net/http/infinite_cache_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698