Bug 783551 - Get tooltool running on the b2g on OS X builds. r=respindola
[gecko.git] / netwerk / cache / nsCacheSession.h
blob447765f0b7fdc4f4f040ba9ec50db617d8b8a3a3
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_
10 #include "nspr.h"
11 #include "nsError.h"
12 #include "nsCOMPtr.h"
13 #include "nsICacheSession.h"
14 #include "nsIFile.h"
15 #include "nsString.h"
17 class nsCacheSession : public nsICacheSession
19 public:
20 NS_DECL_ISUPPORTS
21 NS_DECL_NSICACHESESSION
23 nsCacheSession(const char * clientID, nsCacheStoragePolicy storagePolicy, bool streamBased);
24 virtual ~nsCacheSession();
26 nsCString * ClientID() { return &mClientID; }
28 enum SessionInfo {
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
55 mInfo |= policy;
58 nsIFile* ProfileDir() { return mProfileDir; }
60 private:
61 nsCString mClientID;
62 PRUint32 mInfo;
63 nsCOMPtr<nsIFile> mProfileDir;
66 #endif // _nsCacheSession_h_