1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
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
{
18 virtual ~nsCacheSession();
22 NS_DECL_NSICACHESESSION
24 nsCacheSession(const char* clientID
, nsCacheStoragePolicy storagePolicy
,
27 nsCString
* ClientID() { return &mClientID
; }
30 eStoragePolicyMask
= 0x000000FF,
31 eStreamBasedMask
= 0x00000100,
32 eDoomEntriesIfExpiredMask
= 0x00001000,
33 ePrivateMask
= 0x00010000
36 void MarkStreamBased() { mInfo
|= eStreamBasedMask
; }
37 void ClearStreamBased() { mInfo
&= ~eStreamBasedMask
; }
38 bool IsStreamBased() { return (mInfo
& eStreamBasedMask
) != 0; }
40 void MarkDoomEntriesIfExpired() { mInfo
|= eDoomEntriesIfExpiredMask
; }
41 void ClearDoomEntriesIfExpired() { mInfo
&= ~eDoomEntriesIfExpiredMask
; }
42 bool WillDoomEntriesIfExpired() {
43 return (0 != (mInfo
& eDoomEntriesIfExpiredMask
));
46 void MarkPrivate() { mInfo
|= ePrivateMask
; }
47 void MarkPublic() { mInfo
&= ~ePrivateMask
; }
48 bool IsPrivate() { return (mInfo
& ePrivateMask
) != 0; }
49 nsCacheStoragePolicy
StoragePolicy() {
50 return (nsCacheStoragePolicy
)(mInfo
& eStoragePolicyMask
);
53 void SetStoragePolicy(nsCacheStoragePolicy policy
) {
54 NS_ASSERTION(policy
<= 0xFF, "too many bits in nsCacheStoragePolicy");
55 mInfo
&= ~eStoragePolicyMask
; // clear storage policy bits
59 nsIFile
* ProfileDir() { return mProfileDir
; }
64 nsCOMPtr
<nsIFile
> mProfileDir
;
67 #endif // _nsCacheSession_h_