Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: net/disk_cache/blockfile/block_bitmaps_v3.cc

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/disk_cache/blockfile/backend_impl.cc ('k') | net/disk_cache/blockfile/block_files.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « net/disk_cache/blockfile/backend_impl.cc ('k') | net/disk_cache/blockfile/block_files.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698