diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-09 22:01:29 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-09 22:01:29 +0000 |
commit | 7d4e3a8bef1d62195eea2a4190a626a058bf5f23 (patch) | |
tree | 48ae233248dd5d33d8b1467c041e3fdcfcaab346 /net/disk_cache/entry_impl.cc | |
parent | 8d3347feb74ff61582d42b214365664ecc41c775 (diff) | |
download | chromium_src-7d4e3a8bef1d62195eea2a4190a626a058bf5f23.zip chromium_src-7d4e3a8bef1d62195eea2a4190a626a058bf5f23.tar.gz chromium_src-7d4e3a8bef1d62195eea2a4190a626a058bf5f23.tar.bz2 |
Disk cache: Add explicit support for eviction / deletion
of sparse entries.
I started to add code to modify the children_map of the
parent entry when a child is evicted but that ended up
being too much trouble for too little gain. We have to be
prepared to handle the case of not finding a child entry
because there is no way to make sure that the process
doesn't go away at any time, so adding a lot of complexity
just to avoid an extra entry lookup is just not worth it.
On the other hand, potentially freeing up a lot of space when
a sparse entry is deleted (insetad of just waiting for the
eviction code to do the cleanup) seems like a good thing.
BUG=12258
TEST=unittest
Review URL: http://codereview.chromium.org/149306
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20325 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/entry_impl.cc')
-rw-r--r-- | net/disk_cache/entry_impl.cc | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/net/disk_cache/entry_impl.cc b/net/disk_cache/entry_impl.cc index 4c17cbb..75fb92e5 100644 --- a/net/disk_cache/entry_impl.cc +++ b/net/disk_cache/entry_impl.cc @@ -453,6 +453,11 @@ void EntryImpl::InternalDoom() { void EntryImpl::DeleteEntryData(bool everything) { DCHECK(doomed_ || !everything); + if (GetEntryFlags() & PARENT_ENTRY) { + // We have some child entries that must go away. + SparseControl::DeleteChildren(this); + } + if (GetDataSize(0)) CACHE_UMA(COUNTS, "DeleteHeader", 0, GetDataSize(0)); if (GetDataSize(1)) @@ -834,6 +839,38 @@ int EntryImpl::InitSparseData() { return result; } +void EntryImpl::SetEntryFlags(uint32 flags) { + entry_.Data()->flags |= flags; + entry_.set_modified(); +} + +uint32 EntryImpl::GetEntryFlags() { + return entry_.Data()->flags; +} + +void EntryImpl::GetData(int index, char** buffer, Addr* address) { + if (user_buffers_[index].get()) { + // The data is already in memory, just copy it an we're done. + int data_len = entry_.Data()->data_size[index]; + DCHECK(data_len <= kMaxBlockSize); + *buffer = new char[data_len]; + memcpy(*buffer, user_buffers_[index].get(), data_len); + return; + } + + // Bad news: we'd have to read the info from disk so instead we'll just tell + // the caller where to read from. + *buffer = NULL; + address->set_value(entry_.Data()->data_addr[index]); + if (address->is_initialized()) { + // Prevent us from deleting the block from the backing store. + backend_->ModifyStorageSize(entry_.Data()->data_size[index] - + unreported_size_[index], 0); + entry_.Data()->data_addr[index] = 0; + entry_.Data()->data_size[index] = 0; + } +} + void EntryImpl::ReportIOTime(Operation op, const base::Time& start) { int group = backend_->GetSizeGroup(); switch (op) { |