| 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/entry_impl.h" | 5 #include "net/disk_cache/entry_impl.h" |
| 6 | 6 |
| 7 #include "base/hash.h" | 7 #include "base/hash.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1174 if (!backend_) | 1174 if (!backend_) |
| 1175 return false; | 1175 return false; |
| 1176 | 1176 |
| 1177 FileType file_type = Addr::RequiredFileType(size); | 1177 FileType file_type = Addr::RequiredFileType(size); |
| 1178 if (EXTERNAL == file_type) { | 1178 if (EXTERNAL == file_type) { |
| 1179 if (size > backend_->MaxFileSize()) | 1179 if (size > backend_->MaxFileSize()) |
| 1180 return false; | 1180 return false; |
| 1181 if (!backend_->CreateExternalFile(address)) | 1181 if (!backend_->CreateExternalFile(address)) |
| 1182 return false; | 1182 return false; |
| 1183 } else { | 1183 } else { |
| 1184 int num_blocks = (size + Addr::BlockSizeForFileType(file_type) - 1) / | 1184 int num_blocks = Addr::RequiredBlocks(size, file_type); |
| 1185 Addr::BlockSizeForFileType(file_type); | |
| 1186 | 1185 |
| 1187 if (!backend_->CreateBlock(file_type, num_blocks, address)) | 1186 if (!backend_->CreateBlock(file_type, num_blocks, address)) |
| 1188 return false; | 1187 return false; |
| 1189 } | 1188 } |
| 1190 return true; | 1189 return true; |
| 1191 } | 1190 } |
| 1192 | 1191 |
| 1193 // Note that this method may end up modifying a block file so upon return the | 1192 // Note that this method may end up modifying a block file so upon return the |
| 1194 // involved block will be free, and could be reused for something else. If there | 1193 // involved block will be free, and could be reused for something else. If there |
| 1195 // is a crash after that point (and maybe before returning to the caller), the | 1194 // is a crash after that point (and maybe before returning to the caller), the |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1541 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this), | 1540 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this), |
| 1542 entry_.address().value(), node_.address().value()); | 1541 entry_.address().value(), node_.address().value()); |
| 1543 | 1542 |
| 1544 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0], | 1543 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0], |
| 1545 entry_.Data()->data_addr[1], entry_.Data()->long_key); | 1544 entry_.Data()->data_addr[1], entry_.Data()->long_key); |
| 1546 | 1545 |
| 1547 Trace(" doomed: %d 0x%x", doomed_, dirty); | 1546 Trace(" doomed: %d 0x%x", doomed_, dirty); |
| 1548 } | 1547 } |
| 1549 | 1548 |
| 1550 } // namespace disk_cache | 1549 } // namespace disk_cache |
| OLD | NEW |