Skip to content

Commit

Permalink
Updating cache IDL documentation. This is not part of the mozilla build.
Browse files Browse the repository at this point in the history
  • Loading branch information
darin%netscape.com committed Feb 24, 2001
1 parent cb127e5 commit a19e03e
Show file tree
Hide file tree
Showing 5 changed files with 201 additions and 109 deletions.
143 changes: 83 additions & 60 deletions netwerk/cache/public/nsICache.idl
Original file line number Diff line number Diff line change
Expand Up @@ -23,94 +23,117 @@
* Darin Fisher <[email protected]>
*/



typedef long nsCacheStoragePolicy;
typedef long nsCacheAccessMode;

/**
* nsICache is a namespace for various cache constants. It does not represent
* an actual object.
*/
[scriptable, uuid(ec1c0063-197d-44bb-84ba-7525d50fc937)]
interface nsICache
{
/**
* Cache Access Mode
* Access Modes
*
*
* Mode Requested | Not Cached | Cached
* --------------------------------------------------------------------------
* READ | NS_NOT_IN_CACHE | NS_OK
* | Flags = 0 | Flags = READ
* | No Channel | Channel
* --------------------------------------------------------------------------
* ------------------------------------------------------------------------
* READ | KEY_NOT_FOUND | NS_OK
* | Mode = NONE | Mode = READ
* | No Descriptor | Descriptor
* ------------------------------------------------------------------------
* WRITE | NS_OK | NS_OK (Cache manager
* | Flags = WRITE | Flags = WRITE dooms existing
* | Channel | Channel cache object)
* --------------------------------------------------------------------------
* READ|WRITE | NS_OK | NS_OK
* (1st req.) | Flags = WRITE | Flags = READ|WRITE
* | Channel | Channel
* --------------------------------------------------------------------------
* READ|WRITE | N/A | NS_OK
* (Nth req.) | | Flags = READ
* | | Channel
* --------------------------------------------------------------------------
*
*
* If you think that you might need to modify cached data or meta data, then
* you must open a cache entry with the WRITE flag set. Only one cache
* entry descriptor, per cache entry, will be granted WRITE permission.
*
* Usually, you will set both the READ and WRITE flags in order to first test
* the meta data and informational fields to determine if a write (ie. going
* to the net) may actually be necessary. If you determine that it is not,
* then you would mark the cache entry as valid (using MarkValid) and then
* simply read the data from the cache.
*
* A descriptor granted WRITE access has exclusive access to the cache entry
* up until the point at which it marks it as valid. Once the
* cache entry has been "validated", other descriptors with READ access may be
* opened to the cache entry.
* | Mode = WRITE | Mode = WRITE dooms existing
* | Descriptor | Descriptor cache entry)
* ------------------------------------------------------------------------
* READ_WRITE | NS_OK | NS_OK
* (1st req.) | Mode = WRITE | Mode = READ_WRITE
* | Descriptor | Descriptor
* ------------------------------------------------------------------------
* READ_WRITE | N/A | NS_OK
* (Nth req.) | | Mode = READ
* | | Descriptor
* ------------------------------------------------------------------------
*
* If you make a request for READ|WRITE access to a cache entry, the cache
* service will downgrade your access to READ if there is already a
* cache entry descriptor open with WRITE access.
*
* If you make a request for WRITE access to a cache entry (without the READ
* flag set) and another descriptor with WRITE access is currently
* open, then the existing cache entry will be 'doomed', and you will be given
* a descriptor (with WRITE access only) to a new cache entry.
*
* Access Requested:
*
* READ - I only want to READ, if there isn't an entry just fail
* WRITE - I have something new I want to write into the cache, make me a new
* entry and doom the old one, if any.
* READ_WRITE - I want to READ, but I'm willing to update an existing entry if
* necessary, or create a new one if none exists.
* WRITE - I have something new I want to write into the cache, make
* me a new entry and doom the old one, if any.
* READ_WRITE - I want to READ, but I'm willing to update an existing
* entry if necessary, or create a new one if none exists.
*
*
* Access Granted:
* NO_ACCESS - No descriptor is provided. You get zilch. Nada. Nothing.
* READ - You can READ from this descriptor
* WRITE - You must WRITE to this descriptor because the cache entry was just
* created for you
*
* NONE - No descriptor is provided. You get zilch. Nada. Nothing.
* READ - You can READ from this descriptor.
* WRITE - You must WRITE to this descriptor because the cache entry
* was just created for you.
* READ_WRITE - You can READ the descriptor to determine if it's valid,
* you may WRITE if it needs updating
* you may WRITE if it needs updating.
*
*
* Comments:
*
* If you think that you might need to modify cached data or meta data,
* then you must open a cache entry requesting WRITE access. Only one
* cache entry descriptor, per cache entry, will be granted WRITE access.
*
* Usually, you will request READ_WRITE access in order to first test the
* meta data and informational fields to determine if a write (ie. going
* to the net) may actually be necessary. If you determine that it is
* not, then you would mark the cache entry as valid (using MarkValid) and
* then simply read the data from the cache.
*
* A descriptor granted WRITE access has exclusive access to the cache
* entry up to the point at which it marks it as valid. Once the cache
* entry has been "validated", other descriptors with READ access may be
* opened to the cache entry.
*
* If you make a request for READ_WRITE access to a cache entry, the cache
* service will downgrade your access to READ if there is already a
* cache entry descriptor open with WRITE access.
*
* If you make a request for only WRITE access to a cache entry and another
* descriptor with WRITE access is currently open, then the existing cache
* entry will be 'doomed', and you will be given a descriptor (with WRITE
* access only) to a new cache entry.
*
*/
const nsCacheAccessMode ACCESS_NONE = 0;
const nsCacheAccessMode ACCESS_READ = 1;
const nsCacheAccessMode ACCESS_WRITE = 2;
const nsCacheAccessMode ACCESS_READ_WRITE = 3;
const nsCacheAccessMode ACCESS_NONE = 0;
const nsCacheAccessMode ACCESS_READ = 1;
const nsCacheAccessMode ACCESS_WRITE = 2;
const nsCacheAccessMode ACCESS_READ_WRITE = 3;

/**
* Storage Policy
*
* The storage policy of a cache entry determines the device(s) to which
* it belongs. See nsICacheSession and nsICacheEntryDescriptor for more
* details.
*
* STORE_ANYWHERE - Allows the cache entry to be stored in any device.
* The cache service decides which cache device to use
* based on "some resource management calculation."
* STORE_IN_MEMORY - Requires the cache entry to reside in non-persistent
* storage (ie. typically in system RAM).
* STORE_ON_DISK - Requires the cache entry to reside in persistent
* storage (ie. typically on a system's hard disk).
*/
const nsCacheStoragePolicy STORE_ANYWHERE = 0;
const nsCacheStoragePolicy STORE_IN_MEMORY = 1;
const nsCacheStoragePolicy STORE_ON_DISK = 2;
const nsCacheStoragePolicy STORE_ANYWHERE = 0;
const nsCacheStoragePolicy STORE_IN_MEMORY = 1;
const nsCacheStoragePolicy STORE_ON_DISK = 2;
};



