Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "nsISupports.idl"
8 interface nsILoadGroup;
10 typedef unsigned long nsLoadFlags;
12 /**
13 * nsIRequest
14 */
15 [scriptable, uuid(ef6bfbd2-fd46-48d8-96b7-9f8f0fd387fe)]
16 interface nsIRequest : nsISupports
17 {
18 /**
19 * The name of the request. Often this is the URI of the request.
20 */
21 readonly attribute AUTF8String name;
23 /**
24 * Indicates whether the request is pending. nsIRequest::isPending is
25 * true when there is an outstanding asynchronous event that will make
26 * the request no longer be pending. Requests do not necessarily start
27 * out pending; in some cases, requests have to be explicitly initiated
28 * (e.g. nsIChannel implementations are only pending once asyncOpen
29 * returns successfully).
30 *
31 * Requests can become pending multiple times during their lifetime.
32 *
33 * @return TRUE if the request has yet to reach completion.
34 * @return FALSE if the request has reached completion (e.g., after
35 * OnStopRequest has fired).
36 * @note Suspended requests are still considered pending.
37 */
38 boolean isPending();
40 /**
41 * The error status associated with the request.
42 */
43 readonly attribute nsresult status;
45 /**
46 * Cancels the current request. This will close any open input or
47 * output streams and terminate any async requests. Users should
48 * normally pass NS_BINDING_ABORTED, although other errors may also
49 * be passed. The error passed in will become the value of the
50 * status attribute.
51 *
52 * Implementations must not send any notifications (e.g. via
53 * nsIRequestObserver) synchronously from this function. Similarly,
54 * removal from the load group (if any) must also happen asynchronously.
55 *
56 * Requests that use nsIStreamListener must not call onDataAvailable
57 * anymore after cancel has been called.
58 *
59 * @param aStatus the reason for canceling this request.
60 *
61 * NOTE: most nsIRequest implementations expect aStatus to be a
62 * failure code; however, some implementations may allow aStatus to
63 * be a success code such as NS_OK. In general, aStatus should be
64 * a failure code.
65 */
66 void cancel(in nsresult aStatus);
68 /**
69 * Suspends the current request. This may have the effect of closing
70 * any underlying transport (in order to free up resources), although
71 * any open streams remain logically opened and will continue delivering
72 * data when the transport is resumed.
73 *
74 * Calling cancel() on a suspended request must not send any
75 * notifications (such as onstopRequest) until the request is resumed.
76 *
77 * NOTE: some implementations are unable to immediately suspend, and
78 * may continue to deliver events already posted to an event queue. In
79 * general, callers should be capable of handling events even after
80 * suspending a request.
81 */
82 void suspend();
84 /**
85 * Resumes the current request. This may have the effect of re-opening
86 * any underlying transport and will resume the delivery of data to
87 * any open streams.
88 */
89 void resume();
91 /**
92 * The load group of this request. While pending, the request is a
93 * member of the load group. It is the responsibility of the request
94 * to implement this policy.
95 */
96 attribute nsILoadGroup loadGroup;
98 /**
99 * The load flags of this request. Bits 0-15 are reserved.
100 *
101 * When added to a load group, this request's load flags are merged with
102 * the load flags of the load group.
103 */
104 attribute nsLoadFlags loadFlags;
106 /**
107 * Mask defining the bits reserved for nsIRequest LoadFlags
108 */
109 const unsigned long LOAD_REQUESTMASK = 0xFFFF;
111 /**************************************************************************
112 * Listed below are the various load flags which may be or'd together.
113 */
115 /**
116 * No special load flags:
117 */
118 const unsigned long LOAD_NORMAL = 0;
120 /**
121 * Don't deliver status notifications to the nsIProgressEventSink, or keep
122 * this load from completing the nsILoadGroup it may belong to.
123 */
124 const unsigned long LOAD_BACKGROUND = 1 << 0;
126 /**************************************************************************
127 * The following flags control the flow of data into the cache.
128 */
130 /**
131 * This flag prevents loading of the request with an HTTP pipeline.
132 * Generally this is because the resource is expected to take a
133 * while to load and may cause head of line blocking problems.
134 */
135 const unsigned long INHIBIT_PIPELINE = 1 << 6;
137 /**
138 * This flag prevents caching of any kind. It does not, however, prevent
139 * cached content from being used to satisfy this request.
140 */
141 const unsigned long INHIBIT_CACHING = 1 << 7;
143 /**
144 * This flag prevents caching on disk (or other persistent media), which
145 * may be needed to preserve privacy. For HTTPS, this flag is set auto-
146 * matically.
147 */
148 const unsigned long INHIBIT_PERSISTENT_CACHING = 1 << 8;
150 /**************************************************************************
151 * The following flags control what happens when the cache contains data
152 * that could perhaps satisfy this request. They are listed in descending
153 * order of precidence.
154 */
156 /**
157 * Force an end-to-end download of content data from the origin server.
158 * This flag is used for a shift-reload.
159 */
160 const unsigned long LOAD_BYPASS_CACHE = 1 << 9;
162 /**
163 * Attempt to force a load from the cache, bypassing ALL validation logic
164 * (note: this is stronger than VALIDATE_NEVER, which still validates for
165 * certain conditions).
166 *
167 * If the resource is not present in cache, it will be loaded from the
168 * network. Combine this flag with LOAD_ONLY_FROM_CACHE if you wish to
169 * perform cache-only loads without validation checks.
170 *
171 * This flag is used when browsing via history. It is not recommended for
172 * normal browsing as it may likely violate reasonable assumptions made by
173 * the server and confuse users.
174 */
175 const unsigned long LOAD_FROM_CACHE = 1 << 10;
177 /**
178 * The following flags control the frequency of cached content validation
179 * when neither LOAD_BYPASS_CACHE or LOAD_FROM_CACHE are set. By default,
180 * cached content is automatically validated if necessary before reuse.
181 *
182 * VALIDATE_ALWAYS forces validation of any cached content independent of
183 * its expiration time.
184 *
185 * VALIDATE_NEVER disables validation of cached content, unless it arrived
186 * with the "Cache: no-store" header, or arrived via HTTPS with the
187 * "Cache: no-cache" header.
188 *
189 * VALIDATE_ONCE_PER_SESSION disables validation of expired content,
190 * provided it has already been validated (at least once) since the start
191 * of this session.
192 *
193 * NOTE TO IMPLEMENTORS:
194 * These flags are intended for normal browsing, and they should therefore
195 * not apply to content that must be validated before each use. Consider,
196 * for example, a HTTP response with a "Cache-control: no-cache" header.
197 * According to RFC2616, this response must be validated before it can
198 * be taken from a cache. Breaking this requirement could result in
199 * incorrect and potentially undesirable side-effects.
200 */
201 const unsigned long VALIDATE_ALWAYS = 1 << 11;
202 const unsigned long VALIDATE_NEVER = 1 << 12;
203 const unsigned long VALIDATE_ONCE_PER_SESSION = 1 << 13;
205 /**
206 * When set, this flag indicates that no user-specific data should be added
207 * to the request when opened. This means that things like authorization
208 * tokens or cookie headers should not be added.
209 */
210 const unsigned long LOAD_ANONYMOUS = 1 << 14;
212 /**
213 * When set, this flag indicates that caches of network connections,
214 * particularly HTTP persistent connections, should not be used.
215 */
216 const unsigned long LOAD_FRESH_CONNECTION = 1 << 15;
217 };