2001-02-26 14:40:22 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
*
|
2012-05-21 11:12:37 +00:00
|
|
|
* 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/. */
|
2001-02-26 14:40:22 +00:00
|
|
|
|
|
|
|
#ifndef _nsCacheSession_h_
|
|
|
|
#define _nsCacheSession_h_
|
|
|
|
|
|
|
|
#include "nspr.h"
|
|
|
|
#include "nsError.h"
|
2012-06-04 14:12:24 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2001-02-26 14:40:22 +00:00
|
|
|
#include "nsICacheSession.h"
|
2012-06-06 02:08:30 +00:00
|
|
|
#include "nsIFile.h"
|
2001-02-26 14:40:22 +00:00
|
|
|
#include "nsString.h"
|
|
|
|
|
|
|
|
class nsCacheSession : public nsICacheSession
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSICACHESESSION
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
nsCacheSession(const char * clientID, nsCacheStoragePolicy storagePolicy, bool streamBased);
|
2001-02-26 14:40:22 +00:00
|
|
|
virtual ~nsCacheSession();
|
|
|
|
|
|
|
|
nsCString * ClientID() { return &mClientID; }
|
2001-03-08 05:37:00 +00:00
|
|
|
|
|
|
|
enum SessionInfo {
|
|
|
|
eStoragePolicyMask = 0x000000FF,
|
|
|
|
eStreamBasedMask = 0x00000100,
|
2012-05-24 15:31:53 +00:00
|
|
|
eDoomEntriesIfExpiredMask = 0x00001000,
|
|
|
|
ePrivateMask = 0x00010000
|
2001-03-08 05:37:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void MarkStreamBased() { mInfo |= eStreamBasedMask; }
|
|
|
|
void ClearStreamBased() { mInfo &= ~eStreamBasedMask; }
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsStreamBased() { return (mInfo & eStreamBasedMask) != 0; }
|
2001-03-08 05:37:00 +00:00
|
|
|
|
|
|
|
void MarkDoomEntriesIfExpired() { mInfo |= eDoomEntriesIfExpiredMask; }
|
|
|
|
void ClearDoomEntriesIfExpired() { mInfo &= ~eDoomEntriesIfExpiredMask; }
|
2011-09-29 06:19:26 +00:00
|
|
|
bool WillDoomEntriesIfExpired() { return (0 != (mInfo & eDoomEntriesIfExpiredMask)); }
|
2001-03-08 05:37:00 +00:00
|
|
|
|
2012-05-24 15:31:53 +00:00
|
|
|
void MarkPrivate() { mInfo |= ePrivateMask; }
|
|
|
|
void MarkPublic() { mInfo &= ~ePrivateMask; }
|
|
|
|
bool IsPrivate() { return (mInfo & ePrivateMask) != 0; }
|
2001-03-08 05:37:00 +00:00
|
|
|
nsCacheStoragePolicy StoragePolicy()
|
|
|
|
{
|
|
|
|
return (nsCacheStoragePolicy)(mInfo & eStoragePolicyMask);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetStoragePolicy(nsCacheStoragePolicy policy)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(policy <= 0xFF, "too many bits in nsCacheStoragePolicy");
|
|
|
|
mInfo &= ~eStoragePolicyMask; // clear storage policy bits
|
|
|
|
mInfo |= policy;
|
|
|
|
}
|
2001-02-26 14:40:22 +00:00
|
|
|
|
2012-06-06 02:08:30 +00:00
|
|
|
nsIFile* ProfileDir() { return mProfileDir; }
|
2012-06-04 14:12:24 +00:00
|
|
|
|
2001-02-26 14:40:22 +00:00
|
|
|
private:
|
2001-02-26 15:53:31 +00:00
|
|
|
nsCString mClientID;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mInfo;
|
2012-06-06 02:08:30 +00:00
|
|
|
nsCOMPtr<nsIFile> mProfileDir;
|
2001-02-26 14:40:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _nsCacheSession_h_
|