| 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 <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/atomicops.h" | 9 #include "base/atomicops.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 MappedFile* file = GetFile(address); | 425 MappedFile* file = GetFile(address); |
| 426 if (!file) | 426 if (!file) |
| 427 return false; | 427 return false; |
| 428 | 428 |
| 429 BlockHeader header(file); | 429 BlockHeader header(file); |
| 430 bool rv = header.UsedMapBlock(address.start_block(), address.num_blocks()); | 430 bool rv = header.UsedMapBlock(address.start_block(), address.num_blocks()); |
| 431 DCHECK(rv); | 431 DCHECK(rv); |
| 432 | 432 |
| 433 static bool read_contents = false; | 433 static bool read_contents = false; |
| 434 if (read_contents) { | 434 if (read_contents) { |
| 435 scoped_ptr<char[]> buffer; | 435 std::unique_ptr<char[]> buffer; |
| 436 buffer.reset(new char[Addr::BlockSizeForFileType(BLOCK_4K) * 4]); | 436 buffer.reset(new char[Addr::BlockSizeForFileType(BLOCK_4K) * 4]); |
| 437 size_t size = address.BlockSize() * address.num_blocks(); | 437 size_t size = address.BlockSize() * address.num_blocks(); |
| 438 size_t offset = address.start_block() * address.BlockSize() + | 438 size_t offset = address.start_block() * address.BlockSize() + |
| 439 kBlockHeaderSize; | 439 kBlockHeaderSize; |
| 440 bool ok = file->Read(buffer.get(), size, offset); | 440 bool ok = file->Read(buffer.get(), size, offset); |
| 441 DCHECK(ok); | 441 DCHECK(ok); |
| 442 } | 442 } |
| 443 | 443 |
| 444 return rv; | 444 return rv; |
| 445 #endif | 445 #endif |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 } | 724 } |
| 725 | 725 |
| 726 base::FilePath BlockFiles::Name(int index) { | 726 base::FilePath BlockFiles::Name(int index) { |
| 727 // The file format allows for 256 files. | 727 // The file format allows for 256 files. |
| 728 DCHECK(index < 256 && index >= 0); | 728 DCHECK(index < 256 && index >= 0); |
| 729 std::string tmp = base::StringPrintf("%s%d", kBlockName, index); | 729 std::string tmp = base::StringPrintf("%s%d", kBlockName, index); |
| 730 return path_.AppendASCII(tmp); | 730 return path_.AppendASCII(tmp); |
| 731 } | 731 } |
| 732 | 732 |
| 733 } // namespace disk_cache | 733 } // namespace disk_cache |
| OLD | NEW |