Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / netwerk / base / public / nsICachingChannel.idl
blob629995be3744f85bcc729203fc0360eb0e507980
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 2001
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Darin Fisher <darin@netscape.com> (original author)
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #include "nsISupports.idl"
41 interface nsIFile;
43 /**
44 * A channel may optionally implement this interface to allow clients
45 * to affect its behavior with respect to how it uses the cache service.
47 * This interface provides:
48 * 1) Support for "stream as file" semantics (for JAR and plugins).
49 * 2) Support for "pinning" cached data in the cache (for printing and save-as).
50 * 3) Support for uniquely identifying cached data in cases when the URL
51 * is insufficient (e.g., HTTP form submission).
53 [scriptable, uuid(830D4BCB-3E46-4011-9BDA-51A5D1AF891F)]
54 interface nsICachingChannel : nsISupports
56 /**
57 * Set/get the cache token... uniquely identifies the data in the cache.
58 * Holding a reference to this token prevents the cached data from being
59 * removed.
61 * A cache token retrieved from a particular instance of nsICachingChannel
62 * could be set on another instance of nsICachingChannel provided the
63 * underlying implementations are compatible. The implementation of
64 * nsICachingChannel would be expected to only read from the cache entry
65 * identified by the cache token and not try to validate it.
67 * The cache token can be QI'd to a nsICacheEntryInfo if more detail
68 * about the cache entry is needed (e.g., expiration time).
70 attribute nsISupports cacheToken;
72 /**
73 * The same as above but accessing the offline app cache token if there
74 * is any.
76 * @throws
77 * NS_ERROR_NOT_AVAILABLE when there is not offline cache token
79 attribute nsISupports offlineCacheToken;
81 /**
82 * Set/get the cache key... uniquely identifies the data in the cache
83 * for this channel. Holding a reference to this key does NOT prevent
84 * the cached data from being removed.
86 * A cache key retrieved from a particular instance of nsICachingChannel
87 * could be set on another instance of nsICachingChannel provided the
88 * underlying implementations are compatible and provided the new
89 * channel instance was created with the same URI. The implementation of
90 * nsICachingChannel would be expected to use the cache entry identified
91 * by the cache token. Depending on the value of nsIRequest::loadFlags,
92 * the cache entry may be validated, overwritten, or simply read.
94 * The cache key may be NULL indicating that the URI of the channel is
95 * sufficient to locate the same cache entry. Setting a NULL cache key
96 * is likewise valid.
98 attribute nsISupports cacheKey;
101 * Specifies whether or not the data should be cached to a file. This
102 * may fail if the disk cache is not present. The value of this attribute
103 * is usually only settable during the processing of a channel's
104 * OnStartRequest. The default value of this attribute depends on the
105 * particular implementation of nsICachingChannel.
107 attribute boolean cacheAsFile;
110 * Specifies whether or not the data should be placed in the offline cache,
111 * in addition to normal memory/disk caching. This may fail if the offline
112 * cache is not present. The value of this attribute should be set before
113 * opening the channel.
115 attribute boolean cacheForOfflineUse;
118 * The session into which to cache offline data. If not specified,
119 * data will be placed in "HTTP-offline"
121 attribute ACString offlineCacheClientID;
124 * Get the "file" where the cached data can be found. This is valid for
125 * as long as a reference to the cache token is held. This may return
126 * an error if cacheAsFile is false.
128 readonly attribute nsIFile cacheFile;
131 * TRUE if this channel's data is being loaded from the cache. This value
132 * is undefined before the channel fires its OnStartRequest notification
133 * and after the channel fires its OnStopRequest notification.
135 boolean isFromCache();
137 /**************************************************************************
138 * Caching channel specific load flags:
142 * This load flag inhibits fetching from the net. An error of
143 * NS_ERROR_DOCUMENT_NOT_CACHED will be sent to the listener's
144 * onStopRequest if network IO is necessary to complete the request.
146 * This flag can be used to find out whether fetching this URL would
147 * cause validation of the cache entry via the network.
149 * Combining this flag with LOAD_BYPASS_LOCAL_CACHE will cause all
150 * loads to fail. This flag differs from LOAD_ONLY_FROM_CACHE in that
151 * this flag fails the load if validation is required while
152 * LOAD_ONLY_FROM_CACHE skips validation where possible.
154 const unsigned long LOAD_NO_NETWORK_IO = 1 << 26;
157 * This load flag causes the offline cache to be checked when fetching
158 * a request. It will be set automatically if the browser is offline.
160 * This flag will not be transferred through a redirect.
162 const unsigned long LOAD_CHECK_OFFLINE_CACHE = 1 << 27;
165 * This load flag causes the local cache to be skipped when fetching a
166 * request. Unlike LOAD_BYPASS_CACHE, it does not force an end-to-end load
167 * (i.e., it does not affect proxy caches).
169 const unsigned long LOAD_BYPASS_LOCAL_CACHE = 1 << 28;
172 * This load flag causes the local cache to be skipped if the request
173 * would otherwise block waiting to access the cache.
175 const unsigned long LOAD_BYPASS_LOCAL_CACHE_IF_BUSY = 1 << 29;
178 * This load flag inhibits fetching from the net if the data in the cache
179 * has been evicted. An error of NS_ERROR_DOCUMENT_NOT_CACHED will be sent
180 * to the listener's onStopRequest in this case. This flag is set
181 * automatically when the application is offline.
183 const unsigned long LOAD_ONLY_FROM_CACHE = 1 << 30;
186 * This load flag controls what happens when a document would be loaded
187 * from the cache to satisfy a call to AsyncOpen. If this attribute is
188 * set to TRUE, then the document will not be loaded from the cache. A
189 * stream listener can check nsICachingChannel::isFromCache to determine
190 * if the AsyncOpen will actually result in data being streamed.
192 * If this flag has been set, and the request can be satisfied via the
193 * cache, then the OnDataAvailable events will be skipped. The listener
194 * will only see OnStartRequest followed by OnStopRequest.
196 const unsigned long LOAD_ONLY_IF_MODIFIED = 1 << 31;