netwerk/cache/nsCacheSession.h

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

     1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     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_
    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
    18 {
    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
    33     };
    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()
    47     {
    48         return (nsCacheStoragePolicy)(mInfo & eStoragePolicyMask);
    49     }
    51     void SetStoragePolicy(nsCacheStoragePolicy policy)
    52     {
    53         NS_ASSERTION(policy <= 0xFF, "too many bits in nsCacheStoragePolicy");
    54         mInfo &= ~eStoragePolicyMask; // clear storage policy bits
    55         mInfo |= policy;
    56     }
    58     nsIFile* ProfileDir() { return mProfileDir; }
    60 private:
    61     nsCString               mClientID;
    62     uint32_t                mInfo;
    63     nsCOMPtr<nsIFile>       mProfileDir;
    64 };
    66 #endif // _nsCacheSession_h_

mercurial