Index: net/disk_cache/mem_entry_impl.cc |
=================================================================== |
--- net/disk_cache/mem_entry_impl.cc (revision 24829) |
+++ net/disk_cache/mem_entry_impl.cc (working copy) |
@@ -54,45 +54,6 @@ |
backend_->ModifyStorageSize(static_cast<int32>(key_.size()), 0); |
} |
-bool MemEntryImpl::CreateEntry(const std::string& key) { |
- key_ = key; |
- last_modified_ = Time::Now(); |
- last_used_ = Time::Now(); |
- Open(); |
- backend_->ModifyStorageSize(0, static_cast<int32>(key.size())); |
- return true; |
-} |
- |
-void MemEntryImpl::Close() { |
- // Only a parent entry can be closed. |
- DCHECK(type() == kParentEntry); |
- ref_count_--; |
- DCHECK(ref_count_ >= 0); |
- if (!ref_count_ && doomed_) |
- InternalDoom(); |
-} |
- |
-void MemEntryImpl::Open() { |
- // Only a parent entry can be opened. |
- // TODO(hclam): make sure it's correct to not apply the concept of ref |
- // counting to child entry. |
- DCHECK(type() == kParentEntry); |
- ref_count_++; |
- DCHECK(ref_count_ >= 0); |
- DCHECK(!doomed_); |
-} |
- |
-bool MemEntryImpl::InUse() { |
- if (type() == kParentEntry) { |
- return ref_count_ > 0; |
- } else { |
- // A child entry is always not in use. The consequence is that a child entry |
- // can always be evicted while the associated parent entry is currently in |
- // used (i.e. opened). |
- return false; |
- } |
-} |
- |
void MemEntryImpl::Doom() { |
if (doomed_) |
return; |
@@ -106,29 +67,13 @@ |
} |
} |
-void MemEntryImpl::InternalDoom() { |
- doomed_ = true; |
- if (!ref_count_) { |
- if (type() == kParentEntry) { |
- // If this is a parent entry, we need to doom all the child entries. |
- if (children_.get()) { |
- EntryMap children; |
- children.swap(*children_); |
- for (EntryMap::iterator i = children.begin(); |
- i != children.end(); ++i) { |
- // Since a pointer to this object is also saved in the map, avoid |
- // dooming it. |
- if (i->second != this) |
- i->second->Doom(); |
- } |
- DCHECK(children_->size() == 0); |
- } |
- } else { |
- // If this is a child entry, detach it from the parent. |
- parent_->DetachChild(child_id_); |
- } |
- delete this; |
- } |
+void MemEntryImpl::Close() { |
+ // Only a parent entry can be closed. |
+ DCHECK(type() == kParentEntry); |
+ ref_count_--; |
+ DCHECK(ref_count_ >= 0); |
+ if (!ref_count_ && doomed_) |
+ InternalDoom(); |
} |
std::string MemEntryImpl::GetKey() const { |
@@ -374,6 +319,65 @@ |
return 0; |
} |
+// ------------------------------------------------------------------------ |
+ |
+bool MemEntryImpl::CreateEntry(const std::string& key) { |
+ key_ = key; |
+ last_modified_ = Time::Now(); |
+ last_used_ = Time::Now(); |
+ Open(); |
+ backend_->ModifyStorageSize(0, static_cast<int32>(key.size())); |
+ return true; |
+} |
+ |
+void MemEntryImpl::InternalDoom() { |
+ doomed_ = true; |
+ if (!ref_count_) { |
+ if (type() == kParentEntry) { |
+ // If this is a parent entry, we need to doom all the child entries. |
+ if (children_.get()) { |
+ EntryMap children; |
+ children.swap(*children_); |
+ for (EntryMap::iterator i = children.begin(); |
+ i != children.end(); ++i) { |
+ // Since a pointer to this object is also saved in the map, avoid |
+ // dooming it. |
+ if (i->second != this) |
+ i->second->Doom(); |
+ } |
+ DCHECK(children_->size() == 0); |
+ } |
+ } else { |
+ // If this is a child entry, detach it from the parent. |
+ parent_->DetachChild(child_id_); |
+ } |
+ delete this; |
+ } |
+} |
+ |
+void MemEntryImpl::Open() { |
+ // Only a parent entry can be opened. |
+ // TODO(hclam): make sure it's correct to not apply the concept of ref |
+ // counting to child entry. |
+ DCHECK(type() == kParentEntry); |
+ ref_count_++; |
+ DCHECK(ref_count_ >= 0); |
+ DCHECK(!doomed_); |
+} |
+ |
+bool MemEntryImpl::InUse() { |
+ if (type() == kParentEntry) { |
+ return ref_count_ > 0; |
+ } else { |
+ // A child entry is always not in use. The consequence is that a child entry |
+ // can always be evicted while the associated parent entry is currently in |
+ // used (i.e. opened). |
+ return false; |
+ } |
+} |
+ |
+// ------------------------------------------------------------------------ |
+ |
void MemEntryImpl::PrepareTarget(int index, int offset, int buf_len) { |
int entry_size = GetDataSize(index); |