OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/simple/simple_synchronous_entry.h" | 5 #include "net/disk_cache/simple/simple_synchronous_entry.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cstring> | 8 #include <cstring> |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 base::StringPrintf("_%1d", index); | 44 base::StringPrintf("_%1d", index); |
45 } | 45 } |
46 | 46 |
47 int32 DataSizeFromKeyAndFileSize(size_t key_size, int64 file_size) { | 47 int32 DataSizeFromKeyAndFileSize(size_t key_size, int64 file_size) { |
48 int64 data_size = file_size - key_size - sizeof(disk_cache::SimpleFileHeader); | 48 int64 data_size = file_size - key_size - sizeof(disk_cache::SimpleFileHeader); |
49 DCHECK_GE(implicit_cast<int64>(std::numeric_limits<int32>::max()), data_size); | 49 DCHECK_GE(implicit_cast<int64>(std::numeric_limits<int32>::max()), data_size); |
50 return data_size; | 50 return data_size; |
51 } | 51 } |
52 | 52 |
53 int64 FileOffsetFromDataOffset(size_t key_size, int data_offset) { | 53 int64 FileOffsetFromDataOffset(size_t key_size, int data_offset) { |
54 const int64 headers_size = sizeof(disk_cache::SimpleFileHeader) + | 54 const int64 headers_size = sizeof(disk_cache::SimpleFileHeader) + key_size; |
55 key_size; | |
56 return headers_size + data_offset; | 55 return headers_size + data_offset; |
57 } | 56 } |
58 | 57 |
59 } // namespace | 58 } // namespace |
60 | 59 |
61 namespace disk_cache { | 60 namespace disk_cache { |
62 | 61 |
63 // static | 62 // static |
64 void SimpleSynchronousEntry::OpenEntry( | 63 void SimpleSynchronousEntry::OpenEntry( |
65 const FilePath& path, | 64 const FilePath& path, |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 // TODO(gavinp): Clean up created files. | 292 // TODO(gavinp): Clean up created files. |
294 DLOG(WARNING) << "Could not write keys to new cache entry."; | 293 DLOG(WARNING) << "Could not write keys to new cache entry."; |
295 return false; | 294 return false; |
296 } | 295 } |
297 } | 296 } |
298 initialized_ = true; | 297 initialized_ = true; |
299 return true; | 298 return true; |
300 } | 299 } |
301 | 300 |
302 } // namespace disk_cache | 301 } // namespace disk_cache |
OLD | NEW |