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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 const std::string& hash_key, | 31 const std::string& hash_key, |
32 uint64* hash_key_out); | 32 uint64* hash_key_out); |
33 | 33 |
34 // Given a |key| for a (potential) entry in the simple backend and the |index| | 34 // Given a |key| for a (potential) entry in the simple backend and the |index| |
35 // of a stream on that entry, returns the filename in which that stream would be | 35 // of a stream on that entry, returns the filename in which that stream would be |
36 // stored. | 36 // stored. |
37 NET_EXPORT_PRIVATE std::string GetFilenameFromKeyAndIndex( | 37 NET_EXPORT_PRIVATE std::string GetFilenameFromKeyAndIndex( |
38 const std::string& key, | 38 const std::string& key, |
39 int index); | 39 int index); |
40 | 40 |
41 // Given the size of a file holding a stream in the simple backend and the size | 41 // Same as |GetFilenameFromKeyAndIndex| above, but using a hex string. |
42 // of the key to an entry, returns the number of bytes in the stream. | 42 std::string GetFilenameFromHexStringAndIndex(const std::string& hex_key, |
| 43 int index); |
| 44 |
| 45 // Given the size of a file holding a stream in the simple backend and the key |
| 46 // to an entry, returns the number of bytes in the stream. |
43 int32 GetDataSizeFromKeyAndFileSize(const std::string& key, | 47 int32 GetDataSizeFromKeyAndFileSize(const std::string& key, |
44 int64 file_size); | 48 int64 file_size); |
45 | 49 |
46 // Given the size of a stream in the simple backend and the size of the key to | 50 // Given the size of a stream in the simple backend and the key to an entry, |
47 // an entry, returns the number of bytes in the file. | 51 // returns the number of bytes in the file. |
48 int64 GetFileSizeFromKeyAndDataSize(const std::string& key, | 52 int64 GetFileSizeFromKeyAndDataSize(const std::string& key, |
49 int32 data_size); | 53 int32 data_size); |
50 | 54 |
51 // Given the size of a key to an entry, and an offset into a stream on that | 55 // Given the key to an entry, and an offset into a stream on that entry, returns |
52 // entry, returns the file offset corresponding to |data_offset|. | 56 // the file offset corresponding to |data_offset|. |
53 int64 GetFileOffsetFromKeyAndDataOffset(const std::string& key, | 57 int64 GetFileOffsetFromKeyAndDataOffset(const std::string& key, |
54 int data_offset); | 58 int data_offset); |
55 | 59 |
56 } // namespace simple_backend | 60 } // namespace simple_backend |
57 | 61 |
58 } // namespace disk_cache | 62 } // namespace disk_cache |
59 | 63 |
60 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_UTIL_H_ | 64 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_UTIL_H_ |
OLD | NEW |