| 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 #include "net/disk_cache/blockfile/block_bitmaps_v3.h" | 5 #include "net/disk_cache/blockfile/block_bitmaps_v3.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "net/disk_cache/blockfile/disk_format_base.h" | 9 #include "net/disk_cache/blockfile/disk_format_base.h" |
| 10 #include "net/disk_cache/blockfile/trace.h" | 10 #include "net/disk_cache/blockfile/trace.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 address.num_blocks()); | 64 address.num_blocks()); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void BlockBitmaps::Clear() { | 67 void BlockBitmaps::Clear() { |
| 68 bitmaps_.clear(); | 68 bitmaps_.clear(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void BlockBitmaps::ReportStats() { | 71 void BlockBitmaps::ReportStats() { |
| 72 int used_blocks[kFirstAdditionalBlockFile]; | 72 int used_blocks[kFirstAdditionalBlockFile]; |
| 73 int load[kFirstAdditionalBlockFile]; | 73 int load[kFirstAdditionalBlockFile]; |
| 74 for (int i = 0; i < kFirstAdditionalBlockFile; i++) { | 74 for (int16 i = 0; i < kFirstAdditionalBlockFile; i++) { |
| 75 GetFileStats(i, &used_blocks[i], &load[i]); | 75 GetFileStats(i, &used_blocks[i], &load[i]); |
| 76 } | 76 } |
| 77 UMA_HISTOGRAM_COUNTS("DiskCache.Blocks_0", used_blocks[0]); | 77 UMA_HISTOGRAM_COUNTS("DiskCache.Blocks_0", used_blocks[0]); |
| 78 UMA_HISTOGRAM_COUNTS("DiskCache.Blocks_1", used_blocks[1]); | 78 UMA_HISTOGRAM_COUNTS("DiskCache.Blocks_1", used_blocks[1]); |
| 79 UMA_HISTOGRAM_COUNTS("DiskCache.Blocks_2", used_blocks[2]); | 79 UMA_HISTOGRAM_COUNTS("DiskCache.Blocks_2", used_blocks[2]); |
| 80 UMA_HISTOGRAM_COUNTS("DiskCache.Blocks_3", used_blocks[3]); | 80 UMA_HISTOGRAM_COUNTS("DiskCache.Blocks_3", used_blocks[3]); |
| 81 | 81 |
| 82 UMA_HISTOGRAM_ENUMERATION("DiskCache.BlockLoad_0", load[0], 101); | 82 UMA_HISTOGRAM_ENUMERATION("DiskCache.BlockLoad_0", load[0], 101); |
| 83 UMA_HISTOGRAM_ENUMERATION("DiskCache.BlockLoad_1", load[1], 101); | 83 UMA_HISTOGRAM_ENUMERATION("DiskCache.BlockLoad_1", load[1], 101); |
| 84 UMA_HISTOGRAM_ENUMERATION("DiskCache.BlockLoad_2", load[2], 101); | 84 UMA_HISTOGRAM_ENUMERATION("DiskCache.BlockLoad_2", load[2], 101); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 97 return false; | 97 return false; |
| 98 | 98 |
| 99 bool rv = bitmaps_[header_num].UsedMapBlock(address.start_block(), | 99 bool rv = bitmaps_[header_num].UsedMapBlock(address.start_block(), |
| 100 address.num_blocks()); | 100 address.num_blocks()); |
| 101 DCHECK(rv); | 101 DCHECK(rv); |
| 102 return rv; | 102 return rv; |
| 103 #endif | 103 #endif |
| 104 } | 104 } |
| 105 | 105 |
| 106 int BlockBitmaps::GetHeaderNumber(Addr address) { | 106 int BlockBitmaps::GetHeaderNumber(Addr address) { |
| 107 DCHECK_GE(bitmaps_.size(), static_cast<size_t>(kFirstAdditionalBlockFileV3)); | 107 DCHECK_GE(bitmaps_.size(), kFirstAdditionalBlockFileV3); |
| 108 DCHECK(address.is_block_file() || !address.is_initialized()); | 108 DCHECK(address.is_block_file() || !address.is_initialized()); |
| 109 if (!address.is_initialized()) | 109 if (!address.is_initialized()) |
| 110 return -1; | 110 return -1; |
| 111 | 111 |
| 112 int file_index = address.FileNumber(); | 112 int file_index = address.FileNumber(); |
| 113 if (static_cast<unsigned int>(file_index) >= bitmaps_.size()) | 113 if (static_cast<unsigned int>(file_index) >= bitmaps_.size()) |
| 114 return -1; | 114 return -1; |
| 115 | 115 |
| 116 return file_index; | 116 return file_index; |
| 117 } | 117 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 *used_count += used; | 170 *used_count += used; |
| 171 | 171 |
| 172 index = bitmaps_[index].NextFileId(); | 172 index = bitmaps_[index].NextFileId(); |
| 173 } while (index); | 173 } while (index); |
| 174 | 174 |
| 175 if (max_blocks) | 175 if (max_blocks) |
| 176 *load = *used_count * 100 / max_blocks; | 176 *load = *used_count * 100 / max_blocks; |
| 177 } | 177 } |
| 178 | 178 |
| 179 } // namespace disk_cache | 179 } // namespace disk_cache |
| OLD | NEW |