netwerk/cache/nsICache.idl

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
michael@0 2 *
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #include "nsISupports.idl"
michael@0 8
michael@0 9 typedef long nsCacheStoragePolicy;
michael@0 10 typedef long nsCacheAccessMode;
michael@0 11
michael@0 12 /**
michael@0 13 * nsICache is a namespace for various cache constants. It does not represent
michael@0 14 * an actual object.
michael@0 15 */
michael@0 16 [scriptable, uuid(d6c67f38-b39a-4582-8a48-4c4f8a56dfd0)]
michael@0 17 interface nsICache
michael@0 18 {
michael@0 19 /**
michael@0 20 * Access Modes
michael@0 21 *
michael@0 22 *
michael@0 23 * Mode Requested | Not Cached | Cached
michael@0 24 * ------------------------------------------------------------------------
michael@0 25 * READ | KEY_NOT_FOUND | NS_OK
michael@0 26 * | Mode = NONE | Mode = READ
michael@0 27 * | No Descriptor | Descriptor
michael@0 28 * ------------------------------------------------------------------------
michael@0 29 * WRITE | NS_OK | NS_OK (Cache service
michael@0 30 * | Mode = WRITE | Mode = WRITE dooms existing
michael@0 31 * | Descriptor | Descriptor cache entry)
michael@0 32 * ------------------------------------------------------------------------
michael@0 33 * READ_WRITE | NS_OK | NS_OK
michael@0 34 * (1st req.) | Mode = WRITE | Mode = READ_WRITE
michael@0 35 * | Descriptor | Descriptor
michael@0 36 * ------------------------------------------------------------------------
michael@0 37 * READ_WRITE | N/A | NS_OK
michael@0 38 * (Nth req.) | | Mode = READ
michael@0 39 * | | Descriptor
michael@0 40 * ------------------------------------------------------------------------
michael@0 41 *
michael@0 42 *
michael@0 43 * Access Requested:
michael@0 44 *
michael@0 45 * READ - I only want to READ, if there isn't an entry just fail
michael@0 46 * WRITE - I have something new I want to write into the cache, make
michael@0 47 * me a new entry and doom the old one, if any.
michael@0 48 * READ_WRITE - I want to READ, but I'm willing to update an existing
michael@0 49 * entry if necessary, or create a new one if none exists.
michael@0 50 *
michael@0 51 *
michael@0 52 * Access Granted:
michael@0 53 *
michael@0 54 * NONE - No descriptor is provided. You get zilch. Nada. Nothing.
michael@0 55 * READ - You can READ from this descriptor.
michael@0 56 * WRITE - You must WRITE to this descriptor because the cache entry
michael@0 57 * was just created for you.
michael@0 58 * READ_WRITE - You can READ the descriptor to determine if it's valid,
michael@0 59 * you may WRITE if it needs updating.
michael@0 60 *
michael@0 61 *
michael@0 62 * Comments:
michael@0 63 *
michael@0 64 * If you think that you might need to modify cached data or meta data,
michael@0 65 * then you must open a cache entry requesting WRITE access. Only one
michael@0 66 * cache entry descriptor, per cache entry, will be granted WRITE access.
michael@0 67 *
michael@0 68 * Usually, you will request READ_WRITE access in order to first test the
michael@0 69 * meta data and informational fields to determine if a write (ie. going
michael@0 70 * to the net) may actually be necessary. If you determine that it is
michael@0 71 * not, then you would mark the cache entry as valid (using MarkValid) and
michael@0 72 * then simply read the data from the cache.
michael@0 73 *
michael@0 74 * A descriptor granted WRITE access has exclusive access to the cache
michael@0 75 * entry up to the point at which it marks it as valid. Once the cache
michael@0 76 * entry has been "validated", other descriptors with READ access may be
michael@0 77 * opened to the cache entry.
michael@0 78 *
michael@0 79 * If you make a request for READ_WRITE access to a cache entry, the cache
michael@0 80 * service will downgrade your access to READ if there is already a
michael@0 81 * cache entry descriptor open with WRITE access.
michael@0 82 *
michael@0 83 * If you make a request for only WRITE access to a cache entry and another
michael@0 84 * descriptor with WRITE access is currently open, then the existing cache
michael@0 85 * entry will be 'doomed', and you will be given a descriptor (with WRITE
michael@0 86 * access only) to a new cache entry.
michael@0 87 *
michael@0 88 */
michael@0 89 const nsCacheAccessMode ACCESS_NONE = 0;
michael@0 90 const nsCacheAccessMode ACCESS_READ = 1;
michael@0 91 const nsCacheAccessMode ACCESS_WRITE = 2;
michael@0 92 const nsCacheAccessMode ACCESS_READ_WRITE = 3;
michael@0 93
michael@0 94 /**
michael@0 95 * Storage Policy
michael@0 96 *
michael@0 97 * The storage policy of a cache entry determines the device(s) to which
michael@0 98 * it belongs. See nsICacheSession and nsICacheEntryDescriptor for more
michael@0 99 * details.
michael@0 100 *
michael@0 101 * STORE_ANYWHERE - Allows the cache entry to be stored in any device.
michael@0 102 * The cache service decides which cache device to use
michael@0 103 * based on "some resource management calculation."
michael@0 104 * STORE_IN_MEMORY - Requires the cache entry to reside in non-persistent
michael@0 105 * storage (ie. typically in system RAM).
michael@0 106 * STORE_ON_DISK - Requires the cache entry to reside in persistent
michael@0 107 * storage (ie. typically on a system's hard disk).
michael@0 108 * STORE_OFFLINE - Requires the cache entry to reside in persistent,
michael@0 109 * reliable storage for offline use.
michael@0 110 */
michael@0 111 const nsCacheStoragePolicy STORE_ANYWHERE = 0;
michael@0 112 const nsCacheStoragePolicy STORE_IN_MEMORY = 1;
michael@0 113 const nsCacheStoragePolicy STORE_ON_DISK = 2;
michael@0 114 // value 3 was used by STORE_ON_DISK_AS_FILE which was removed
michael@0 115 const nsCacheStoragePolicy STORE_OFFLINE = 4;
michael@0 116
michael@0 117 /**
michael@0 118 * All entries for a cache session are stored as streams of data or
michael@0 119 * as objects. These constant my be used to specify the type of entries
michael@0 120 * when calling nsICacheService::CreateSession().
michael@0 121 */
michael@0 122 const long NOT_STREAM_BASED = 0;
michael@0 123 const long STREAM_BASED = 1;
michael@0 124
michael@0 125 /**
michael@0 126 * The synchronous OpenCacheEntry() may be blocking or non-blocking. If a cache entry is
michael@0 127 * waiting to be validated by another cache descriptor (so no new cache descriptors for that
michael@0 128 * key can be created, OpenCacheEntry() will return NS_ERROR_CACHE_WAIT_FOR_VALIDATION in
michael@0 129 * non-blocking mode. In blocking mode, it will wait until the cache entry for the key has
michael@0 130 * been validated or doomed. If the cache entry is validated, then a descriptor for that
michael@0 131 * entry will be created and returned. If the cache entry was doomed, then a descriptor
michael@0 132 * will be created for a new cache entry for the key.
michael@0 133 */
michael@0 134 const long NON_BLOCKING = 0;
michael@0 135 const long BLOCKING = 1;
michael@0 136
michael@0 137 /**
michael@0 138 * Constant meaning no expiration time.
michael@0 139 */
michael@0 140 const unsigned long NO_EXPIRATION_TIME = 0xFFFFFFFF;
michael@0 141 };
michael@0 142

mercurial