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/. */
7 #ifndef _nsCacheSession_h_
8 #define _nsCacheSession_h_
13 #include "nsICacheSession.h"
17 class nsCacheSession
: public nsICacheSession
21 NS_DECL_NSICACHESESSION
23 nsCacheSession(const char * clientID
, nsCacheStoragePolicy storagePolicy
, bool streamBased
);
24 virtual ~nsCacheSession();
26 nsCString
* ClientID() { return &mClientID
; }
29 eStoragePolicyMask
= 0x000000FF,
30 eStreamBasedMask
= 0x00000100,
31 eDoomEntriesIfExpiredMask
= 0x00001000,
32 ePrivateMask
= 0x00010000
35 void MarkStreamBased() { mInfo
|= eStreamBasedMask
; }
36 void ClearStreamBased() { mInfo
&= ~eStreamBasedMask
; }
37 bool IsStreamBased() { return (mInfo
& eStreamBasedMask
) != 0; }
39 void MarkDoomEntriesIfExpired() { mInfo
|= eDoomEntriesIfExpiredMask
; }
40 void ClearDoomEntriesIfExpired() { mInfo
&= ~eDoomEntriesIfExpiredMask
; }
41 bool WillDoomEntriesIfExpired() { return (0 != (mInfo
& eDoomEntriesIfExpiredMask
)); }
43 void MarkPrivate() { mInfo
|= ePrivateMask
; }
44 void MarkPublic() { mInfo
&= ~ePrivateMask
; }
45 bool IsPrivate() { return (mInfo
& ePrivateMask
) != 0; }
46 nsCacheStoragePolicy
StoragePolicy()
48 return (nsCacheStoragePolicy
)(mInfo
& eStoragePolicyMask
);
51 void SetStoragePolicy(nsCacheStoragePolicy policy
)
53 NS_ASSERTION(policy
<= 0xFF, "too many bits in nsCacheStoragePolicy");
54 mInfo
&= ~eStoragePolicyMask
; // clear storage policy bits
58 nsIFile
* ProfileDir() { return mProfileDir
; }
63 nsCOMPtr
<nsIFile
> mProfileDir
;
66 #endif // _nsCacheSession_h_