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

Unified Diff: net/disk_cache/backend_impl.cc

Issue 155231: Disk cache: Additional code cleanup after CL 20067. (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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/backend_impl.cc
===================================================================
--- net/disk_cache/backend_impl.cc (revision 20067)
+++ net/disk_cache/backend_impl.cc (working copy)
@@ -1103,8 +1103,8 @@
EntryImpl* BackendImpl::MatchEntry(const std::string& key, uint32 hash,
bool find_parent) {
Addr address(data_->table[hash & mask_]);
- EntryImpl* cache_entry = NULL;
- EntryImpl* parent_entry = NULL;
+ scoped_refptr<EntryImpl> cache_entry, parent_entry;
+ EntryImpl* tmp = NULL;
bool found = false;
for (;;) {
@@ -1118,7 +1118,8 @@
}
bool dirty;
- int error = NewEntry(address, &cache_entry, &dirty);
+ int error = NewEntry(address, &tmp, &dirty);
+ cache_entry.swap(&tmp);
if (error || dirty) {
// This entry is dirty on disk (it was not properly closed): we cannot
@@ -1129,7 +1130,6 @@
if (parent_entry) {
parent_entry->SetNextAddress(child);
- parent_entry->Release();
parent_entry = NULL;
Nicolas Sylvain 2009/07/08 20:25:09 maybe here and below you could use .reset()?
rvargas (doing something else) 2009/07/08 20:49:44 there is no reset() for scoped_refptr
} else {
data_->table[hash & mask_] = child.value();
@@ -1139,7 +1139,6 @@
// It is important to call DestroyInvalidEntry after removing this
// entry from the table.
DestroyInvalidEntry(address, cache_entry);
- cache_entry->Release();
cache_entry = NULL;
} else {
Trace("NewEntry failed on MatchEntry 0x%x", address.value());
@@ -1151,19 +1150,13 @@
}
if (cache_entry->IsSameEntry(key, hash)) {
- if (!cache_entry->Update()) {
- cache_entry->Release();
+ if (!cache_entry->Update())
cache_entry = NULL;
- }
found = true;
break;
}
- if (!cache_entry->Update()) {
- cache_entry->Release();
+ if (!cache_entry->Update())
cache_entry = NULL;
- }
- if (parent_entry)
- parent_entry->Release();
parent_entry = cache_entry;
cache_entry = NULL;
if (!parent_entry)
@@ -1172,17 +1165,14 @@
address.set_value(parent_entry->GetNextAddress());
}
- if (parent_entry && (!find_parent || !found)) {
- parent_entry->Release();
+ if (parent_entry && (!find_parent || !found))
parent_entry = NULL;
- }
- if (cache_entry && (find_parent || !found)) {
- cache_entry->Release();
+ if (cache_entry && (find_parent || !found))
cache_entry = NULL;
- }
- return find_parent ? parent_entry : cache_entry;
+ find_parent ? parent_entry.swap(&tmp) : cache_entry.swap(&tmp);
+ return tmp;
}
// This is the actual implementation for OpenNextEntry and OpenPrevEntry.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698