Bug 783551 - Get tooltool running on the b2g on OS X builds. r=respindola
[gecko.git] / netwerk / cache / nsDiskCache.h
blob319b6b51ee3a24d3545d0aacdb97f85b838dafc0
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"
13 #ifdef XP_WIN
14 #include <winsock.h> // for htonl/ntohl
15 #endif
18 class nsDiskCache {
19 public:
20 enum {
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 {
30 kNotCorrupt = 0,
31 kInvalidArgPointer = 1,
32 kUnexpectedError = 2,
33 kOpenCacheMapError = 3,
34 kBlockFilesShouldNotExist = 4,
35 kOutOfMemory = 5,
36 kCreateCacheSubdirectories = 6,
37 kBlockFilesShouldExist = 7,
38 kHeaderSizeNotRead = 8,
39 kHeaderIsDirty = 9,
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.
57 //
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);
64 // ...
65 static PLDHashNumber Hash(const char* key, PLDHashNumber initval=0);
66 static nsresult Truncate(PRFileDesc * fd, PRUint32 newEOF);
69 #endif // _nsDiskCache_h_