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

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

Issue 585833002: Revert of Remove void** from disk_cache interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/memory/mem_backend_impl.h ('k') | net/disk_cache/simple/simple_backend_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 848ef985db9c4621711dd9ce47cba396445286fa..e69c00edf636a45379a7f29db182512dd8a67c36 100644
--- a/net/disk_cache/memory/mem_backend_impl.cc
+++ b/net/disk_cache/memory/mem_backend_impl.cc
@@ -29,8 +29,7 @@
namespace disk_cache {
MemBackendImpl::MemBackendImpl(net::NetLog* net_log)
- : max_size_(0), current_size_(0), net_log_(net_log), weak_factory_(this) {
-}
+ : max_size_(0), current_size_(0), net_log_(net_log) {}
MemBackendImpl::~MemBackendImpl() {
EntryMap::iterator it = entries_.begin();
@@ -181,40 +180,16 @@
return net::ERR_FAILED;
}
-class MemBackendImpl::MemIterator : public Backend::Iterator {
- public:
- explicit MemIterator(base::WeakPtr<MemBackendImpl> backend)
- : backend_(backend), current_(NULL) {
- }
-
- virtual int OpenNextEntry(Entry** next_entry,
- const CompletionCallback& callback) OVERRIDE {
- if (!backend_)
- return net::ERR_FAILED;
-
- MemEntryImpl* node = backend_->rankings_.GetNext(current_);
- // We should never return a child entry so iterate until we hit a parent
- // entry.
- while (node && node->type() != MemEntryImpl::kParentEntry)
- node = backend_->rankings_.GetNext(node);
- *next_entry = node;
- current_ = node;
-
- if (node) {
- node->Open();
- return net::OK;
- }
- return net::ERR_FAILED;
- }
-
- private:
- base::WeakPtr<MemBackendImpl> backend_;
- MemEntryImpl* current_;
-};
-
-scoped_ptr<Backend::Iterator> MemBackendImpl::CreateIterator() {
- return scoped_ptr<Backend::Iterator>(
- new MemIterator(weak_factory_.GetWeakPtr()));
+int MemBackendImpl::OpenNextEntry(void** iter, Entry** next_entry,
+ const CompletionCallback& callback) {
+ if (OpenNextEntry(iter, next_entry))
+ return net::OK;
+
+ return net::ERR_FAILED;
+}
+
+void MemBackendImpl::EndEnumeration(void** iter) {
+ *iter = NULL;
}
void MemBackendImpl::OnExternalCacheHit(const std::string& key) {
@@ -312,6 +287,23 @@
}
}
+bool MemBackendImpl::OpenNextEntry(void** iter, Entry** next_entry) {
+ MemEntryImpl* current = reinterpret_cast<MemEntryImpl*>(*iter);
+ MemEntryImpl* node = rankings_.GetNext(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;
+
+ if (node)
+ node->Open();
+
+ return NULL != node;
+}
+
void MemBackendImpl::TrimCache(bool empty) {
MemEntryImpl* next = rankings_.GetPrev(NULL);
if (!next)
« no previous file with comments | « net/disk_cache/memory/mem_backend_impl.h ('k') | net/disk_cache/simple/simple_backend_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698