| Index: net/disk_cache/blockfile/backend_impl.cc
|
| diff --git a/net/disk_cache/blockfile/backend_impl.cc b/net/disk_cache/blockfile/backend_impl.cc
|
| index 0d258351a351bd4a5bddf186e750cac9fc4a324a..fe44bc202740266c8e84dc21c4a054954caa107e 100644
|
| --- a/net/disk_cache/blockfile/backend_impl.cc
|
| +++ b/net/disk_cache/blockfile/backend_impl.cc
|
| @@ -52,6 +52,25 @@ const int kBaseTableLen = 64 * 1024;
|
| // Avoid trimming the cache for the first 5 minutes (10 timer ticks).
|
| const int kTrimDelay = 10;
|
|
|
| +class BackendEnumerationState : public disk_cache::Backend::EnumerationState {
|
| + public:
|
| + explicit BackendEnumerationState(
|
| + base::WeakPtr<disk_cache::InFlightBackendIO> background_queue)
|
| + : background_queue_(background_queue),
|
| + data_(NULL) {}
|
| +
|
| + virtual ~BackendEnumerationState() {
|
| + if (background_queue_)
|
| + background_queue_->EndEnumeration(*data());
|
| + }
|
| +
|
| + void** data() { return &data_; }
|
| +
|
| + private:
|
| + base::WeakPtr<disk_cache::InFlightBackendIO> background_queue_;
|
| + void* data_;
|
| +};
|
| +
|
| int DesiredIndexTableLen(int32 storage_size) {
|
| if (storage_size <= k64kEntriesStore)
|
| return kBaseTableLen;
|
| @@ -328,10 +347,15 @@ void BackendImpl::CleanupCache() {
|
|
|
| // ------------------------------------------------------------------------
|
|
|
| -int BackendImpl::OpenPrevEntry(void** iter, Entry** prev_entry,
|
| +int BackendImpl::OpenPrevEntry(Iterator* iter, Entry** prev_entry,
|
| const CompletionCallback& callback) {
|
| DCHECK(!callback.is_null());
|
| - background_queue_.OpenPrevEntry(iter, prev_entry, callback);
|
| + if (!*iter)
|
| + iter->reset(new BackendEnumerationState(GetBackgroundQueue()));
|
| + BackendEnumerationState* state =
|
| + static_cast<BackendEnumerationState*>(iter->get());
|
| +
|
| + background_queue_.OpenPrevEntry(state->data(), prev_entry, callback);
|
| return net::ERR_IO_PENDING;
|
| }
|
|
|
| @@ -1199,16 +1223,17 @@ int BackendImpl::DoomEntriesSince(const base::Time initial_time,
|
| return net::ERR_IO_PENDING;
|
| }
|
|
|
| -int BackendImpl::OpenNextEntry(void** iter, Entry** next_entry,
|
| +int BackendImpl::OpenNextEntry(Iterator* iter, Entry** next_entry,
|
| const CompletionCallback& callback) {
|
| + // TODO(gavinp): Remove all void** iter from cache.
|
| DCHECK(!callback.is_null());
|
| - background_queue_.OpenNextEntry(iter, next_entry, callback);
|
| - return net::ERR_IO_PENDING;
|
| -}
|
| + if (!*iter)
|
| + iter->reset(new BackendEnumerationState(GetBackgroundQueue()));
|
| + BackendEnumerationState* state =
|
| + static_cast<BackendEnumerationState*>(iter->get());
|
|
|
| -void BackendImpl::EndEnumeration(void** iter) {
|
| - background_queue_.EndEnumeration(*iter);
|
| - *iter = NULL;
|
| + background_queue_.OpenNextEntry(state->data(), next_entry, callback);
|
| + return net::ERR_IO_PENDING;
|
| }
|
|
|
| void BackendImpl::GetStats(StatsItems* stats) {
|
|
|