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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 if (header_->lru.filled) | 267 if (header_->lru.filled) |
268 return; | 268 return; |
269 | 269 |
270 header_->lru.filled = 1; | 270 header_->lru.filled = 1; |
271 | 271 |
272 if (header_->create_time) { | 272 if (header_->create_time) { |
273 // This is the first entry that we have to evict, generate some noise. | 273 // This is the first entry that we have to evict, generate some noise. |
274 backend_->FirstEviction(); | 274 backend_->FirstEviction(); |
275 } else { | 275 } else { |
276 // This is an old file, but we may want more reports from this user so | 276 // This is an old file, but we may want more reports from this user so |
277 // lets save some create_time. | 277 // lets save some create_time. Conversion cannot fail here. |
278 Time::Exploded old = {0}; | 278 Time::Exploded old = {0}; |
279 old.year = 2009; | 279 old.year = 2009; |
280 old.month = 3; | 280 old.month = 3; |
281 old.day_of_month = 1; | 281 old.day_of_month = 1; |
282 header_->create_time = Time::FromLocalExploded(old).ToInternalValue(); | 282 base::Time out_time; |
| 283 bool conversion_success = Time::FromLocalExploded(old, &out_time); |
| 284 DCHECK(conversion_success); |
| 285 header_->create_time = out_time.ToInternalValue(); |
283 } | 286 } |
284 } | 287 } |
285 } | 288 } |
286 | 289 |
287 Rankings::List Eviction::GetListForEntry(EntryImpl* entry) { | 290 Rankings::List Eviction::GetListForEntry(EntryImpl* entry) { |
288 return Rankings::NO_USE; | 291 return Rankings::NO_USE; |
289 } | 292 } |
290 | 293 |
291 bool Eviction::EvictEntry(CacheRankingsBlock* node, bool empty, | 294 bool Eviction::EvictEntry(CacheRankingsBlock* node, bool empty, |
292 Rankings::List list) { | 295 Rankings::List list) { |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 Time::FromInternalValue(last2.get()->Data()->last_used)); | 601 Time::FromInternalValue(last2.get()->Data()->last_used)); |
599 if (last3.get()) | 602 if (last3.get()) |
600 CACHE_UMA(AGE, "HighUseAge", 0, | 603 CACHE_UMA(AGE, "HighUseAge", 0, |
601 Time::FromInternalValue(last3.get()->Data()->last_used)); | 604 Time::FromInternalValue(last3.get()->Data()->last_used)); |
602 if (last4.get()) | 605 if (last4.get()) |
603 CACHE_UMA(AGE, "DeletedAge", 0, | 606 CACHE_UMA(AGE, "DeletedAge", 0, |
604 Time::FromInternalValue(last4.get()->Data()->last_used)); | 607 Time::FromInternalValue(last4.get()->Data()->last_used)); |
605 } | 608 } |
606 | 609 |
607 } // namespace disk_cache | 610 } // namespace disk_cache |
OLD | NEW |