Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2010 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 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 // when we're actually doing work. | 63 // when we're actually doing work. |
| 64 backend_ = backend; | 64 backend_ = backend; |
| 65 rankings_ = &backend->rankings_; | 65 rankings_ = &backend->rankings_; |
| 66 header_ = &backend_->data_->header; | 66 header_ = &backend_->data_->header; |
| 67 max_size_ = LowWaterAdjust(backend_->max_size_); | 67 max_size_ = LowWaterAdjust(backend_->max_size_); |
| 68 new_eviction_ = backend->new_eviction_; | 68 new_eviction_ = backend->new_eviction_; |
| 69 first_trim_ = true; | 69 first_trim_ = true; |
| 70 trimming_ = false; | 70 trimming_ = false; |
| 71 delay_trim_ = false; | 71 delay_trim_ = false; |
| 72 trim_delays_ = 0; | 72 trim_delays_ = 0; |
| 73 init_ = true; | |
| 74 } | |
| 75 | |
| 76 void Eviction::Stop() { | |
| 77 if (!init_) | |
| 78 return; | |
|
gavinp
2010/07/19 22:20:31
NOTREACHED() ?
rvargas (doing something else)
2010/07/19 23:48:28
I added a comment explaining when we'll reach Stop
| |
| 79 | |
| 80 // We want to stop further evictions, so let's pretend that we are busy from | |
| 81 // this point on. | |
| 82 DCHECK(!trimming_); | |
| 83 trimming_ = true; | |
| 73 } | 84 } |
| 74 | 85 |
| 75 void Eviction::TrimCache(bool empty) { | 86 void Eviction::TrimCache(bool empty) { |
| 76 if (backend_->disabled_ || trimming_) | 87 if (backend_->disabled_ || trimming_) |
| 77 return; | 88 return; |
| 78 | 89 |
| 79 if (!empty && !ShouldTrim()) | 90 if (!empty && !ShouldTrim()) |
| 80 return PostDelayedTrim(); | 91 return PostDelayedTrim(); |
| 81 | 92 |
| 82 if (new_eviction_) | 93 if (new_eviction_) |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 502 Time::FromInternalValue(last2.get()->Data()->last_used)); | 513 Time::FromInternalValue(last2.get()->Data()->last_used)); |
| 503 if (last3.get()) | 514 if (last3.get()) |
| 504 CACHE_UMA(AGE, "HighUseAge", 0, | 515 CACHE_UMA(AGE, "HighUseAge", 0, |
| 505 Time::FromInternalValue(last3.get()->Data()->last_used)); | 516 Time::FromInternalValue(last3.get()->Data()->last_used)); |
| 506 if (last4.get()) | 517 if (last4.get()) |
| 507 CACHE_UMA(AGE, "DeletedAge", 0, | 518 CACHE_UMA(AGE, "DeletedAge", 0, |
| 508 Time::FromInternalValue(last4.get()->Data()->last_used)); | 519 Time::FromInternalValue(last4.get()->Data()->last_used)); |
| 509 } | 520 } |
| 510 | 521 |
| 511 } // namespace disk_cache | 522 } // namespace disk_cache |
| OLD | NEW |