| 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..4d79fab16aff27da4c0fb4f4f707f9618da87041 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) {
|
|
|