| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include "net/disk_cache/backend_impl.h" | 5 #include "net/disk_cache/backend_impl.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/histogram.h" | 8 #include "base/histogram.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1303 if (!data_->header.lru.filled) | 1303 if (!data_->header.lru.filled) |
| 1304 return; | 1304 return; |
| 1305 | 1305 |
| 1306 // This is an up to date client that will report FirstEviction() data. After | 1306 // This is an up to date client that will report FirstEviction() data. After |
| 1307 // that event, start reporting this: | 1307 // that event, start reporting this: |
| 1308 | 1308 |
| 1309 int64 total_hours = stats_.GetCounter(Stats::TIMER) / 120; | 1309 int64 total_hours = stats_.GetCounter(Stats::TIMER) / 120; |
| 1310 CACHE_UMA(HOURS, "TotalTime", 0, static_cast<int>(total_hours)); | 1310 CACHE_UMA(HOURS, "TotalTime", 0, static_cast<int>(total_hours)); |
| 1311 | 1311 |
| 1312 int64 use_hours = stats_.GetCounter(Stats::LAST_REPORT_TIMER) / 120; | 1312 int64 use_hours = stats_.GetCounter(Stats::LAST_REPORT_TIMER) / 120; |
| 1313 stats_.SetCounter(Stats::LAST_REPORT_TIMER, stats_.GetCounter(Stats::TIMER)); |
| 1314 |
| 1315 // We may see users with no use_hours at this point if this is the first time |
| 1316 // we are running this code. |
| 1317 if (use_hours) |
| 1318 use_hours = total_hours - use_hours; |
| 1319 |
| 1313 if (!use_hours || !GetEntryCount() || !data_->header.num_bytes) | 1320 if (!use_hours || !GetEntryCount() || !data_->header.num_bytes) |
| 1314 return; | 1321 return; |
| 1315 | 1322 |
| 1316 CACHE_UMA(HOURS, "UseTime", 0, static_cast<int>(use_hours)); | 1323 CACHE_UMA(HOURS, "UseTime", 0, static_cast<int>(use_hours)); |
| 1317 CACHE_UMA(PERCENTAGE, "HitRatio", 0, stats_.GetHitRatio()); | 1324 CACHE_UMA(PERCENTAGE, "HitRatio", 0, stats_.GetHitRatio()); |
| 1318 CACHE_UMA(PERCENTAGE, "ResurrectRatio", 0, stats_.GetResurrectRatio()); | 1325 CACHE_UMA(PERCENTAGE, "ResurrectRatio", 0, stats_.GetResurrectRatio()); |
| 1319 | 1326 |
| 1320 int64 trim_rate = stats_.GetCounter(Stats::TRIM_ENTRY) / use_hours; | 1327 int64 trim_rate = stats_.GetCounter(Stats::TRIM_ENTRY) / use_hours; |
| 1321 CACHE_UMA(COUNTS, "TrimRate", 0, static_cast<int>(trim_rate)); | 1328 CACHE_UMA(COUNTS, "TrimRate", 0, static_cast<int>(trim_rate)); |
| 1322 | 1329 |
| 1323 int avg_size = data_->header.num_bytes / GetEntryCount(); | 1330 int avg_size = data_->header.num_bytes / GetEntryCount(); |
| 1324 CACHE_UMA(COUNTS, "EntrySize", 0, avg_size); | 1331 CACHE_UMA(COUNTS, "EntrySize", 0, avg_size); |
| 1325 | 1332 |
| 1326 int large_entries_bytes = stats_.GetLargeEntriesSize(); | 1333 int large_entries_bytes = stats_.GetLargeEntriesSize(); |
| 1327 int large_ratio = large_entries_bytes * 100 / data_->header.num_bytes; | 1334 int large_ratio = large_entries_bytes * 100 / data_->header.num_bytes; |
| 1328 CACHE_UMA(PERCENTAGE, "LargeEntriesRatio", 0, large_ratio); | 1335 CACHE_UMA(PERCENTAGE, "LargeEntriesRatio", 0, large_ratio); |
| 1329 | 1336 |
| 1330 stats_.ResetRatios(); | 1337 stats_.ResetRatios(); |
| 1331 stats_.SetCounter(Stats::TRIM_ENTRY, 0); | 1338 stats_.SetCounter(Stats::TRIM_ENTRY, 0); |
| 1332 stats_.SetCounter(Stats::LAST_REPORT_TIMER, 0); | |
| 1333 } | 1339 } |
| 1334 | 1340 |
| 1335 void BackendImpl::UpgradeTo2_1() { | 1341 void BackendImpl::UpgradeTo2_1() { |
| 1336 // 2.1 is basically the same as 2.0, except that new fields are actually | 1342 // 2.1 is basically the same as 2.0, except that new fields are actually |
| 1337 // updated by the new eviction algorithm. | 1343 // updated by the new eviction algorithm. |
| 1338 DCHECK(0x20000 == data_->header.version); | 1344 DCHECK(0x20000 == data_->header.version); |
| 1339 data_->header.version = 0x20001; | 1345 data_->header.version = 0x20001; |
| 1340 data_->header.lru.sizes[Rankings::NO_USE] = data_->header.num_entries; | 1346 data_->header.lru.sizes[Rankings::NO_USE] = data_->header.num_entries; |
| 1341 } | 1347 } |
| 1342 | 1348 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1448 | 1454 |
| 1449 return num_dirty; | 1455 return num_dirty; |
| 1450 } | 1456 } |
| 1451 | 1457 |
| 1452 bool BackendImpl::CheckEntry(EntryImpl* cache_entry) { | 1458 bool BackendImpl::CheckEntry(EntryImpl* cache_entry) { |
| 1453 RankingsNode* rankings = cache_entry->rankings()->Data(); | 1459 RankingsNode* rankings = cache_entry->rankings()->Data(); |
| 1454 return !rankings->pointer; | 1460 return !rankings->pointer; |
| 1455 } | 1461 } |
| 1456 | 1462 |
| 1457 } // namespace disk_cache | 1463 } // namespace disk_cache |
| OLD | NEW |