| 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_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/histogram.h" | 9 #include "base/histogram.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 // The entry was already evicted. | 354 // The entry was already evicted. |
| 355 cache_entry->Release(); | 355 cache_entry->Release(); |
| 356 stats_.OnEvent(Stats::OPEN_MISS); | 356 stats_.OnEvent(Stats::OPEN_MISS); |
| 357 return false; | 357 return false; |
| 358 } | 358 } |
| 359 | 359 |
| 360 eviction_.OnOpenEntry(cache_entry); | 360 eviction_.OnOpenEntry(cache_entry); |
| 361 DCHECK(entry); | 361 DCHECK(entry); |
| 362 *entry = cache_entry; | 362 *entry = cache_entry; |
| 363 | 363 |
| 364 CACHE_UMA(AGE_MS, "OpenTime", 0, start); | 364 CACHE_UMA(AGE_MS, "OpenTime", GetSizeGroup(), start); |
| 365 stats_.OnEvent(Stats::OPEN_HIT); | 365 stats_.OnEvent(Stats::OPEN_HIT); |
| 366 return true; | 366 return true; |
| 367 } | 367 } |
| 368 | 368 |
| 369 bool BackendImpl::CreateEntry(const std::string& key, Entry** entry) { | 369 bool BackendImpl::CreateEntry(const std::string& key, Entry** entry) { |
| 370 if (disabled_ || key.empty()) | 370 if (disabled_ || key.empty()) |
| 371 return false; | 371 return false; |
| 372 | 372 |
| 373 DCHECK(entry); | 373 DCHECK(entry); |
| 374 *entry = NULL; | 374 *entry = NULL; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 block_files_.GetFile(entry_address)->Store(cache_entry->entry()); | 432 block_files_.GetFile(entry_address)->Store(cache_entry->entry()); |
| 433 block_files_.GetFile(node_address)->Store(cache_entry->rankings()); | 433 block_files_.GetFile(node_address)->Store(cache_entry->rankings()); |
| 434 | 434 |
| 435 IncreaseNumEntries(); | 435 IncreaseNumEntries(); |
| 436 eviction_.OnCreateEntry(cache_entry); | 436 eviction_.OnCreateEntry(cache_entry); |
| 437 if (!parent.get()) | 437 if (!parent.get()) |
| 438 data_->table[hash & mask_] = entry_address.value(); | 438 data_->table[hash & mask_] = entry_address.value(); |
| 439 | 439 |
| 440 cache_entry.swap(reinterpret_cast<EntryImpl**>(entry)); | 440 cache_entry.swap(reinterpret_cast<EntryImpl**>(entry)); |
| 441 | 441 |
| 442 CACHE_UMA(AGE_MS, "CreateTime", 0, start); | 442 CACHE_UMA(AGE_MS, "CreateTime", GetSizeGroup(), start); |
| 443 stats_.OnEvent(Stats::CREATE_HIT); | 443 stats_.OnEvent(Stats::CREATE_HIT); |
| 444 Trace("create entry hit "); | 444 Trace("create entry hit "); |
| 445 return true; | 445 return true; |
| 446 } | 446 } |
| 447 | 447 |
| 448 bool BackendImpl::DoomEntry(const std::string& key) { | 448 bool BackendImpl::DoomEntry(const std::string& key) { |
| 449 if (disabled_) | 449 if (disabled_) |
| 450 return false; | 450 return false; |
| 451 | 451 |
| 452 Entry* entry; | 452 Entry* entry; |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 void BackendImpl::TooMuchStorageRequested(int32 size) { | 743 void BackendImpl::TooMuchStorageRequested(int32 size) { |
| 744 stats_.ModifyStorageStats(0, size); | 744 stats_.ModifyStorageStats(0, size); |
| 745 } | 745 } |
| 746 | 746 |
| 747 std::string BackendImpl::HistogramName(const char* name, int experiment) { | 747 std::string BackendImpl::HistogramName(const char* name, int experiment) { |
| 748 if (!experiment) | 748 if (!experiment) |
| 749 return StringPrintf("DiskCache.%d.%s", cache_type_, name); | 749 return StringPrintf("DiskCache.%d.%s", cache_type_, name); |
| 750 return StringPrintf("DiskCache.%d.%s_%d", cache_type_, name, experiment); | 750 return StringPrintf("DiskCache.%d.%s_%d", cache_type_, name, experiment); |
| 751 } | 751 } |
| 752 | 752 |
| 753 int BackendImpl::GetSizeGroup() { |
| 754 if (disabled_) |
| 755 return 0; |
| 756 |
| 757 // We want to report times grouped by the current cache size (50 MB groups). |
| 758 int group = data_->header.num_bytes / (50 * 1024 * 1024); |
| 759 if (group > 6) |
| 760 group = 6; // Limit the number of groups, just in case. |
| 761 return group; |
| 762 } |
| 763 |
| 753 // We want to remove biases from some histograms so we only send data once per | 764 // We want to remove biases from some histograms so we only send data once per |
| 754 // week. | 765 // week. |
| 755 bool BackendImpl::ShouldReportAgain() { | 766 bool BackendImpl::ShouldReportAgain() { |
| 756 if (uma_report_) | 767 if (uma_report_) |
| 757 return uma_report_ == 2; | 768 return uma_report_ == 2; |
| 758 | 769 |
| 759 uma_report_++; | 770 uma_report_++; |
| 760 int64 last_report = stats_.GetCounter(Stats::LAST_REPORT); | 771 int64 last_report = stats_.GetCounter(Stats::LAST_REPORT); |
| 761 Time last_time = Time::FromInternalValue(last_report); | 772 Time last_time = Time::FromInternalValue(last_report); |
| 762 if (!last_report || (Time::Now() - last_time).InDays() >= 7) { | 773 if (!last_report || (Time::Now() - last_time).InDays() >= 7) { |
| (...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1518 | 1529 |
| 1519 return num_dirty; | 1530 return num_dirty; |
| 1520 } | 1531 } |
| 1521 | 1532 |
| 1522 bool BackendImpl::CheckEntry(EntryImpl* cache_entry) { | 1533 bool BackendImpl::CheckEntry(EntryImpl* cache_entry) { |
| 1523 RankingsNode* rankings = cache_entry->rankings()->Data(); | 1534 RankingsNode* rankings = cache_entry->rankings()->Data(); |
| 1524 return !rankings->pointer; | 1535 return !rankings->pointer; |
| 1525 } | 1536 } |
| 1526 | 1537 |
| 1527 } // namespace disk_cache | 1538 } // namespace disk_cache |
| OLD | NEW |