michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef _nsCacheSession_h_ michael@0: #define _nsCacheSession_h_ michael@0: michael@0: #include "nspr.h" michael@0: #include "nsError.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsICacheSession.h" michael@0: #include "nsIFile.h" michael@0: #include "nsString.h" michael@0: michael@0: class nsCacheSession : public nsICacheSession michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_NSICACHESESSION michael@0: michael@0: nsCacheSession(const char * clientID, nsCacheStoragePolicy storagePolicy, bool streamBased); michael@0: virtual ~nsCacheSession(); michael@0: michael@0: nsCString * ClientID() { return &mClientID; } michael@0: michael@0: enum SessionInfo { michael@0: eStoragePolicyMask = 0x000000FF, michael@0: eStreamBasedMask = 0x00000100, michael@0: eDoomEntriesIfExpiredMask = 0x00001000, michael@0: ePrivateMask = 0x00010000 michael@0: }; michael@0: michael@0: void MarkStreamBased() { mInfo |= eStreamBasedMask; } michael@0: void ClearStreamBased() { mInfo &= ~eStreamBasedMask; } michael@0: bool IsStreamBased() { return (mInfo & eStreamBasedMask) != 0; } michael@0: michael@0: void MarkDoomEntriesIfExpired() { mInfo |= eDoomEntriesIfExpiredMask; } michael@0: void ClearDoomEntriesIfExpired() { mInfo &= ~eDoomEntriesIfExpiredMask; } michael@0: bool WillDoomEntriesIfExpired() { return (0 != (mInfo & eDoomEntriesIfExpiredMask)); } michael@0: michael@0: void MarkPrivate() { mInfo |= ePrivateMask; } michael@0: void MarkPublic() { mInfo &= ~ePrivateMask; } michael@0: bool IsPrivate() { return (mInfo & ePrivateMask) != 0; } michael@0: nsCacheStoragePolicy StoragePolicy() michael@0: { michael@0: return (nsCacheStoragePolicy)(mInfo & eStoragePolicyMask); michael@0: } michael@0: michael@0: void SetStoragePolicy(nsCacheStoragePolicy policy) michael@0: { michael@0: NS_ASSERTION(policy <= 0xFF, "too many bits in nsCacheStoragePolicy"); michael@0: mInfo &= ~eStoragePolicyMask; // clear storage policy bits michael@0: mInfo |= policy; michael@0: } michael@0: michael@0: nsIFile* ProfileDir() { return mProfileDir; } michael@0: michael@0: private: michael@0: nsCString mClientID; michael@0: uint32_t mInfo; michael@0: nsCOMPtr mProfileDir; michael@0: }; michael@0: michael@0: #endif // _nsCacheSession_h_