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

Unified Diff: net/disk_cache/entry_impl.cc

Issue 149306: Disk cache: Add explicit support for eviction / deletion... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 5 months 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 | « net/disk_cache/entry_impl.h ('k') | net/disk_cache/entry_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/entry_impl.cc
===================================================================
--- net/disk_cache/entry_impl.cc (revision 20076)
+++ net/disk_cache/entry_impl.cc (working copy)
@@ -453,6 +453,11 @@
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 @@
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) {
« no previous file with comments | « net/disk_cache/entry_impl.h ('k') | net/disk_cache/entry_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698