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