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

Unified Diff: net/disk_cache/simple/simple_backend_impl.cc

Issue 533293002: Delete enumerations at Simple Cache backend deletion. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: get really explicit about sizes Created 6 years, 3 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/simple/simple_backend_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/simple/simple_backend_impl.cc
diff --git a/net/disk_cache/simple/simple_backend_impl.cc b/net/disk_cache/simple/simple_backend_impl.cc
index c92a93a7114406d7003290d8b5ae55019d36502e..5b7f77961dc4e734c6d58840f91085cc32c7ed42 100644
--- a/net/disk_cache/simple/simple_backend_impl.cc
+++ b/net/disk_cache/simple/simple_backend_impl.cc
@@ -483,9 +483,10 @@ int SimpleBackendImpl::OpenNextEntry(void** iter,
}
void SimpleBackendImpl::EndEnumeration(void** iter) {
- SimpleIndex::HashList* entry_list =
- static_cast<SimpleIndex::HashList*>(*iter);
- delete entry_list;
+ const ptrdiff_t ptrdiff_enumeration_id = reinterpret_cast<ptrdiff_t>(*iter);
+ const ActiveEnumerationMap::KeyType enumeration_id = ptrdiff_enumeration_id;
jsbell 2014/09/03 22:30:42 How about a helper to hide and self-document the r
gavinp 2014/09/12 21:01:04 Good idea. I threw in some COMPILE_ASSERTS around
+ DCHECK_EQ(enumeration_id, ptrdiff_enumeration_id);
+ active_enumerations_.Remove(enumeration_id);
*iter = NULL;
}
@@ -623,11 +624,21 @@ void SimpleBackendImpl::GetNextEntryInIterator(
callback.Run(error_code);
return;
}
+ std::vector<uint64>* entry_list = NULL;
clamy 2014/09/03 19:47:48 nit: The previous version used the type SimpleInde
gavinp 2014/09/12 21:01:04 No. Using SimpleIndex::HashList was actually the o
if (*iter == NULL) {
- *iter = index()->GetAllHashes().release();
+ const ActiveEnumerationMap::KeyType new_enumeration_id =
+ active_enumerations_.Add(
+ entry_list = index()->GetAllHashes().release());
+ const ptrdiff_t ptrdiff_new_enumeration_id = new_enumeration_id;
+ DCHECK_EQ(new_enumeration_id, ptrdiff_new_enumeration_id);
+ *iter = reinterpret_cast<void*>(ptrdiff_new_enumeration_id);
+ } else {
+ const ptrdiff_t ptrdiff_enumeration_id =
+ reinterpret_cast<ptrdiff_t>(*iter);
+ const ActiveEnumerationMap::KeyType enumeration_id = ptrdiff_enumeration_id;
clamy 2014/09/03 19:47:48 This is really ugly, but I guess we don't really h
gavinp 2014/09/12 21:01:04 I will do this via a helper as jsbell suggested.
+ DCHECK_EQ(ptrdiff_enumeration_id, enumeration_id);
+ entry_list = active_enumerations_.Lookup(enumeration_id);
}
- SimpleIndex::HashList* entry_list =
- static_cast<SimpleIndex::HashList*>(*iter);
while (entry_list->size() > 0) {
uint64 entry_hash = entry_list->back();
entry_list->pop_back();
« no previous file with comments | « net/disk_cache/simple/simple_backend_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698