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