| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |