OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #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/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/metrics/stats_counters.h" |
12 #include "base/rand_util.h" | 13 #include "base/rand_util.h" |
13 #include "base/string_util.h" | 14 #include "base/string_util.h" |
14 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" |
15 #include "base/sys_info.h" | 16 #include "base/sys_info.h" |
16 #include "base/threading/worker_pool.h" | 17 #include "base/threading/worker_pool.h" |
17 #include "base/threading/thread_restrictions.h" | 18 #include "base/threading/thread_restrictions.h" |
18 #include "base/time.h" | 19 #include "base/time.h" |
19 #include "base/timer.h" | 20 #include "base/timer.h" |
20 #include "net/base/net_errors.h" | 21 #include "net/base/net_errors.h" |
21 #include "net/disk_cache/cache_util.h" | 22 #include "net/disk_cache/cache_util.h" |
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 cache_entry->Release(); | 692 cache_entry->Release(); |
692 stats_.OnEvent(Stats::OPEN_MISS); | 693 stats_.OnEvent(Stats::OPEN_MISS); |
693 return NULL; | 694 return NULL; |
694 } | 695 } |
695 | 696 |
696 eviction_.OnOpenEntry(cache_entry); | 697 eviction_.OnOpenEntry(cache_entry); |
697 entry_count_++; | 698 entry_count_++; |
698 | 699 |
699 CACHE_UMA(AGE_MS, "OpenTime", GetSizeGroup(), start); | 700 CACHE_UMA(AGE_MS, "OpenTime", GetSizeGroup(), start); |
700 stats_.OnEvent(Stats::OPEN_HIT); | 701 stats_.OnEvent(Stats::OPEN_HIT); |
| 702 SIMPLE_STATS_COUNTER("disk_cache.hit"); |
701 return cache_entry; | 703 return cache_entry; |
702 } | 704 } |
703 | 705 |
704 EntryImpl* BackendImpl::CreateEntryImpl(const std::string& key) { | 706 EntryImpl* BackendImpl::CreateEntryImpl(const std::string& key) { |
705 if (disabled_ || key.empty()) | 707 if (disabled_ || key.empty()) |
706 return NULL; | 708 return NULL; |
707 | 709 |
708 TimeTicks start = TimeTicks::Now(); | 710 TimeTicks start = TimeTicks::Now(); |
709 uint32 hash = Hash(key); | 711 uint32 hash = Hash(key); |
710 Trace("Create hash 0x%x", hash); | 712 Trace("Create hash 0x%x", hash); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 block_files_.GetFile(node_address)->Store(cache_entry->rankings()); | 778 block_files_.GetFile(node_address)->Store(cache_entry->rankings()); |
777 | 779 |
778 IncreaseNumEntries(); | 780 IncreaseNumEntries(); |
779 eviction_.OnCreateEntry(cache_entry); | 781 eviction_.OnCreateEntry(cache_entry); |
780 entry_count_++; | 782 entry_count_++; |
781 if (!parent.get()) | 783 if (!parent.get()) |
782 data_->table[hash & mask_] = entry_address.value(); | 784 data_->table[hash & mask_] = entry_address.value(); |
783 | 785 |
784 CACHE_UMA(AGE_MS, "CreateTime", GetSizeGroup(), start); | 786 CACHE_UMA(AGE_MS, "CreateTime", GetSizeGroup(), start); |
785 stats_.OnEvent(Stats::CREATE_HIT); | 787 stats_.OnEvent(Stats::CREATE_HIT); |
| 788 SIMPLE_STATS_COUNTER("disk_cache.miss"); |
786 Trace("create entry hit "); | 789 Trace("create entry hit "); |
787 return cache_entry.release(); | 790 return cache_entry.release(); |
788 } | 791 } |
789 | 792 |
790 EntryImpl* BackendImpl::OpenNextEntryImpl(void** iter) { | 793 EntryImpl* BackendImpl::OpenNextEntryImpl(void** iter) { |
791 return OpenFollowingEntry(true, iter); | 794 return OpenFollowingEntry(true, iter); |
792 } | 795 } |
793 | 796 |
794 EntryImpl* BackendImpl::OpenPrevEntryImpl(void** iter) { | 797 EntryImpl* BackendImpl::OpenPrevEntryImpl(void** iter) { |
795 return OpenFollowingEntry(false, iter); | 798 return OpenFollowingEntry(false, iter); |
(...skipping 1344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2140 if (total_memory > kMaxBuffersSize || total_memory <= 0) | 2143 if (total_memory > kMaxBuffersSize || total_memory <= 0) |
2141 total_memory = kMaxBuffersSize; | 2144 total_memory = kMaxBuffersSize; |
2142 | 2145 |
2143 done = true; | 2146 done = true; |
2144 } | 2147 } |
2145 | 2148 |
2146 return static_cast<int>(total_memory); | 2149 return static_cast<int>(total_memory); |
2147 } | 2150 } |
2148 | 2151 |
2149 } // namespace disk_cache | 2152 } // namespace disk_cache |
OLD | NEW |