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

Unified Diff: components/browsing_data/conditional_cache_deletion_helper.cc

Issue 2008323002: Add tests for the cache deletion in BrowsingDataRemover (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix memory leak Created 4 years, 7 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: components/browsing_data/conditional_cache_deletion_helper.cc
diff --git a/components/browsing_data/conditional_cache_deletion_helper.cc b/components/browsing_data/conditional_cache_deletion_helper.cc
index 49f0671f2f7efe9841ed3e139ba3d79f99c3fe70..110b6d349078d5fc050339341f30481cb204f2c0 100644
--- a/components/browsing_data/conditional_cache_deletion_helper.cc
+++ b/components/browsing_data/conditional_cache_deletion_helper.cc
@@ -62,10 +62,15 @@ ConditionalCacheDeletionHelper::~ConditionalCacheDeletionHelper() {
void ConditionalCacheDeletionHelper::IterateOverEntries(int error) {
while (error != net::ERR_IO_PENDING) {
- // Delete the entry obtained in the previous iteration. The iterator is
- // already one step forward, so it won't be invalidated.
- if (previous_entry_ && condition_.Run(previous_entry_))
+ // If the entry obtained in the previous iteration matches the condition,
+ // mark it for deletion. The iterator is already one step forward, so it
+ // won't be invalidated. Always close the previous entry so it does not
+ // leak.
+ if (previous_entry_) {
+ if (condition_.Run(previous_entry_))
previous_entry_->Doom();
+ previous_entry_->Close();
+ }
if (error == net::ERR_FAILED) {
// The iteration finished successfuly or we can no longer iterate

Powered by Google App Engine
This is Rietveld 408576698