2001-02-23 23:20:15 +00:00
|
|
|
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
*
|
2012-05-21 11:12:37 +00: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-23 23:20:15 +00:00
|
|
|
|
2001-03-01 01:56:29 +00:00
|
|
|
#include "nsISupports.idl"
|
|
|
|
|
2001-02-23 23:20:15 +00:00
|
|
|
typedef long nsCacheStoragePolicy;
|
|
|
|
typedef long nsCacheAccessMode;
|
|
|
|
|
2001-02-24 01:27:49 +00:00
|
|
|
/**
|
|
|
|
* nsICache is a namespace for various cache constants. It does not represent
|
|
|
|
* an actual object.
|
|
|
|
*/
|
2013-01-03 23:30:48 +00:00
|
|
|
[scriptable, uuid(d6c67f38-b39a-4582-8a48-4c4f8a56dfd0)]
|
2001-02-23 23:20:15 +00:00
|
|
|
interface nsICache
|
|
|
|
{
|
|
|
|
/**
|
2001-02-24 01:27:49 +00:00
|
|
|
* Access Modes
|
2001-02-23 23:20:15 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* Mode Requested | Not Cached | Cached
|
2001-02-24 01:27:49 +00:00
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
* READ | KEY_NOT_FOUND | NS_OK
|
|
|
|
* | Mode = NONE | Mode = READ
|
|
|
|
* | No Descriptor | Descriptor
|
|
|
|
* ------------------------------------------------------------------------
|
2001-03-12 07:09:24 +00:00
|
|
|
* WRITE | NS_OK | NS_OK (Cache service
|
2001-02-24 01:27:49 +00:00
|
|
|
* | 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
|
|
|
|
* ------------------------------------------------------------------------
|
2001-02-23 23:20:15 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* Access Requested:
|
2001-02-24 01:27:49 +00:00
|
|
|
*
|
2001-02-23 23:20:15 +00:00
|
|
|
* READ - I only want to READ, if there isn't an entry just fail
|
2001-02-24 01:27:49 +00:00
|
|
|
* 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.
|
|
|
|
*
|
2001-02-23 23:20:15 +00:00
|
|
|
*
|
|
|
|
* Access Granted:
|
2001-02-24 01:27:49 +00:00
|
|
|
*
|
|
|
|
* 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.
|
2001-02-23 23:20:15 +00:00
|
|
|
* READ_WRITE - You can READ the descriptor to determine if it's valid,
|
2001-02-24 01:27:49 +00:00
|
|
|
* 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.
|
|
|
|
*
|
2001-02-23 23:20:15 +00:00
|
|
|
*/
|
2001-02-24 01:27:49 +00:00
|
|
|
const nsCacheAccessMode ACCESS_NONE = 0;
|
|
|
|
const nsCacheAccessMode ACCESS_READ = 1;
|
|
|
|
const nsCacheAccessMode ACCESS_WRITE = 2;
|
|
|
|
const nsCacheAccessMode ACCESS_READ_WRITE = 3;
|
2001-02-23 23:20:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Storage Policy
|
2001-02-24 01:27:49 +00:00
|
|
|
*
|
|
|
|
* The storage policy of a cache entry determines the device(s) to which
|
|
|
|
* it belongs. See nsICacheSession and nsICacheEntryDescriptor for more
|
|
|
|
* details.
|
|
|
|
*
|
2001-03-07 01:37:42 +00:00
|
|
|
* 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).
|
2007-03-14 01:52:07 +00:00
|
|
|
* STORE_OFFLINE - Requires the cache entry to reside in persistent,
|
|
|
|
* reliable storage for offline use.
|
2001-02-23 23:20:15 +00:00
|
|
|
*/
|
2001-03-12 07:09:24 +00:00
|
|
|
const nsCacheStoragePolicy STORE_ANYWHERE = 0;
|
|
|
|
const nsCacheStoragePolicy STORE_IN_MEMORY = 1;
|
|
|
|
const nsCacheStoragePolicy STORE_ON_DISK = 2;
|
2013-01-03 23:30:48 +00:00
|
|
|
// value 3 was used by STORE_ON_DISK_AS_FILE which was removed
|
2007-03-14 01:52:07 +00:00
|
|
|
const nsCacheStoragePolicy STORE_OFFLINE = 4;
|
2001-02-26 14:27:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* All entries for a cache session are stored as streams of data or
|
|
|
|
* as objects. These constant my be used to specify the type of entries
|
|
|
|
* when calling nsICacheService::CreateSession().
|
|
|
|
*/
|
2001-03-12 07:09:24 +00:00
|
|
|
const long NOT_STREAM_BASED = 0;
|
|
|
|
const long STREAM_BASED = 1;
|
2001-05-09 03:36:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The synchronous OpenCacheEntry() may be blocking or non-blocking. If a cache entry is
|
|
|
|
* waiting to be validated by another cache descriptor (so no new cache descriptors for that
|
|
|
|
* key can be created, OpenCacheEntry() will return NS_ERROR_CACHE_WAIT_FOR_VALIDATION in
|
|
|
|
* non-blocking mode. In blocking mode, it will wait until the cache entry for the key has
|
|
|
|
* been validated or doomed. If the cache entry is validated, then a descriptor for that
|
|
|
|
* entry will be created and returned. If the cache entry was doomed, then a descriptor
|
|
|
|
* will be created for a new cache entry for the key.
|
|
|
|
*/
|
|
|
|
const long NON_BLOCKING = 0;
|
|
|
|
const long BLOCKING = 1;
|
2010-06-24 06:55:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Constant meaning no expiration time.
|
|
|
|
*/
|
|
|
|
const unsigned long NO_EXPIRATION_TIME = 0xFFFFFFFF;
|
2001-02-23 23:20:15 +00:00
|
|
|
};
|
|
|
|
|