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

Unified Diff: net/disk_cache/mem_entry_impl.cc

Issue 182023: Disk Cache: Function re-ordering. No code change. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 4 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/mem_entry_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « net/disk_cache/mem_entry_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698