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

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

Issue 826973002: replace COMPILE_ASSERT with static_assert in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: apply fixups Created 5 years, 11 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/backend_impl_v3.cc ('k') | net/disk_cache/blockfile/disk_format.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_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 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 } 541 }
542 542
543 FileLock lock(header); 543 FileLock lock(header);
544 header->empty[3] = (new_size - header->max_entries) / 4; // 4 blocks entries 544 header->empty[3] = (new_size - header->max_entries) / 4; // 4 blocks entries
545 header->max_entries = new_size; 545 header->max_entries = new_size;
546 546
547 return true; 547 return true;
548 } 548 }
549 549
550 MappedFile* BlockFiles::FileForNewBlock(FileType block_type, int block_count) { 550 MappedFile* BlockFiles::FileForNewBlock(FileType block_type, int block_count) {
551 COMPILE_ASSERT(RANKINGS == 1, invalid_file_type); 551 static_assert(RANKINGS == 1, "invalid file type");
552 MappedFile* file = block_files_[block_type - 1]; 552 MappedFile* file = block_files_[block_type - 1];
553 BlockHeader file_header(file); 553 BlockHeader file_header(file);
554 554
555 TimeTicks start = TimeTicks::Now(); 555 TimeTicks start = TimeTicks::Now();
556 while (file_header.NeedToGrowBlockFile(block_count)) { 556 while (file_header.NeedToGrowBlockFile(block_count)) {
557 if (kMaxBlocks == file_header.Header()->max_entries) { 557 if (kMaxBlocks == file_header.Header()->max_entries) {
558 file = NextFile(file); 558 file = NextFile(file);
559 if (!file) 559 if (!file)
560 return NULL; 560 return NULL;
561 file_header = BlockHeader(file); 561 file_header = BlockHeader(file);
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 } 722 }
723 723
724 base::FilePath BlockFiles::Name(int index) { 724 base::FilePath BlockFiles::Name(int index) {
725 // The file format allows for 256 files. 725 // The file format allows for 256 files.
726 DCHECK(index < 256 && index >= 0); 726 DCHECK(index < 256 && index >= 0);
727 std::string tmp = base::StringPrintf("%s%d", kBlockName, index); 727 std::string tmp = base::StringPrintf("%s%d", kBlockName, index);
728 return path_.AppendASCII(tmp); 728 return path_.AppendASCII(tmp);
729 } 729 }
730 730
731 } // namespace disk_cache 731 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/blockfile/backend_impl_v3.cc ('k') | net/disk_cache/blockfile/disk_format.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698