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

Side by Side Diff: net/disk_cache/blockfile/eviction.cc

Issue 2673863003: Fix loop early exit bug in blockfile cache Trim behavior. (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // The eviction policy is a very simple pure LRU, so the elements at the end of 5 // The eviction policy is a very simple pure LRU, so the elements at the end of
6 // the list are evicted until kCleanUpMargin free space is available. There is 6 // the list are evicted until kCleanUpMargin free space is available. There is
7 // only one list in use (Rankings::NO_USE), and elements are sent to the front 7 // only one list in use (Rankings::NO_USE), and elements are sent to the front
8 // of the list whenever they are accessed. 8 // of the list whenever they are accessed.
9 9
10 // The new (in-development) eviction policy adds re-use as a factor to evict 10 // The new (in-development) eviction policy adds re-use as a factor to evict
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 void Eviction::TrimCacheV2(bool empty) { 322 void Eviction::TrimCacheV2(bool empty) {
323 Trace("*** Trim Cache ***"); 323 Trace("*** Trim Cache ***");
324 trimming_ = true; 324 trimming_ = true;
325 TimeTicks start = TimeTicks::Now(); 325 TimeTicks start = TimeTicks::Now();
326 326
327 const int kListsToSearch = 3; 327 const int kListsToSearch = 3;
328 Rankings::ScopedRankingsBlock next[kListsToSearch]; 328 Rankings::ScopedRankingsBlock next[kListsToSearch];
329 int list = Rankings::LAST_ELEMENT; 329 int list = Rankings::LAST_ELEMENT;
330 330
331 // Get a node from each list. 331 // Get a node from each list.
332 bool done = false;
332 for (int i = 0; i < kListsToSearch; i++) { 333 for (int i = 0; i < kListsToSearch; i++) {
333 bool done = false;
334 next[i].set_rankings(rankings_); 334 next[i].set_rankings(rankings_);
335 if (done) 335 if (done)
336 continue; 336 continue;
337 next[i].reset(rankings_->GetPrev(NULL, static_cast<Rankings::List>(i))); 337 next[i].reset(rankings_->GetPrev(NULL, static_cast<Rankings::List>(i)));
338 if (!empty && NodeIsOldEnough(next[i].get(), i)) { 338 if (!empty && NodeIsOldEnough(next[i].get(), i)) {
339 list = static_cast<Rankings::List>(i); 339 list = static_cast<Rankings::List>(i);
340 done = true; 340 done = true;
341 } 341 }
342 } 342 }
343 343
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 Time::FromInternalValue(last2.get()->Data()->last_used)); 597 Time::FromInternalValue(last2.get()->Data()->last_used));
598 if (last3.get()) 598 if (last3.get())
599 CACHE_UMA(AGE, "HighUseAge", 0, 599 CACHE_UMA(AGE, "HighUseAge", 0,
600 Time::FromInternalValue(last3.get()->Data()->last_used)); 600 Time::FromInternalValue(last3.get()->Data()->last_used));
601 if (last4.get()) 601 if (last4.get())
602 CACHE_UMA(AGE, "DeletedAge", 0, 602 CACHE_UMA(AGE, "DeletedAge", 0,
603 Time::FromInternalValue(last4.get()->Data()->last_used)); 603 Time::FromInternalValue(last4.get()->Data()->last_used));
604 } 604 }
605 605
606 } // namespace disk_cache 606 } // namespace disk_cache
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698