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 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
759 AddStorageSize(new_size - old_size); | 759 AddStorageSize(new_size - old_size); |
760 | 760 |
761 // Update the usage statistics. | 761 // Update the usage statistics. |
762 stats_.ModifyStorageStats(old_size, new_size); | 762 stats_.ModifyStorageStats(old_size, new_size); |
763 } | 763 } |
764 | 764 |
765 void BackendImpl::TooMuchStorageRequested(int32 size) { | 765 void BackendImpl::TooMuchStorageRequested(int32 size) { |
766 stats_.ModifyStorageStats(0, size); | 766 stats_.ModifyStorageStats(0, size); |
767 } | 767 } |
768 | 768 |
769 std::string BackendImpl::HistogramName(const char* name, int experiment) { | 769 bool BackendImpl::IsLoaded() const { |
770 CACHE_UMA(COUNTS, "PendingIO", GetSizeGroup(), num_pending_io_); | |
771 return num_pending_io_ > 10; | |
772 } | |
773 | |
774 std::string BackendImpl::HistogramName(const char* name, int experiment) const { | |
770 if (!experiment) | 775 if (!experiment) |
771 return StringPrintf("DiskCache.%d.%s", cache_type_, name); | 776 return StringPrintf("DiskCache.%d.%s", cache_type_, name); |
772 return StringPrintf("DiskCache.%d.%s_%d", cache_type_, name, experiment); | 777 return StringPrintf("DiskCache.%d.%s_%d", cache_type_, name, experiment); |
773 } | 778 } |
774 | 779 |
775 int BackendImpl::GetSizeGroup() { | 780 int BackendImpl::GetSizeGroup() const { |
776 if (disabled_) | 781 if (disabled_) |
777 return 0; | 782 return 0; |
778 | 783 |
779 // We want to report times grouped by the current cache size (50 MB groups). | 784 // We want to report times grouped by the current cache size (50 MB groups). |
780 int group = data_->header.num_bytes / (50 * 1024 * 1024); | 785 int group = data_->header.num_bytes / (50 * 1024 * 1024); |
781 if (group > 6) | 786 if (group > 6) |
782 group = 6; // Limit the number of groups, just in case. | 787 group = 6; // Limit the number of groups, just in case. |
783 return group; | 788 return group; |
784 } | 789 } |
785 | 790 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
852 DCHECK(error <= 0); | 857 DCHECK(error <= 0); |
853 CACHE_UMA(CACHE_ERROR, "Error", 0, error * -1); | 858 CACHE_UMA(CACHE_ERROR, "Error", 0, error * -1); |
854 } | 859 } |
855 | 860 |
856 void BackendImpl::OnEvent(Stats::Counters an_event) { | 861 void BackendImpl::OnEvent(Stats::Counters an_event) { |
857 stats_.OnEvent(an_event); | 862 stats_.OnEvent(an_event); |
858 } | 863 } |
859 | 864 |
860 void BackendImpl::OnStatsTimer() { | 865 void BackendImpl::OnStatsTimer() { |
861 stats_.OnEvent(Stats::TIMER); | 866 stats_.OnEvent(Stats::TIMER); |
867 int64 time = stats_.GetCounter(Stats::TIMER); | |
862 int64 current = stats_.GetCounter(Stats::OPEN_ENTRIES); | 868 int64 current = stats_.GetCounter(Stats::OPEN_ENTRIES); |
863 int64 time = stats_.GetCounter(Stats::TIMER); | |
864 | 869 |
865 current = current * (time - 1) + num_refs_; | 870 // OPEN_ENTRIES is a sampled average of the number of open entries, avoiding |
866 current /= time; | 871 // the bias towards 0. |
867 stats_.SetCounter(Stats::OPEN_ENTRIES, current); | 872 if (num_refs_ && (current != num_refs_)) { |
868 stats_.SetCounter(Stats::MAX_ENTRIES, max_refs_); | 873 int64 diff = (num_refs_ - current) / 50; |
874 if (!diff) | |
875 diff = num_refs_ > current ? 1 : -1; | |
876 current = current + diff; | |
877 stats_.SetCounter(Stats::OPEN_ENTRIES, current); | |
878 stats_.SetCounter(Stats::MAX_ENTRIES, max_refs_); | |
879 } | |
880 | |
881 CACHE_UMA(COUNTS, "NumberOfReferences", 0, num_refs_); | |
Nicolas Sylvain
2009/07/09 22:32:21
still lgtm
| |
869 | 882 |
870 if (!data_) | 883 if (!data_) |
871 first_timer_ = false; | 884 first_timer_ = false; |
872 if (first_timer_) { | 885 if (first_timer_) { |
873 first_timer_ = false; | 886 first_timer_ = false; |
874 if (ShouldReportAgain()) | 887 if (ShouldReportAgain()) |
875 ReportStats(); | 888 ReportStats(); |
876 } | 889 } |
877 | 890 |
878 // Save stats to disk at 5 min intervals. | 891 // Save stats to disk at 5 min intervals. |
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1563 | 1576 |
1564 return num_dirty; | 1577 return num_dirty; |
1565 } | 1578 } |
1566 | 1579 |
1567 bool BackendImpl::CheckEntry(EntryImpl* cache_entry) { | 1580 bool BackendImpl::CheckEntry(EntryImpl* cache_entry) { |
1568 RankingsNode* rankings = cache_entry->rankings()->Data(); | 1581 RankingsNode* rankings = cache_entry->rankings()->Data(); |
1569 return !rankings->pointer; | 1582 return !rankings->pointer; |
1570 } | 1583 } |
1571 | 1584 |
1572 } // namespace disk_cache | 1585 } // namespace disk_cache |
OLD | NEW |