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/entry_impl.h" | 5 #include "net/disk_cache/blockfile/entry_impl.h" |
6 | 6 |
7 #include "base/hash.h" | 7 #include "base/hash.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.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 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 // backend is disabled. | 769 // backend is disabled. |
770 if (!key_.empty()) | 770 if (!key_.empty()) |
771 return key_; | 771 return key_; |
772 | 772 |
773 Addr address(entry->Data()->long_key); | 773 Addr address(entry->Data()->long_key); |
774 DCHECK(address.is_initialized()); | 774 DCHECK(address.is_initialized()); |
775 size_t offset = 0; | 775 size_t offset = 0; |
776 if (address.is_block_file()) | 776 if (address.is_block_file()) |
777 offset = address.start_block() * address.BlockSize() + kBlockHeaderSize; | 777 offset = address.start_block() * address.BlockSize() + kBlockHeaderSize; |
778 | 778 |
779 COMPILE_ASSERT(kNumStreams == kKeyFileIndex, invalid_key_index); | 779 static_assert(kNumStreams == kKeyFileIndex, "invalid key index"); |
780 File* key_file = const_cast<EntryImpl*>(this)->GetBackingFile(address, | 780 File* key_file = const_cast<EntryImpl*>(this)->GetBackingFile(address, |
781 kKeyFileIndex); | 781 kKeyFileIndex); |
782 if (!key_file) | 782 if (!key_file) |
783 return std::string(); | 783 return std::string(); |
784 | 784 |
785 ++key_len; // We store a trailing \0 on disk that we read back below. | 785 ++key_len; // We store a trailing \0 on disk that we read back below. |
786 if (!offset && key_file->GetLength() != static_cast<size_t>(key_len)) | 786 if (!offset && key_file->GetLength() != static_cast<size_t>(key_len)) |
787 return std::string(); | 787 return std::string(); |
788 | 788 |
789 if (!key_file->Read(WriteInto(&key_, key_len), key_len, offset)) | 789 if (!key_file->Read(WriteInto(&key_, key_len), key_len, offset)) |
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1545 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this), | 1545 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this), |
1546 entry_.address().value(), node_.address().value()); | 1546 entry_.address().value(), node_.address().value()); |
1547 | 1547 |
1548 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0], | 1548 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0], |
1549 entry_.Data()->data_addr[1], entry_.Data()->long_key); | 1549 entry_.Data()->data_addr[1], entry_.Data()->long_key); |
1550 | 1550 |
1551 Trace(" doomed: %d 0x%x", doomed_, dirty); | 1551 Trace(" doomed: %d 0x%x", doomed_, dirty); |
1552 } | 1552 } |
1553 | 1553 |
1554 } // namespace disk_cache | 1554 } // namespace disk_cache |
OLD | NEW |