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