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

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

Issue 484603006: Add LOCAL_ prefix to non-UMA histogram macros. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 6 years, 3 months 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/block_bitmaps_v3.cc ('k') | net/dns/host_resolver_impl.cc » ('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_files.h" 5 #include "net/disk_cache/blockfile/block_files.h"
6 6
7 #include "base/atomicops.h" 7 #include "base/atomicops.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // than the actual number of used blocks. 94 // than the actual number of used blocks.
95 base::subtle::MemoryBarrier(); 95 base::subtle::MemoryBarrier();
96 header_->allocation_map[current] |= to_add; 96 header_->allocation_map[current] |= to_add;
97 97
98 header_->hints[target - 1] = current; 98 header_->hints[target - 1] = current;
99 header_->empty[target - 1]--; 99 header_->empty[target - 1]--;
100 STRESS_DCHECK(header_->empty[target - 1] >= 0); 100 STRESS_DCHECK(header_->empty[target - 1] >= 0);
101 if (target != size) { 101 if (target != size) {
102 header_->empty[target - size - 1]++; 102 header_->empty[target - size - 1]++;
103 } 103 }
104 HISTOGRAM_TIMES("DiskCache.CreateBlock", TimeTicks::Now() - start); 104 LOCAL_HISTOGRAM_TIMES("DiskCache.CreateBlock", TimeTicks::Now() - start);
105 return true; 105 return true;
106 } 106 }
107 } 107 }
108 108
109 // It is possible to have an undetected corruption (for example when the OS 109 // It is possible to have an undetected corruption (for example when the OS
110 // crashes), fix it here. 110 // crashes), fix it here.
111 LOG(ERROR) << "Failing CreateMapBlock"; 111 LOG(ERROR) << "Failing CreateMapBlock";
112 FixAllocationCounters(); 112 FixAllocationCounters();
113 return false; 113 return false;
114 } 114 }
(...skipping 26 matching lines...) Expand all
141 141
142 if (update_counters) { 142 if (update_counters) {
143 if (bits_at_end) 143 if (bits_at_end)
144 header_->empty[bits_at_end - 1]--; 144 header_->empty[bits_at_end - 1]--;
145 header_->empty[new_type - 1]++; 145 header_->empty[new_type - 1]++;
146 STRESS_DCHECK(header_->empty[bits_at_end - 1] >= 0); 146 STRESS_DCHECK(header_->empty[bits_at_end - 1] >= 0);
147 } 147 }
148 base::subtle::MemoryBarrier(); 148 base::subtle::MemoryBarrier();
149 header_->num_entries--; 149 header_->num_entries--;
150 STRESS_DCHECK(header_->num_entries >= 0); 150 STRESS_DCHECK(header_->num_entries >= 0);
151 HISTOGRAM_TIMES("DiskCache.DeleteBlock", TimeTicks::Now() - start); 151 LOCAL_HISTOGRAM_TIMES("DiskCache.DeleteBlock", TimeTicks::Now() - start);
152 } 152 }
153 153
154 // Note that this is a simplified version of DeleteMapBlock(). 154 // Note that this is a simplified version of DeleteMapBlock().
155 bool BlockHeader::UsedMapBlock(int index, int size) { 155 bool BlockHeader::UsedMapBlock(int index, int size) {
156 if (size < 0 || size > kMaxNumBlocks) 156 if (size < 0 || size > kMaxNumBlocks)
157 return false; 157 return false;
158 158
159 int byte_index = index / 8; 159 int byte_index = index / 8;
160 uint8* byte_map = reinterpret_cast<uint8*>(header_->allocation_map); 160 uint8* byte_map = reinterpret_cast<uint8*>(header_->allocation_map);
161 uint8 map_block = byte_map[byte_index]; 161 uint8 map_block = byte_map[byte_index];
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 if (!file) 559 if (!file)
560 return NULL; 560 return NULL;
561 file_header = BlockHeader(file); 561 file_header = BlockHeader(file);
562 continue; 562 continue;
563 } 563 }
564 564
565 if (!GrowBlockFile(file, file_header.Header())) 565 if (!GrowBlockFile(file, file_header.Header()))
566 return NULL; 566 return NULL;
567 break; 567 break;
568 } 568 }
569 HISTOGRAM_TIMES("DiskCache.GetFileForNewBlock", TimeTicks::Now() - start); 569 LOCAL_HISTOGRAM_TIMES("DiskCache.GetFileForNewBlock",
570 TimeTicks::Now() - start);
570 return file; 571 return file;
571 } 572 }
572 573
573 MappedFile* BlockFiles::NextFile(MappedFile* file) { 574 MappedFile* BlockFiles::NextFile(MappedFile* file) {
574 ScopedFlush flush(file); 575 ScopedFlush flush(file);
575 BlockFileHeader* header = reinterpret_cast<BlockFileHeader*>(file->buffer()); 576 BlockFileHeader* header = reinterpret_cast<BlockFileHeader*>(file->buffer());
576 int new_file = header->next_file; 577 int new_file = header->next_file;
577 if (!new_file) { 578 if (!new_file) {
578 // RANKINGS is not reported as a type for small entries, but we may be 579 // RANKINGS is not reported as a type for small entries, but we may be
579 // extending the rankings block file. 580 // extending the rankings block file.
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 } 722 }
722 723
723 base::FilePath BlockFiles::Name(int index) { 724 base::FilePath BlockFiles::Name(int index) {
724 // The file format allows for 256 files. 725 // The file format allows for 256 files.
725 DCHECK(index < 256 && index >= 0); 726 DCHECK(index < 256 && index >= 0);
726 std::string tmp = base::StringPrintf("%s%d", kBlockName, index); 727 std::string tmp = base::StringPrintf("%s%d", kBlockName, index);
727 return path_.AppendASCII(tmp); 728 return path_.AppendASCII(tmp);
728 } 729 }
729 730
730 } // namespace disk_cache 731 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/blockfile/block_bitmaps_v3.cc ('k') | net/dns/host_resolver_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698