summaryrefslogtreecommitdiffstats
path: root/net/disk_cache/backend_impl.cc
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-29 20:44:32 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-29 20:44:32 +0000
commit50f0e87c11606f326990cdae92f838f080efc5d3 (patch)
treeac17439dc2c106115993533c7b5f7e4788942f38 /net/disk_cache/backend_impl.cc
parentd9af50c76da16f7f5a7a312bc8219917b2cab77c (diff)
downloadchromium_src-50f0e87c11606f326990cdae92f838f080efc5d3.zip
chromium_src-50f0e87c11606f326990cdae92f838f080efc5d3.tar.gz
chromium_src-50f0e87c11606f326990cdae92f838f080efc5d3.tar.bz2
Disk cache: Split deleting old entries from the cache into small chunks that run through the
message loop to improve responsiveness of the io thread. BUG=1345851 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1552 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/backend_impl.cc')
-rw-r--r--net/disk_cache/backend_impl.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/net/disk_cache/backend_impl.cc b/net/disk_cache/backend_impl.cc
index 7deb343..bc0f723 100644
--- a/net/disk_cache/backend_impl.cc
+++ b/net/disk_cache/backend_impl.cc
@@ -91,7 +91,7 @@ void CleanupTask::Run() {
}
}
-// Returns a full path to reneme the current cache, in order to delete it. path
+// Returns a full path to rename the current cache, in order to delete it. path
// is the current folder location, and name is the current folder name.
std::wstring GetTempCacheName(const std::wstring& path,
const std::wstring& name) {
@@ -946,6 +946,7 @@ void BackendImpl::TrimCache(bool empty) {
Rankings::ScopedRankingsBlock next(&rankings_, rankings_.GetPrev(node.get()));
DCHECK(next.get());
int target_size = empty ? 0 : LowWaterAdjust(max_size_);
+ int deleted = 0;
while (data_->header.num_bytes > target_size && next.get()) {
node.reset(next.release());
next.reset(rankings_.GetPrev(node.get()));
@@ -968,6 +969,11 @@ void BackendImpl::TrimCache(bool empty) {
entry->Release();
if (!empty)
stats_.OnEvent(Stats::TRIM_ENTRY);
+ if (++deleted == 4 && !empty) {
+ MessageLoop::current()->PostTask(FROM_HERE,
+ factory_.NewRunnableMethod(&BackendImpl::TrimCache, false));
+ break;
+ }
}
}