netwerk/cache2/nsICacheEntry.idl

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 #include "nsISupports.idl"
michael@0 6
michael@0 7 interface nsIInputStream;
michael@0 8 interface nsIOutputStream;
michael@0 9 interface nsICacheEntryDoomCallback;
michael@0 10
michael@0 11 // ************************ REMOVE **********************
michael@0 12 typedef long nsCacheAccessMode;
michael@0 13 typedef long nsCacheStoragePolicy;
michael@0 14
michael@0 15 interface nsICacheListener;
michael@0 16 interface nsIFile;
michael@0 17 interface nsICacheMetaDataVisitor;
michael@0 18
michael@0 19 [scriptable, uuid(3058bf1e-5116-41cf-826b-e6981308d414)]
michael@0 20 interface nsICacheEntry : nsISupports
michael@0 21 {
michael@0 22 /**
michael@0 23 * Placeholder for the initial value of expiration time.
michael@0 24 */
michael@0 25 const unsigned long NO_EXPIRATION_TIME = 0xFFFFFFFF;
michael@0 26
michael@0 27 /**
michael@0 28 * Get the key identifying the cache entry.
michael@0 29 */
michael@0 30 readonly attribute ACString key;
michael@0 31
michael@0 32 /**
michael@0 33 * Whether the entry is memory/only or persisted to disk.
michael@0 34 * Note: private browsing entries are reported as persistent for consistency
michael@0 35 * while are not actually persisted to disk.
michael@0 36 */
michael@0 37 readonly attribute boolean persistent;
michael@0 38
michael@0 39 /**
michael@0 40 * Get the number of times the cache entry has been opened.
michael@0 41 */
michael@0 42 readonly attribute long fetchCount;
michael@0 43
michael@0 44 /**
michael@0 45 * Get the last time the cache entry was opened (in seconds since the Epoch).
michael@0 46 */
michael@0 47 readonly attribute uint32_t lastFetched;
michael@0 48
michael@0 49 /**
michael@0 50 * Get the last time the cache entry was modified (in seconds since the Epoch).
michael@0 51 */
michael@0 52 readonly attribute uint32_t lastModified;
michael@0 53
michael@0 54 /**
michael@0 55 * Get the expiration time of the cache entry (in seconds since the Epoch).
michael@0 56 */
michael@0 57 readonly attribute uint32_t expirationTime;
michael@0 58
michael@0 59 /**
michael@0 60 * Set the time at which the cache entry should be considered invalid (in
michael@0 61 * seconds since the Epoch).
michael@0 62 */
michael@0 63 void setExpirationTime(in uint32_t expirationTime);
michael@0 64
michael@0 65 /**
michael@0 66 * Open blocking input stream to cache data. Use the stream transport
michael@0 67 * service to asynchronously read this stream on a background thread.
michael@0 68 * The returned stream MAY implement nsISeekableStream.
michael@0 69 *
michael@0 70 * @param offset
michael@0 71 * read starting from this offset into the cached data. an offset
michael@0 72 * beyond the end of the stream has undefined consequences.
michael@0 73 *
michael@0 74 * @return non-blocking, buffered input stream.
michael@0 75 */
michael@0 76 nsIInputStream openInputStream(in long long offset);
michael@0 77
michael@0 78 /**
michael@0 79 * Open non-blocking output stream to cache data. The returned stream
michael@0 80 * MAY implement nsISeekableStream.
michael@0 81 *
michael@0 82 * If opening an output stream to existing cached data, the data will be
michael@0 83 * truncated to the specified offset.
michael@0 84 *
michael@0 85 * @param offset
michael@0 86 * write starting from this offset into the cached data. an offset
michael@0 87 * beyond the end of the stream has undefined consequences.
michael@0 88 *
michael@0 89 * @return blocking, buffered output stream.
michael@0 90 */
michael@0 91 nsIOutputStream openOutputStream(in long long offset);
michael@0 92
michael@0 93 /**
michael@0 94 * Stores the Content-Length specified in the HTTP header for this
michael@0 95 * entry. Checked before we write to the cache entry, to prevent ever
michael@0 96 * taking up space in the cache for an entry that we know up front
michael@0 97 * is going to have to be evicted anyway. See bug 588507.
michael@0 98 */
michael@0 99 attribute int64_t predictedDataSize;
michael@0 100
michael@0 101 /**
michael@0 102 * Get/set security info on the cache entry for this descriptor.
michael@0 103 */
michael@0 104 attribute nsISupports securityInfo;
michael@0 105
michael@0 106 /**
michael@0 107 * Get the size of the cache entry data, as stored. This may differ
michael@0 108 * from the entry's dataSize, if the entry is compressed.
michael@0 109 */
michael@0 110 readonly attribute unsigned long storageDataSize;
michael@0 111
michael@0 112 /**
michael@0 113 * Asynchronously doom an entry. Listener will be notified about the status
michael@0 114 * of the operation. Null may be passed if caller doesn't care about the
michael@0 115 * result.
michael@0 116 */
michael@0 117 void asyncDoom(in nsICacheEntryDoomCallback listener);
michael@0 118
michael@0 119 /**
michael@0 120 * Methods for accessing meta data. Meta data is a table of key/value
michael@0 121 * string pairs. The strings do not have to conform to any particular
michael@0 122 * charset, but they must be null terminated.
michael@0 123 */
michael@0 124 string getMetaDataElement(in string key);
michael@0 125 void setMetaDataElement(in string key, in string value);
michael@0 126
michael@0 127 /**
michael@0 128 * Claims that all metadata on this entry are up-to-date and this entry
michael@0 129 * now can be delivered to other waiting consumers.
michael@0 130 *
michael@0 131 * We need such method since metadata must be delivered synchronously.
michael@0 132 */
michael@0 133 void metaDataReady();
michael@0 134
michael@0 135 /**
michael@0 136 * Called by consumer upon 304/206 response from the server. This marks
michael@0 137 * the entry content as positively revalidated.
michael@0 138 * Consumer uses this method after the consumer has returned ENTRY_NEEDS_REVALIDATION
michael@0 139 * result from onCacheEntryCheck and after successfull revalidation with the server.
michael@0 140 */
michael@0 141 void setValid();
michael@0 142
michael@0 143 /**
michael@0 144 * Doom this entry and open a new, empty, entry for write. Consumer has
michael@0 145 * to exchange the entry this method is called on for the newly created.
michael@0 146 * Used on 200 responses to conditional requests.
michael@0 147 *
michael@0 148 * @param aMemoryOnly
michael@0 149 * - whether the entry is to be created as memory/only regardless how
michael@0 150 * the entry being recreated persistence is set
michael@0 151 * @returns
michael@0 152 * - an entry that can be used to write to
michael@0 153 * @throws
michael@0 154 * - NS_ERROR_NOT_AVAILABLE when the entry cannot be from some reason
michael@0 155 * recreated for write
michael@0 156 */
michael@0 157 nsICacheEntry recreate([optional] in boolean aMemoryOnly);
michael@0 158
michael@0 159 /**
michael@0 160 * Returns the length of data this entry holds.
michael@0 161 * @throws
michael@0 162 * NS_ERROR_IN_PROGRESS when the write is still in progress.
michael@0 163 */
michael@0 164 readonly attribute long long dataSize;
michael@0 165
michael@0 166 /****************************************************************************
michael@0 167 * The following methods might be added to some nsICacheEntryInternal
michael@0 168 * interface since we want to remove them as soon as the old cache backend is
michael@0 169 * completely removed.
michael@0 170 */
michael@0 171
michael@0 172 /**
michael@0 173 * @deprecated
michael@0 174 * FOR BACKWARD COMPATIBILITY ONLY
michael@0 175 * When the old cache backend is eventually removed, this method
michael@0 176 * can be removed too.
michael@0 177 *
michael@0 178 * In the new backend: this method is no-op
michael@0 179 * In the old backend: this method delegates to nsICacheEntryDescriptor.close()
michael@0 180 */
michael@0 181 void close();
michael@0 182
michael@0 183 /**
michael@0 184 * @deprecated
michael@0 185 * FOR BACKWARD COMPATIBILITY ONLY
michael@0 186 * Marks the entry as valid so that others can use it and get only readonly
michael@0 187 * access when the entry is held by the 1st writer.
michael@0 188 */
michael@0 189 void markValid();
michael@0 190
michael@0 191 /**
michael@0 192 * @deprecated
michael@0 193 * FOR BACKWARD COMPATIBILITY ONLY
michael@0 194 * Marks the entry as valid when write access is acquired.
michael@0 195 */
michael@0 196 void maybeMarkValid();
michael@0 197
michael@0 198 /**
michael@0 199 * @deprecated
michael@0 200 * FOR BACKWARD COMPATIBILITY ONLY / KINDA HACK
michael@0 201 * @param aWriteAllowed
michael@0 202 * Consumer indicates whether write to the entry is allowed for it.
michael@0 203 * Depends on implementation how the flag is handled.
michael@0 204 * @returns
michael@0 205 * true when write access is acquired for this entry,
michael@0 206 * false otherwise
michael@0 207 */
michael@0 208 boolean hasWriteAccess(in boolean aWriteAllowed);
michael@0 209 };

mercurial