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 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_UTIL_H_ | 5 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_UTIL_H_ |
6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_UTIL_H_ | 6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_UTIL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 const std::string& key, | 46 const std::string& key, |
47 int file_index); | 47 int file_index); |
48 | 48 |
49 // Same as |GetFilenameFromKeyAndIndex| above, but using a hex string. | 49 // Same as |GetFilenameFromKeyAndIndex| above, but using a hex string. |
50 std::string GetFilenameFromEntryHashAndFileIndex(uint64_t entry_hash, | 50 std::string GetFilenameFromEntryHashAndFileIndex(uint64_t entry_hash, |
51 int file_index); | 51 int file_index); |
52 | 52 |
53 // Given a |key| for an entry, returns the name of the sparse data file. | 53 // Given a |key| for an entry, returns the name of the sparse data file. |
54 std::string GetSparseFilenameFromEntryHash(uint64_t entry_hash); | 54 std::string GetSparseFilenameFromEntryHash(uint64_t entry_hash); |
55 | 55 |
| 56 // Given the size of a key, the size in bytes of the header at the beginning |
| 57 // of a simple cache file. |
| 58 size_t GetHeaderSize(size_t key_length); |
| 59 |
56 // Given the size of a file holding a stream in the simple backend and the key | 60 // Given the size of a file holding a stream in the simple backend and the key |
57 // to an entry, returns the number of bytes in the stream. | 61 // to an entry, returns the number of bytes in the stream. |
58 NET_EXPORT_PRIVATE int32_t GetDataSizeFromKeyAndFileSize(const std::string& key, | 62 NET_EXPORT_PRIVATE int32_t GetDataSizeFromFileSize(size_t key_length, |
59 int64_t file_size); | 63 int64_t file_size); |
60 | 64 |
61 // Given the size of a stream in the simple backend and the key to an entry, | 65 // Given the size of a stream in the simple backend and the key to an entry, |
62 // returns the number of bytes in the file. | 66 // returns the number of bytes in the file. |
63 NET_EXPORT_PRIVATE int64_t GetFileSizeFromKeyAndDataSize(const std::string& key, | 67 NET_EXPORT_PRIVATE int64_t GetFileSizeFromDataSize(size_t key_length, |
64 int32_t data_size); | 68 int32_t data_size); |
65 | 69 |
66 // Given the stream index, returns the number of the file the stream is stored | 70 // Given the stream index, returns the number of the file the stream is stored |
67 // in. | 71 // in. |
68 NET_EXPORT_PRIVATE int GetFileIndexFromStreamIndex(int stream_index); | 72 NET_EXPORT_PRIVATE int GetFileIndexFromStreamIndex(int stream_index); |
69 | 73 |
70 // Fills |out_time| with the time the file last modified time. Unlike the | 74 // Fills |out_time| with the time the file last modified time. Unlike the |
71 // functions in file.h, the time resolution is milliseconds. | 75 // functions in file.h, the time resolution is milliseconds. |
72 NET_EXPORT_PRIVATE bool GetMTime(const base::FilePath& path, | 76 NET_EXPORT_PRIVATE bool GetMTime(const base::FilePath& path, |
73 base::Time* out_mtime); | 77 base::Time* out_mtime); |
74 | 78 |
75 // Deletes a file, insuring POSIX semantics. Provided that all open handles to | 79 // Deletes a file, insuring POSIX semantics. Provided that all open handles to |
76 // this file were opened with File::FLAG_SHARE_DELETE, it is possible to delete | 80 // this file were opened with File::FLAG_SHARE_DELETE, it is possible to delete |
77 // an open file and continue to use that file. After deleting an open file, it | 81 // an open file and continue to use that file. After deleting an open file, it |
78 // is possible to immediately create a new file with the same name. | 82 // is possible to immediately create a new file with the same name. |
79 NET_EXPORT_PRIVATE bool SimpleCacheDeleteFile(const base::FilePath& path); | 83 NET_EXPORT_PRIVATE bool SimpleCacheDeleteFile(const base::FilePath& path); |
80 | 84 |
81 } // namespace simple_util | 85 } // namespace simple_util |
82 | 86 |
83 } // namespace disk_cache | 87 } // namespace disk_cache |
84 | 88 |
85 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_UTIL_H_ | 89 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_UTIL_H_ |
OLD | NEW |