Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Public Attributes | Private Attributes
nsCacheSession Class Reference

#include <nsCacheSession.h>

Inheritance diagram for nsCacheSession:
Inheritance graph
[legend]
Collaboration diagram for nsCacheSession:
Collaboration graph
[legend]

List of all members.

Public Types

enum  SessionInfo { eStoragePolicyMask = 0x000000FF, eStreamBasedMask = 0x00000100, eDoomEntriesIfExpiredMask = 0x00001000 }

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSICACHESESSION 
nsCacheSession (const char *clientID, nsCacheStoragePolicy storagePolicy, PRBool streamBased)
virtual ~nsCacheSession ()
nsCStringClientID ()
void MarkStreamBased ()
void ClearStreamBased ()
PRBool IsStreamBased ()
void MarkDoomEntriesIfExpired ()
void ClearDoomEntriesIfExpired ()
PRBool WillDoomEntriesIfExpired ()
nsCacheStoragePolicy StoragePolicy ()
void SetStoragePolicy (nsCacheStoragePolicy policy)
nsICacheEntryDescriptor openCacheEntry (in ACString key, in nsCacheAccessMode accessRequested, in boolean blockingMode)
 A cache session can only give out one descriptor with WRITE access to a given cache entry at a time.
void asyncOpenCacheEntry (in ACString key, in nsCacheAccessMode accessRequested, in nsICacheListener listener)
 Asynchronous cache access.
void evictEntries ()
 Evict all entries for this session's clientID according to its storagePolicy.
PRBool isStorageEnabled ()
 Return whether any of the cache devices implied by the session storage policy are currently enabled for instantiation if they don't already exist.

Public Attributes

attribute PRBool doomEntriesIfExpired
 Expired entries will be doomed or evicted if this attribute is set to true.

Private Attributes

nsCString mClientID
PRUint32 mInfo

Detailed Description

Definition at line 51 of file nsCacheSession.h.


Member Enumeration Documentation

Enumerator:
eStoragePolicyMask 
eStreamBasedMask 
eDoomEntriesIfExpiredMask 

Definition at line 62 of file nsCacheSession.h.

                     {
        eStoragePolicyMask        = 0x000000FF,
        eStreamBasedMask          = 0x00000100,
        eDoomEntriesIfExpiredMask = 0x00001000
    };

Constructor & Destructor Documentation

nsCacheSession::nsCacheSession ( const char *  clientID,
nsCacheStoragePolicy  storagePolicy,
PRBool  streamBased 
)

Definition at line 49 of file nsCacheSession.cpp.

    : mClientID(clientID),
      mInfo(0)
{
  SetStoragePolicy(storagePolicy);

  if (streamBased) MarkStreamBased();
  else SetStoragePolicy(nsICache::STORE_IN_MEMORY);

  MarkDoomEntriesIfExpired();
}

Definition at line 63 of file nsCacheSession.cpp.

{
  /* destructor code */
    // notify service we are going away?
}

Member Function Documentation

void nsICacheSession::asyncOpenCacheEntry ( in ACString  key,
in nsCacheAccessMode  accessRequested,
in nsICacheListener  listener 
) [inherited]

Asynchronous cache access.

Does not block the calling thread. Instead, the listener will be notified when the descriptor is available.

Definition at line 73 of file nsCacheSession.h.

Definition at line 69 of file nsCacheSession.h.

Definition at line 60 of file nsCacheSession.h.

{ return &mClientID; }

Here is the caller graph for this function:

Evict all entries for this session's clientID according to its storagePolicy.

Return whether any of the cache devices implied by the session storage policy are currently enabled for instantiation if they don't already exist.

Definition at line 70 of file nsCacheSession.h.

{ return (mInfo & eStreamBasedMask) != 0; }

Here is the caller graph for this function:

Definition at line 72 of file nsCacheSession.h.

Definition at line 68 of file nsCacheSession.h.

nsICacheEntryDescriptor nsICacheSession::openCacheEntry ( in ACString  key,
in nsCacheAccessMode  accessRequested,
in boolean  blockingMode 
) [inherited]

A cache session can only give out one descriptor with WRITE access to a given cache entry at a time.

Until the client calls MarkValid on its descriptor, other attempts to open the same cache entry will block. Synchronous cache access. This returns a unique descriptor each time it is called, even if the same key is specified. When called by multiple threads for write access, only one writable descriptor will be granted. If 'blockingMode' is set to false, it will return NS_ERROR_CACHE_WAIT_FOR_VALIDATION rather than block when another descriptor has been given WRITE access but hasn't validated the entry yet.

Definition at line 81 of file nsCacheSession.h.

    {
        NS_ASSERTION(policy <= 0xFF, "too many bits in nsCacheStoragePolicy");
        mInfo &= ~eStoragePolicyMask; // clear storage policy bits
        mInfo |= policy;
    }

Definition at line 76 of file nsCacheSession.h.

Here is the caller graph for this function:

Definition at line 74 of file nsCacheSession.h.

Here is the caller graph for this function:


Member Data Documentation

Expired entries will be doomed or evicted if this attribute is set to true.

If false, expired entries will be returned (useful for offline- mode and clients, such as HTTP, that can update the valid lifetime of cached content). This attribute defaults to true.

Definition at line 58 of file nsICacheSession.idl.

Definition at line 89 of file nsCacheSession.h.

Definition at line 90 of file nsCacheSession.h.


The documentation for this class was generated from the following files: