| 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 | |
| 34 // Given a |key| for a (potential) entry in the simple backend and the |index| | 17 // 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 | 18 // of a stream on that entry, returns the filename in which that stream would be |
| 36 // stored. | 19 // stored. |
| 37 NET_EXPORT_PRIVATE std::string GetFilenameFromKeyAndIndex( | 20 NET_EXPORT_PRIVATE std::string GetFilenameFromKeyAndIndex( |
| 38 const std::string& key, | 21 const std::string& key, |
| 39 int index); | 22 int index); |
| 40 | 23 |
| 41 // Given the size of a file holding a stream in the simple backend and the size | 24 // Given the size of a file holding a stream in the simple backend and the size |
| 42 // of the key to an entry, returns the number of bytes in the stream. | 25 // of the key to an entry, returns the number of bytes in the stream. |
| 43 int32 GetDataSizeFromKeyAndFileSize(const std::string& key, | 26 int32 GetDataSizeFromKeyAndFileSize(const std::string& key, |
| 44 int64 file_size); | 27 int64 file_size); |
| 45 | 28 |
| 46 // Given the size of a stream in the simple backend and the size of the key to | 29 // Given the size of a stream in the simple backend and the size of the key to |
| 47 // an entry, returns the number of bytes in the file. | 30 // an entry, returns the number of bytes in the file. |
| 48 int64 GetFileSizeFromKeyAndDataSize(const std::string& key, | 31 int64 GetFileSizeFromKeyAndDataSize(const std::string& key, |
| 49 int32 data_size); | 32 int32 data_size); |
| 50 | 33 |
| 51 // Given the size of a key to an entry, and an offset into a stream on that | 34 // Given the size of a key to an entry, and an offset into a stream on that |
| 52 // entry, returns the file offset corresponding to |data_offset|. | 35 // entry, returns the file offset corresponding to |data_offset|. |
| 53 int64 GetFileOffsetFromKeyAndDataOffset(const std::string& key, | 36 int64 GetFileOffsetFromKeyAndDataOffset(const std::string& key, |
| 54 int data_offset); | 37 int data_offset); |
| 55 | 38 |
| 56 } // namespace simple_backend | 39 } // namespace simple_backend |
| 57 | 40 |
| 58 } // namespace disk_cache | 41 } // namespace disk_cache |
| 59 | 42 |
| 60 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_UTIL_H_ | 43 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_UTIL_H_ |
| OLD | NEW |