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" |
11 #include "net/base/net_export.h" | 11 #include "net/base/net_export.h" |
12 | 12 |
13 namespace disk_cache { | 13 namespace disk_cache { |
14 | 14 |
15 namespace simple_util { | 15 namespace simple_util { |
16 | 16 |
| 17 std::string ConvertEntryHashKeyToHexString(uint64 hash_key); |
| 18 |
| 19 // |key| is the regular HTTP Cache key, which is a URL. |
| 20 // Returns the Hex ascii representation of the uint64 hash_key. |
| 21 std::string GetEntryHashKeyAsHexString(const std::string& key); |
| 22 |
| 23 // |key| is the regular HTTP Cache key, which is a URL. |
| 24 // Returns the hash of the key as uint64. |
| 25 uint64 GetEntryHashKey(const std::string& key); |
| 26 |
| 27 // Parses the |hash_key| string into a uint64 buffer. |
| 28 // |hash_key| string must be of the form: FFFFFFFFFFFFFFFF . |
| 29 bool GetEntryHashKeyFromHexString(const std::string& hash_key, |
| 30 uint64* hash_key_out); |
| 31 |
17 // Given a |key| for a (potential) entry in the simple backend and the |index| | 32 // Given a |key| for a (potential) entry in the simple backend and the |index| |
18 // of a stream on that entry, returns the filename in which that stream would be | 33 // of a stream on that entry, returns the filename in which that stream would be |
19 // stored. | 34 // stored. |
20 NET_EXPORT_PRIVATE std::string GetFilenameFromKeyAndIndex( | 35 NET_EXPORT_PRIVATE std::string GetFilenameFromKeyAndIndex( |
21 const std::string& key, | 36 const std::string& key, |
22 int index); | 37 int index); |
23 | 38 |
24 // Given the size of a file holding a stream in the simple backend and the size | 39 // Given the size of a file holding a stream in the simple backend and the size |
25 // of the key to an entry, returns the number of bytes in the stream. | 40 // of the key to an entry, returns the number of bytes in the stream. |
26 int32 GetDataSizeFromKeyAndFileSize(const std::string& key, | 41 int32 GetDataSizeFromKeyAndFileSize(const std::string& key, |
27 int64 file_size); | 42 int64 file_size); |
28 | 43 |
29 // Given the size of a stream in the simple backend and the size of the key to | 44 // Given the size of a stream in the simple backend and the size of the key to |
30 // an entry, returns the number of bytes in the file. | 45 // an entry, returns the number of bytes in the file. |
31 int64 GetFileSizeFromKeyAndDataSize(const std::string& key, | 46 int64 GetFileSizeFromKeyAndDataSize(const std::string& key, |
32 int32 data_size); | 47 int32 data_size); |
33 | 48 |
34 // Given the size of a key to an entry, and an offset into a stream on that | 49 // Given the size of a key to an entry, and an offset into a stream on that |
35 // entry, returns the file offset corresponding to |data_offset|. | 50 // entry, returns the file offset corresponding to |data_offset|. |
36 int64 GetFileOffsetFromKeyAndDataOffset(const std::string& key, | 51 int64 GetFileOffsetFromKeyAndDataOffset(const std::string& key, |
37 int data_offset); | 52 int data_offset); |
38 | 53 |
39 } // namespace simple_backend | 54 } // namespace simple_backend |
40 | 55 |
41 } // namespace disk_cache | 56 } // namespace disk_cache |
42 | 57 |
43 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_UTIL_H_ | 58 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_UTIL_H_ |
OLD | NEW |