| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/index_table_v3.h" | 5 #include "net/disk_cache/blockfile/index_table_v3.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 void IndexTable::OnBackupTimer() { | 779 void IndexTable::OnBackupTimer() { |
| 780 if (!modified_) | 780 if (!modified_) |
| 781 return; | 781 return; |
| 782 | 782 |
| 783 int num_words = (header_->table_len + 31) / 32; | 783 int num_words = (header_->table_len + 31) / 32; |
| 784 int num_bytes = num_words * 4 + static_cast<int>(sizeof(*header_)); | 784 int num_bytes = num_words * 4 + static_cast<int>(sizeof(*header_)); |
| 785 scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(num_bytes)); | 785 scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(num_bytes)); |
| 786 memcpy(buffer->data(), header_, sizeof(*header_)); | 786 memcpy(buffer->data(), header_, sizeof(*header_)); |
| 787 memcpy(buffer->data() + sizeof(*header_), backup_bitmap_storage_.get(), | 787 memcpy(buffer->data() + sizeof(*header_), backup_bitmap_storage_.get(), |
| 788 num_words * 4); | 788 num_words * 4); |
| 789 backend_->SaveIndex(buffer, num_bytes); | 789 backend_->SaveIndex(buffer.get(), num_bytes); |
| 790 modified_ = false; | 790 modified_ = false; |
| 791 } | 791 } |
| 792 | 792 |
| 793 // ----------------------------------------------------------------------- | 793 // ----------------------------------------------------------------------- |
| 794 | 794 |
| 795 EntryCell IndexTable::FindEntryCellImpl(uint32 hash, Addr address, | 795 EntryCell IndexTable::FindEntryCellImpl(uint32 hash, Addr address, |
| 796 bool allow_deleted) { | 796 bool allow_deleted) { |
| 797 int bucket_num = static_cast<int>(hash & mask_); | 797 int bucket_num = static_cast<int>(hash & mask_); |
| 798 IndexBucket* bucket = &main_table_[bucket_num]; | 798 IndexBucket* bucket = &main_table_[bucket_num]; |
| 799 do { | 799 do { |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1140 bool IndexTable::MisplacedHash(const IndexCell& cell, uint32 hash) { | 1140 bool IndexTable::MisplacedHash(const IndexCell& cell, uint32 hash) { |
| 1141 if (!extra_bits_) | 1141 if (!extra_bits_) |
| 1142 return false; | 1142 return false; |
| 1143 | 1143 |
| 1144 uint32 mask = (1 << extra_bits_) - 1; | 1144 uint32 mask = (1 << extra_bits_) - 1; |
| 1145 hash = small_table_ ? hash >> kSmallTableHashShift : hash >> kHashShift; | 1145 hash = small_table_ ? hash >> kSmallTableHashShift : hash >> kHashShift; |
| 1146 return (GetHashValue(cell) & mask) != (hash & mask); | 1146 return (GetHashValue(cell) & mask) != (hash & mask); |
| 1147 } | 1147 } |
| 1148 | 1148 |
| 1149 } // namespace disk_cache | 1149 } // namespace disk_cache |
| OLD | NEW |