diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-08 21:39:08 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-08 21:39:08 +0000 |
commit | 9e6f8526f9a60410b6d448103a9015d72a067deb (patch) | |
tree | 344dfd33a7db6e166fce493c06991dd037e55fb9 /net/disk_cache/backend_impl.cc | |
parent | f01b25cdcb53d8e52a3c6623a9b383f52afc6a00 (diff) | |
download | chromium_src-9e6f8526f9a60410b6d448103a9015d72a067deb.zip chromium_src-9e6f8526f9a60410b6d448103a9015d72a067deb.tar.gz chromium_src-9e6f8526f9a60410b6d448103a9015d72a067deb.tar.bz2 |
Disk cache: Additional code cleanup after CL 20067.
BUG=15596
TEST=none
Review URL: http://codereview.chromium.org/155231
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20190 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/backend_impl.cc')
-rw-r--r-- | net/disk_cache/backend_impl.cc | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/net/disk_cache/backend_impl.cc b/net/disk_cache/backend_impl.cc index 3cd3cc2..0a59030 100644 --- a/net/disk_cache/backend_impl.cc +++ b/net/disk_cache/backend_impl.cc @@ -1103,8 +1103,8 @@ int BackendImpl::NewEntry(Addr address, EntryImpl** entry, bool* dirty) { 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 @@ EntryImpl* BackendImpl::MatchEntry(const std::string& key, uint32 hash, } 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 @@ EntryImpl* BackendImpl::MatchEntry(const std::string& key, uint32 hash, if (parent_entry) { parent_entry->SetNextAddress(child); - parent_entry->Release(); parent_entry = NULL; } else { data_->table[hash & mask_] = child.value(); @@ -1139,7 +1139,6 @@ EntryImpl* BackendImpl::MatchEntry(const std::string& key, uint32 hash, // 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 @@ EntryImpl* BackendImpl::MatchEntry(const std::string& key, uint32 hash, } 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 @@ EntryImpl* BackendImpl::MatchEntry(const std::string& key, uint32 hash, 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. |