%{C++

/**
* Cache specific nsresult error codes
*/
#define NS_ERROR_CACHE_KEY_NOT_FOUND NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 60)
#define NS_ERROR_CACHE_DATA_IS_STREAM NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 61)
#define NS_ERROR_CACHE_DATA_IS_NOT_STREAM NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 62)
Expand Down
74 changes: 51 additions & 23 deletions netwerk/cache/public/nsICacheEntryDescriptor.idl
Original file line number Diff line number Diff line change
Expand Up @@ -30,53 +30,79 @@
interface nsISimpleEnumerator;
interface nsICacheListener;


[scriptable, uuid(49c1a11d-f5d2-4f09-8262-551e64908ada)]
interface nsICacheEntryDescriptor : nsISupports
{
/**
* attributes from cache entry
* Get the key identifying the cache entry.
*/

readonly attribute string key;
readonly attribute long fetchCount;
readonly attribute PRTime lastFetched;
readonly attribute PRTime lastValidated;
readonly attribute string key;

/**
* Get the number of times the cache entry has been opened.
*/
readonly attribute long fetchCount;

/**
* Get the last time the cache entry was opened.
*/
readonly attribute PRTime lastFetched;

attribute PRTime expirationTime;
/**
* Get the last time the cache entry was marked valid.
*/
readonly attribute PRTime lastValidated;

attribute unsigned long dataSize;
/**
* Get the expiration time of the cache entry.
*/
attribute PRTime expirationTime;

/**
* Find out whether or not the cache entry is stream based.
*/
boolean isStreamBased();

/**
* Indicate whether the cached data is a stream or object.
* Get/set the cache entry data size. This attribute can only be set if
* the cache entry IS NOT stream based.
*/
boolean isStreamBased();
attribute unsigned long dataSize;

/**
* If the cache entry is a stream, a transport can be requested.
* Get a transport to the cache data. This will fail if the cache entry
* IS NOT stream based.
*/
readonly attribute nsITransport transport;
readonly attribute nsITransport transport;

/**
* If the cache entry is not a stream, you can request the non-persistent
* cached object.
* Get/set the cache data element. This will fail if the cache entry
* IS stream based. The cache entry holds a strong reference to this
* object. The object will be released when the cache entry is destroyed.
*/
attribute nsISupports cacheElement;
attribute nsISupports cacheElement;

/**
* Access granted to this descriptor. (see nsICacheService.idl)
* Get the access granted to this descriptor. See nsICache.idl for the
* definitions of the access modes and a thorough description of their
* corresponding meanings.
*/
readonly attribute unsigned long accessGranted;
readonly attribute nsCacheAccessMode accessGranted;

/**
*
* Get/set the storage policy of the cache entry. See nsICache.idl for
* the definitions of the storage policies.
*/
attribute nsCacheStoragePolicy storagePolicy;

/**
* Doom the cache entry this descriptor references in order to slate it for
* removal. Once doomed a cache entry cannot be undoomed.
*
* A descriptor with WRITE access can doom the cache entry and choose to
* fail pending requests. This means that pending requests will not get
* a cache descriptor. This is meant as a tool for clients that wish to
* instruct pending requests to skip the cache.
*/
void doom();
void doomAndFailPendingRequests(in nsresult status);
Expand All @@ -88,11 +114,13 @@ interface nsICacheEntryDescriptor : nsISupports
void markValid();

/**
* Methods for accessing MetaData.
* Methods for accessing meta data. Meta data is a table of key/value
* string pairs. The strings do not have to conform to any particular
* charset, but they must be null terminated.
*/
string getMetaDataElement(in string key);
void setMetadataElement(in string key, in string value);
string getMetaDataElement(in string key);
void setMetadataElement(in string key, in string value);

nsISimpleEnumerator getMetaDataEnumerator(); /* todo */
nsISimpleEnumerator getMetaDataEnumerator(); /* todo */
};

37 changes: 29 additions & 8 deletions netwerk/cache/public/nsICacheService.idl
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,52 @@
* Darin Fisher <[email protected]>
*/


#include "nsISupports.idl"


interface nsISimpleEnumerator;
interface nsICacheListener;
interface nsICacheSession;
interface nsICacheVisitor;


[scriptable, uuid(0ebec4c7-742f-4f27-8e7b-7c8a0cc76348)]
interface nsICacheService : nsISupports
{
/**
* Initialize the cache service.
*/
void init();

/**
* Shutdown the cache service.
*/
void shutdown();

/*
* Create Session
* Create a cache session
*
* A cache session represents a client's access into the cache. The cache
* session is not "owned" by the cache service. Hence, it is possible to
* create duplicate cache sessions. Entries created by a cache session
* are invisible to other cache sessions, unless the cache sessions are
* equivalent.
*
* @param clientID - Specifies the name of the client using the cache.
* @param storagePolicy - Limits the storage policy for all entries
* accessed via the returned session. As a result, devices excluded
* by the storage policy will not be searched when opening entries
* from the returned session.
* @param streamBased - Indicates whether or not the data being cached
* can be represented as a stream. The storagePolicy must be
* consistent with the value of this field. For example, a non-stream-
* based cache entry can only have a storage policy of STORE_IN_MEMORY.
* @return new cache session.
*/
nsICacheSession createSession(in string clientID,
in long storagePolicy,
in boolean streamBased);
nsICacheSession createSession(in string clientID,
in long storagePolicy,
in boolean streamBased);

/*
* methods for implementing about:cache
* Visit entries stored in the cache. Used to implement about:cache.
*/
void visitEntries(in nsICacheVisitor visitor);
};
Loading

0 comments on commit a19e03e

Please sign in to comment.