| 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_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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |