1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #ifndef _nsDiskCache_h_
9 #define _nsDiskCache_h_
11 #include "nsCacheEntry.h"
14 #include <winsock.h> // for htonl/ntohl
21 kCurrentVersion
= 0x00010013 // format = 16 bits major version/16 bits minor version
24 enum { kData
, kMetaData
};
26 // Stores the reason why the cache is corrupt.
27 // Note: I'm only listing the enum values explicitly for easy mapping when
28 // looking at telemetry data.
29 enum CorruptCacheInfo
{
31 kInvalidArgPointer
= 1,
33 kOpenCacheMapError
= 3,
34 kBlockFilesShouldNotExist
= 4,
36 kCreateCacheSubdirectories
= 6,
37 kBlockFilesShouldExist
= 7,
38 kHeaderSizeNotRead
= 8,
40 kVersionMismatch
= 10,
41 kRecordsIncomplete
= 11,
42 kHeaderIncomplete
= 12,
43 kNotEnoughToRead
= 13,
44 kEntryCountIncorrect
= 14,
45 kCouldNotGetBlockFileForIndex
= 15,
46 kCouldNotCreateBlockFile
= 16,
47 kBlockFileSizeError
= 17,
48 kBlockFileBitMapWriteError
= 18,
49 kBlockFileSizeLessThanBitMap
= 19,
50 kBlockFileBitMapReadError
= 20,
51 kBlockFileEstimatedSizeError
= 21,
52 kFlushHeaderError
= 22
55 // Parameter initval initializes internal state of hash function. Hash values are different
56 // for the same text when different initval is used. It can be any random number.
58 // It can be used for generating 64-bit hash value:
59 // (PRUint64(Hash(key, initval1)) << 32) | Hash(key, initval2)
61 // It can be also used to hash multiple strings:
62 // h = Hash(string1, 0);
63 // h = Hash(string2, h);
65 static PLDHashNumber
Hash(const char* key
, PLDHashNumber initval
=0);
66 static nsresult
Truncate(PRFileDesc
* fd
, PRUint32 newEOF
);
69 #endif // _nsDiskCache_h_