Index: net/disk_cache/simple/simple_backend_impl.h |
diff --git a/net/disk_cache/simple/simple_backend_impl.h b/net/disk_cache/simple/simple_backend_impl.h |
index 462a101f96147cf8dd7b99165a0c78dc96df8cc5..48c422f9f8802dc9bf837d0d75a01aab5d79c224 100644 |
--- a/net/disk_cache/simple/simple_backend_impl.h |
+++ b/net/disk_cache/simple/simple_backend_impl.h |
@@ -34,6 +34,11 @@ namespace disk_cache { |
// files. |
// See http://www.chromium.org/developers/design-documents/network-stack/disk-cache/very-simple-backend |
// |
+// The SimpleBackendImpl provides safe iteration; mutating entries during |
+// iteration cannot cause a crash. It is undefined whether entries created or |
+// destroyed during the iteration will be included in any pre-existing |
+// iterations. |
+// |
// The non-static functions below must be called on the IO thread unless |
// otherwise stated. |
@@ -97,14 +102,15 @@ class NET_EXPORT_PRIVATE SimpleBackendImpl : public Backend, |
const CompletionCallback& callback) OVERRIDE; |
virtual int DoomEntriesSince(base::Time initial_time, |
const CompletionCallback& callback) OVERRIDE; |
- virtual int OpenNextEntry(void** iter, Entry** next_entry, |
- const CompletionCallback& callback) OVERRIDE; |
- virtual void EndEnumeration(void** iter) OVERRIDE; |
+ virtual scoped_ptr<Iterator> CreateIterator() OVERRIDE; |
virtual void GetStats( |
std::vector<std::pair<std::string, std::string> >* stats) OVERRIDE; |
virtual void OnExternalCacheHit(const std::string& key) OVERRIDE; |
private: |
+ class SimpleIterator; |
+ friend class SimpleIterator; |
+ |
typedef base::hash_map<uint64, SimpleEntryImpl*> EntryMap; |
typedef base::Callback<void(base::Time mtime, uint64 max_size, int result)> |
@@ -155,14 +161,6 @@ class NET_EXPORT_PRIVATE SimpleBackendImpl : public Backend, |
// which is very important to prevent races in DoomEntries() above. |
int DoomEntryFromHash(uint64 entry_hash, const CompletionCallback & callback); |
- // Called when the index is initilized to find the next entry in the iterator |
- // |iter|. If there are no more hashes in the iterator list, net::ERR_FAILED |
- // is returned. Otherwise, calls OpenEntryFromHash. |
- void GetNextEntryInIterator(void** iter, |
- Entry** next_entry, |
- const CompletionCallback& callback, |
- int error_code); |
- |
// Called when we tried to open an entry with hash alone. When a blank entry |
// has been created and filled in with information from the disk - based on a |
// hash alone - this checks that a duplicate active entry was not created |
@@ -181,14 +179,6 @@ class NET_EXPORT_PRIVATE SimpleBackendImpl : public Backend, |
const CompletionCallback& callback, |
int error_code); |
- // Called at the end of the asynchronous operation triggered by |
- // OpenEntryFromHash. Makes sure to continue iterating if the open entry was |
- // not a success. |
- void CheckIterationReturnValue(void** iter, |
- Entry** entry, |
- const CompletionCallback& callback, |
- int error_code); |
- |
// A callback thunk used by DoomEntries to clear the |entries_pending_doom_| |
// after a mass doom. |
void DoomEntriesComplete(scoped_ptr<std::vector<uint64> > entry_hashes, |