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
3 // found in the LICENSE file.
5 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_UTIL_H_
6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_UTIL_H_
10 #include "base/basictypes.h"
11 #include "net/base/net_export.h"
18 namespace disk_cache
{
20 namespace simple_util
{
22 NET_EXPORT_PRIVATE
std::string
ConvertEntryHashKeyToHexString(uint64 hash_key
);
24 // |key| is the regular cache key, such as an URL.
25 // Returns the Hex ascii representation of the uint64 hash_key.
26 NET_EXPORT_PRIVATE
std::string
GetEntryHashKeyAsHexString(
27 const std::string
& key
);
29 // |key| is the regular HTTP Cache key, which is a URL.
30 // Returns the hash of the key as uint64.
31 NET_EXPORT_PRIVATE uint64
GetEntryHashKey(const std::string
& key
);
33 // Parses the |hash_key| string into a uint64 buffer.
34 // |hash_key| string must be of the form: FFFFFFFFFFFFFFFF .
35 NET_EXPORT_PRIVATE
bool GetEntryHashKeyFromHexString(
36 const std::string
& hash_key
,
37 uint64
* hash_key_out
);
39 // Given a |key| for a (potential) entry in the simple backend and the |index|
40 // of a stream on that entry, returns the filename in which that stream would be
42 NET_EXPORT_PRIVATE
std::string
GetFilenameFromKeyAndIndex(
43 const std::string
& key
,
46 // Same as |GetFilenameFromKeyAndIndex| above, but using a hex string.
47 std::string
GetFilenameFromEntryHashAndIndex(uint64 entry_hash
, int index
);
49 // Given the size of a file holding a stream in the simple backend and the key
50 // to an entry, returns the number of bytes in the stream.
51 NET_EXPORT_PRIVATE int32
GetDataSizeFromKeyAndFileSize(const std::string
& key
,
54 // Given the size of a stream in the simple backend and the key to an entry,
55 // returns the number of bytes in the file.
56 NET_EXPORT_PRIVATE int64
GetFileSizeFromKeyAndDataSize(const std::string
& key
,
59 // Given the key to an entry, and an offset into a stream on that entry, returns
60 // the file offset corresponding to |data_offset|.
61 NET_EXPORT_PRIVATE int64
GetFileOffsetFromKeyAndDataOffset(
62 const std::string
& key
,
65 // Fills |out_time| with the time the file last modified time.
66 // TODO(gavinp): Remove this function.
67 NET_EXPORT_PRIVATE
bool GetMTime(const base::FilePath
& path
,
68 base::Time
* out_mtime
);
69 } // namespace simple_backend
71 } // namespace disk_cache
73 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_UTIL_H_