diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /netwerk/cache/nsDiskCache.h | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'netwerk/cache/nsDiskCache.h')
-rw-r--r-- | netwerk/cache/nsDiskCache.h | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/netwerk/cache/nsDiskCache.h b/netwerk/cache/nsDiskCache.h new file mode 100644 index 0000000000..e01860b7bf --- /dev/null +++ b/netwerk/cache/nsDiskCache.h @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _nsDiskCache_h_ +#define _nsDiskCache_h_ + +#include "nsCacheEntry.h" + +#ifdef XP_WIN +# include <winsock.h> // for htonl/ntohl +#endif + +class nsDiskCache { + public: + enum { + kCurrentVersion = + 0x00010013 // format = 16 bits major version/16 bits minor version + }; + + enum { kData, kMetaData }; + + // Stores the reason why the cache is corrupt. + // Note: I'm only listing the enum values explicitly for easy mapping when + // looking at telemetry data. + enum CorruptCacheInfo { + kNotCorrupt = 0, + kInvalidArgPointer = 1, + kUnexpectedError = 2, + kOpenCacheMapError = 3, + kBlockFilesShouldNotExist = 4, + kOutOfMemory = 5, + kCreateCacheSubdirectories = 6, + kBlockFilesShouldExist = 7, + kHeaderSizeNotRead = 8, + kHeaderIsDirty = 9, + kVersionMismatch = 10, + kRecordsIncomplete = 11, + kHeaderIncomplete = 12, + kNotEnoughToRead = 13, + kEntryCountIncorrect = 14, + kCouldNotGetBlockFileForIndex = 15, + kCouldNotCreateBlockFile = 16, + kBlockFileSizeError = 17, + kBlockFileBitMapWriteError = 18, + kBlockFileSizeLessThanBitMap = 19, + kBlockFileBitMapReadError = 20, + kBlockFileEstimatedSizeError = 21, + kFlushHeaderError = 22, + kCacheCleanFilePathError = 23, + kCacheCleanOpenFileError = 24, + kCacheCleanTimerError = 25 + }; + + // Parameter initval initializes internal state of hash function. Hash values + // are different for the same text when different initval is used. It can be + // any random number. + // + // It can be used for generating 64-bit hash value: + // (uint64_t(Hash(key, initval1)) << 32) | Hash(key, initval2) + // + // It can be also used to hash multiple strings: + // h = Hash(string1, 0); + // h = Hash(string2, h); + // ... + static PLDHashNumber Hash(const char* key, PLDHashNumber initval = 0); + static nsresult Truncate(PRFileDesc* fd, uint32_t newEOF); +}; + +#endif // _nsDiskCache_h_ |