netwerk/cache/nsCacheSession.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/cache/nsCacheSession.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,66 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.5 + *
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef _nsCacheSession_h_
    1.11 +#define _nsCacheSession_h_
    1.12 +
    1.13 +#include "nspr.h"
    1.14 +#include "nsError.h"
    1.15 +#include "nsCOMPtr.h"
    1.16 +#include "nsICacheSession.h"
    1.17 +#include "nsIFile.h"
    1.18 +#include "nsString.h"
    1.19 +
    1.20 +class nsCacheSession : public nsICacheSession
    1.21 +{
    1.22 +public:
    1.23 +    NS_DECL_ISUPPORTS
    1.24 +    NS_DECL_NSICACHESESSION
    1.25 +    
    1.26 +    nsCacheSession(const char * clientID, nsCacheStoragePolicy storagePolicy, bool streamBased);
    1.27 +    virtual ~nsCacheSession();
    1.28 +    
    1.29 +    nsCString *           ClientID()      { return &mClientID; }
    1.30 +
    1.31 +    enum SessionInfo {
    1.32 +        eStoragePolicyMask        = 0x000000FF,
    1.33 +        eStreamBasedMask          = 0x00000100,
    1.34 +        eDoomEntriesIfExpiredMask = 0x00001000,
    1.35 +        ePrivateMask              = 0x00010000
    1.36 +    };
    1.37 +
    1.38 +    void   MarkStreamBased()  { mInfo |=  eStreamBasedMask; }
    1.39 +    void   ClearStreamBased() { mInfo &= ~eStreamBasedMask; }
    1.40 +    bool IsStreamBased()    { return (mInfo & eStreamBasedMask) != 0; }
    1.41 +
    1.42 +    void   MarkDoomEntriesIfExpired()  { mInfo |=  eDoomEntriesIfExpiredMask; }
    1.43 +    void   ClearDoomEntriesIfExpired() { mInfo &= ~eDoomEntriesIfExpiredMask; }
    1.44 +    bool WillDoomEntriesIfExpired()  { return (0 != (mInfo & eDoomEntriesIfExpiredMask)); }
    1.45 +
    1.46 +    void   MarkPrivate() { mInfo |= ePrivateMask; }
    1.47 +    void   MarkPublic() { mInfo &= ~ePrivateMask; }
    1.48 +    bool IsPrivate() { return (mInfo & ePrivateMask) != 0; }
    1.49 +    nsCacheStoragePolicy  StoragePolicy()
    1.50 +    {
    1.51 +        return (nsCacheStoragePolicy)(mInfo & eStoragePolicyMask);
    1.52 +    }
    1.53 +
    1.54 +    void SetStoragePolicy(nsCacheStoragePolicy policy)
    1.55 +    {
    1.56 +        NS_ASSERTION(policy <= 0xFF, "too many bits in nsCacheStoragePolicy");
    1.57 +        mInfo &= ~eStoragePolicyMask; // clear storage policy bits
    1.58 +        mInfo |= policy;
    1.59 +    }
    1.60 +
    1.61 +    nsIFile* ProfileDir() { return mProfileDir; }
    1.62 +
    1.63 +private:
    1.64 +    nsCString               mClientID;
    1.65 +    uint32_t                mInfo;
    1.66 +    nsCOMPtr<nsIFile>       mProfileDir;
    1.67 +};
    1.68 +
    1.69 +#endif // _nsCacheSession_h_

mercurial