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

Unified Diff: net/disk_cache/blockfile/in_flight_backend_io.cc

Issue 583293002: Do not leak when iterator outlives disk cache backend. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cacheenums-again
Patch Set: cleaner ownership 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/blockfile/in_flight_backend_io.cc
diff --git a/net/disk_cache/blockfile/in_flight_backend_io.cc b/net/disk_cache/blockfile/in_flight_backend_io.cc
index 8cd12ae40997e0b1f85e1d539fc67b74671115a4..28d7114ba610313a76a4878a3d1460f2c1cacd64 100644
--- a/net/disk_cache/blockfile/in_flight_backend_io.cc
+++ b/net/disk_cache/blockfile/in_flight_backend_io.cc
@@ -26,8 +26,7 @@ BackendIO::BackendIO(InFlightIO* controller, BackendImpl* backend,
callback_(callback),
operation_(OP_NONE),
entry_ptr_(NULL),
- iter_ptr_(NULL),
- iter_(NULL),
+ iterator_(NULL),
entry_(NULL),
index_(0),
offset_(0),
@@ -116,15 +115,16 @@ void BackendIO::DoomEntriesSince(const base::Time initial_time) {
initial_time_ = initial_time;
}
-void BackendIO::OpenNextEntry(void** iter, Entry** next_entry) {
+void BackendIO::OpenNextEntry(Rankings::Iterator* iterator,
+ Entry** next_entry) {
operation_ = OP_OPEN_NEXT;
- iter_ptr_ = iter;
+ iterator_ = iterator;
entry_ptr_ = next_entry;
}
-void BackendIO::EndEnumeration(void* iterator) {
+void BackendIO::EndEnumeration(scoped_ptr<Rankings::Iterator> iterator) {
operation_ = OP_END_ENUMERATION;
- iter_ = iterator;
+ scoped_iterator_ = iterator.Pass();
}
void BackendIO::OnExternalCacheHit(const std::string& key) {
@@ -245,10 +245,10 @@ void BackendIO::ExecuteBackendOperation() {
result_ = backend_->SyncDoomEntriesSince(initial_time_);
break;
case OP_OPEN_NEXT:
- result_ = backend_->SyncOpenNextEntry(iter_ptr_, entry_ptr_);
+ result_ = backend_->SyncOpenNextEntry(iterator_, entry_ptr_);
break;
case OP_END_ENUMERATION:
- backend_->SyncEndEnumeration(iter_);
+ backend_->SyncEndEnumeration(scoped_iterator_.Pass());
result_ = net::OK;
break;
case OP_ON_EXTERNAL_CACHE_HIT:
@@ -382,17 +382,19 @@ void InFlightBackendIO::DoomEntriesSince(
PostOperation(operation.get());
}
-void InFlightBackendIO::OpenNextEntry(void** iter, Entry** next_entry,
+void InFlightBackendIO::OpenNextEntry(Rankings::Iterator* iterator,
+ Entry** next_entry,
const net::CompletionCallback& callback) {
scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback));
- operation->OpenNextEntry(iter, next_entry);
+ operation->OpenNextEntry(iterator, next_entry);
PostOperation(operation.get());
}
-void InFlightBackendIO::EndEnumeration(void* iterator) {
+void InFlightBackendIO::EndEnumeration(
+ scoped_ptr<Rankings::Iterator> iterator) {
scoped_refptr<BackendIO> operation(
new BackendIO(this, backend_, net::CompletionCallback()));
- operation->EndEnumeration(iterator);
+ operation->EndEnumeration(iterator.Pass());
PostOperation(operation.get());
}

Powered by Google App Engine
This is Rietveld 408576698