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

Unified Diff: net/disk_cache/memory/mem_backend_impl.cc

Issue 542733002: Remove void** from disk_cache interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: narrow given upstream 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/memory/mem_backend_impl.cc
diff --git a/net/disk_cache/memory/mem_backend_impl.cc b/net/disk_cache/memory/mem_backend_impl.cc
index e69c00edf636a45379a7f29db182512dd8a67c36..7df8b2e8504cba779bfc9296572389904fa8fb8e 100644
--- a/net/disk_cache/memory/mem_backend_impl.cc
+++ b/net/disk_cache/memory/mem_backend_impl.cc
@@ -180,7 +180,7 @@ int MemBackendImpl::DoomEntriesSince(const base::Time initial_time,
return net::ERR_FAILED;
}
-int MemBackendImpl::OpenNextEntry(void** iter, Entry** next_entry,
+int MemBackendImpl::OpenNextEntry(Iterator* iter, Entry** next_entry,
const CompletionCallback& callback) {
if (OpenNextEntry(iter, next_entry))
return net::OK;
@@ -188,10 +188,6 @@ int MemBackendImpl::OpenNextEntry(void** iter, Entry** next_entry,
return net::ERR_FAILED;
}
-void MemBackendImpl::EndEnumeration(void** iter) {
- *iter = NULL;
-}
-
void MemBackendImpl::OnExternalCacheHit(const std::string& key) {
EntryMap::iterator it = entries_.find(key);
if (it != entries_.end()) {
@@ -287,16 +283,29 @@ bool MemBackendImpl::DoomEntriesSince(const Time initial_time) {
}
}
-bool MemBackendImpl::OpenNextEntry(void** iter, Entry** next_entry) {
- MemEntryImpl* current = reinterpret_cast<MemEntryImpl*>(*iter);
- MemEntryImpl* node = rankings_.GetNext(current);
+bool MemBackendImpl::OpenNextEntry(Iterator* iter, Entry** next_entry) {
+ class State : public EnumerationState {
+ public:
+ State() : current_(NULL) {}
+
+ MemEntryImpl* current() { return current_; }
+ void set_current(MemEntryImpl* current) { current_ = current; }
+
+ private:
+ MemEntryImpl* current_;
+ };
+ if (!*iter)
+ iter->reset(new State());
+ State* state = static_cast<State*>(iter->get());
+
+ MemEntryImpl* node = rankings_.GetNext(state->current());
// We should never return a child entry so iterate until we hit a parent
// entry.
while (node && node->type() != MemEntryImpl::kParentEntry) {
node = rankings_.GetNext(node);
}
*next_entry = node;
- *iter = node;
+ state->set_current(node);
if (node)
node->Open();

Powered by Google App Engine
This is Rietveld 408576698