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

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

Issue 542733002: Remove void** from disk_cache interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more more explicit constructor 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
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 ffdc9b185b366ef95a2f1b6ca91a89714e6423f5..0d896114af0c7e99cecbf4c587c8ac9034f628c5 100644
--- a/net/disk_cache/simple/simple_backend_impl.cc
+++ b/net/disk_cache/simple/simple_backend_impl.cc
@@ -473,20 +473,13 @@ int SimpleBackendImpl::DoomEntriesSince(
return DoomEntriesBetween(initial_time, Time(), callback);
}
-int SimpleBackendImpl::OpenNextEntry(void** iter,
+int SimpleBackendImpl::OpenNextEntry(Iterator* iter,
Entry** next_entry,
const CompletionCallback& callback) {
- CompletionCallback get_next_entry =
- base::Bind(&SimpleBackendImpl::GetNextEntryInIterator, AsWeakPtr(), iter,
+ CompletionCallback open_next_entry_impl =
+ base::Bind(&SimpleBackendImpl::OpenNextEntryImpl, AsWeakPtr(), iter,
next_entry, callback);
- return index_->ExecuteWhenReady(get_next_entry);
-}
-
-void SimpleBackendImpl::EndEnumeration(void** iter) {
- SimpleIndex::HashList* entry_list =
- static_cast<SimpleIndex::HashList*>(*iter);
- delete entry_list;
- *iter = NULL;
+ return index_->ExecuteWhenReady(open_next_entry_impl);
}
void SimpleBackendImpl::GetStats(
@@ -614,23 +607,35 @@ int SimpleBackendImpl::DoomEntryFromHash(uint64 entry_hash,
return net::ERR_IO_PENDING;
}
-void SimpleBackendImpl::GetNextEntryInIterator(
- void** iter,
- Entry** next_entry,
- const CompletionCallback& callback,
- int error_code) {
- if (error_code != net::OK) {
- callback.Run(error_code);
+void SimpleBackendImpl::OpenNextEntryImpl(Iterator* iter,
+ Entry** next_entry,
+ const CompletionCallback& callback,
+ int index_initialization_error_code) {
+ if (index_initialization_error_code != net::OK) {
+ callback.Run(index_initialization_error_code);
return;
}
- if (*iter == NULL) {
- *iter = index()->GetAllHashes().release();
- }
- SimpleIndex::HashList* entry_list =
- static_cast<SimpleIndex::HashList*>(*iter);
- while (entry_list->size() > 0) {
- uint64 entry_hash = entry_list->back();
- entry_list->pop_back();
+
+ class State : public EnumerationState {
+ public:
+ explicit State(scoped_ptr<std::vector<uint64> > hashes_to_enumerate) {
+ hashes_to_enumerate_.swap(*hashes_to_enumerate);
+ }
+ virtual ~State() {}
+
+ std::vector<uint64>& hashes_to_enumerate() { return hashes_to_enumerate_; }
+
+ private:
+ std::vector<uint64> hashes_to_enumerate_;
+ };
+
+ if (!*iter)
+ iter->reset(new State(index()->GetAllHashes().Pass()));
+ State* state = static_cast<State*>(iter->get());
+
+ while (!state->hashes_to_enumerate().empty()) {
+ uint64 entry_hash = state->hashes_to_enumerate().back();
+ state->hashes_to_enumerate().pop_back();
if (index()->Has(entry_hash)) {
*next_entry = NULL;
CompletionCallback continue_iteration = base::Bind(
@@ -707,7 +712,7 @@ void SimpleBackendImpl::OnEntryOpenedFromKey(
}
void SimpleBackendImpl::CheckIterationReturnValue(
- void** iter,
+ Iterator* iter,
Entry** entry,
const CompletionCallback& callback,
int error_code) {

Powered by Google App Engine
This is Rietveld 408576698