| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2010 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 ads re-use as a factor to evict | 10 // The new (in-development) eviction policy ads re-use as a factor to evict |
| 11 // an entry. The story so far: | 11 // an entry. The story so far: |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 | 217 |
| 218 bool Eviction::EvictEntry(CacheRankingsBlock* node, bool empty) { | 218 bool Eviction::EvictEntry(CacheRankingsBlock* node, bool empty) { |
| 219 EntryImpl* entry = backend_->GetEnumeratedEntry(node, true); | 219 EntryImpl* entry = backend_->GetEnumeratedEntry(node, true); |
| 220 if (!entry) { | 220 if (!entry) { |
| 221 Trace("NewEntry failed on Trim 0x%x", node->address().value()); | 221 Trace("NewEntry failed on Trim 0x%x", node->address().value()); |
| 222 return false; | 222 return false; |
| 223 } | 223 } |
| 224 | 224 |
| 225 ReportTrimTimes(entry); | 225 ReportTrimTimes(entry); |
| 226 if (empty || !new_eviction_) { | 226 if (empty || !new_eviction_) { |
| 227 entry->Doom(); | 227 entry->DoomImpl(); |
| 228 } else { | 228 } else { |
| 229 entry->DeleteEntryData(false); | 229 entry->DeleteEntryData(false); |
| 230 EntryStore* info = entry->entry()->Data(); | 230 EntryStore* info = entry->entry()->Data(); |
| 231 DCHECK(ENTRY_NORMAL == info->state); | 231 DCHECK(ENTRY_NORMAL == info->state); |
| 232 | 232 |
| 233 rankings_->Remove(entry->rankings(), GetListForEntryV2(entry)); | 233 rankings_->Remove(entry->rankings(), GetListForEntryV2(entry)); |
| 234 info->state = ENTRY_EVICTED; | 234 info->state = ENTRY_EVICTED; |
| 235 entry->entry()->Store(); | 235 entry->entry()->Store(); |
| 236 rankings_->Insert(entry->rankings(), true, Rankings::DELETED); | 236 rankings_->Insert(entry->rankings(), true, Rankings::DELETED); |
| 237 backend_->OnEvent(Stats::TRIM_ENTRY); | 237 backend_->OnEvent(Stats::TRIM_ENTRY); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 } | 446 } |
| 447 | 447 |
| 448 // TODO(rvargas): figure out how to deal with corruption at this point (dirty | 448 // TODO(rvargas): figure out how to deal with corruption at this point (dirty |
| 449 // entries that live in this list). | 449 // entries that live in this list). |
| 450 if (node->Data()->dirty) { | 450 if (node->Data()->dirty) { |
| 451 // We ignore the failure; we're removing the entry anyway. | 451 // We ignore the failure; we're removing the entry anyway. |
| 452 entry->Update(); | 452 entry->Update(); |
| 453 } | 453 } |
| 454 bool doomed = (entry->entry()->Data()->state == ENTRY_DOOMED); | 454 bool doomed = (entry->entry()->Data()->state == ENTRY_DOOMED); |
| 455 entry->entry()->Data()->state = ENTRY_DOOMED; | 455 entry->entry()->Data()->state = ENTRY_DOOMED; |
| 456 entry->Doom(); | 456 entry->DoomImpl(); |
| 457 entry->Release(); | 457 entry->Release(); |
| 458 return !doomed; | 458 return !doomed; |
| 459 } | 459 } |
| 460 | 460 |
| 461 bool Eviction::NodeIsOldEnough(CacheRankingsBlock* node, int list) { | 461 bool Eviction::NodeIsOldEnough(CacheRankingsBlock* node, int list) { |
| 462 if (!node) | 462 if (!node) |
| 463 return false; | 463 return false; |
| 464 | 464 |
| 465 // If possible, we want to keep entries on each list at least kTargetTime | 465 // If possible, we want to keep entries on each list at least kTargetTime |
| 466 // hours. Each successive list on the enumeration has 2x the target time of | 466 // hours. Each successive list on the enumeration has 2x the target time of |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 Time::FromInternalValue(last2.get()->Data()->last_used)); | 502 Time::FromInternalValue(last2.get()->Data()->last_used)); |
| 503 if (last3.get()) | 503 if (last3.get()) |
| 504 CACHE_UMA(AGE, "HighUseAge", 0, | 504 CACHE_UMA(AGE, "HighUseAge", 0, |
| 505 Time::FromInternalValue(last3.get()->Data()->last_used)); | 505 Time::FromInternalValue(last3.get()->Data()->last_used)); |
| 506 if (last4.get()) | 506 if (last4.get()) |
| 507 CACHE_UMA(AGE, "DeletedAge", 0, | 507 CACHE_UMA(AGE, "DeletedAge", 0, |
| 508 Time::FromInternalValue(last4.get()->Data()->last_used)); | 508 Time::FromInternalValue(last4.get()->Data()->last_used)); |
| 509 } | 509 } |
| 510 | 510 |
| 511 } // namespace disk_cache | 511 } // namespace disk_cache |
| OLD | NEW |