Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
michael@0 | 1 | /* -*- mode: C++; tab-width: 4; 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 nsIURI; |
michael@0 | 9 | interface nsIDOMWindow; |
michael@0 | 10 | interface nsIDOMNode; |
michael@0 | 11 | interface nsIDOMDocument; |
michael@0 | 12 | interface nsIOfflineCacheUpdate; |
michael@0 | 13 | interface nsIPrincipal; |
michael@0 | 14 | interface nsIPrefBranch; |
michael@0 | 15 | interface nsIApplicationCache; |
michael@0 | 16 | interface nsIFile; |
michael@0 | 17 | interface nsIObserver; |
michael@0 | 18 | |
michael@0 | 19 | [scriptable, uuid(47360d57-8ef4-4a5d-8865-1a27a739ad1a)] |
michael@0 | 20 | interface nsIOfflineCacheUpdateObserver : nsISupports { |
michael@0 | 21 | const unsigned long STATE_ERROR = 1; |
michael@0 | 22 | const unsigned long STATE_CHECKING = 2; |
michael@0 | 23 | const unsigned long STATE_NOUPDATE = 3; |
michael@0 | 24 | const unsigned long STATE_OBSOLETE = 4; |
michael@0 | 25 | const unsigned long STATE_DOWNLOADING = 5; |
michael@0 | 26 | const unsigned long STATE_ITEMSTARTED = 6; |
michael@0 | 27 | const unsigned long STATE_ITEMCOMPLETED = 7; |
michael@0 | 28 | const unsigned long STATE_ITEMPROGRESS = 8; |
michael@0 | 29 | const unsigned long STATE_FINISHED = 10; |
michael@0 | 30 | |
michael@0 | 31 | /** |
michael@0 | 32 | * aUpdate has changed its state. |
michael@0 | 33 | * |
michael@0 | 34 | * @param aUpdate |
michael@0 | 35 | * The nsIOfflineCacheUpdate being processed. |
michael@0 | 36 | * @param event |
michael@0 | 37 | * See enumeration above |
michael@0 | 38 | */ |
michael@0 | 39 | void updateStateChanged(in nsIOfflineCacheUpdate aUpdate, in uint32_t state); |
michael@0 | 40 | |
michael@0 | 41 | /** |
michael@0 | 42 | * Informs the observer about an application being available to associate. |
michael@0 | 43 | * |
michael@0 | 44 | * @param applicationCache |
michael@0 | 45 | * The application cache instance that has been created or found by the |
michael@0 | 46 | * update to associate with |
michael@0 | 47 | */ |
michael@0 | 48 | void applicationCacheAvailable(in nsIApplicationCache applicationCache); |
michael@0 | 49 | }; |
michael@0 | 50 | |
michael@0 | 51 | /** |
michael@0 | 52 | * An nsIOfflineCacheUpdate is used to update an application's offline |
michael@0 | 53 | * resources. |
michael@0 | 54 | * |
michael@0 | 55 | * It can be used to perform partial or complete updates. |
michael@0 | 56 | * |
michael@0 | 57 | * One update object will be updating at a time. The active object will |
michael@0 | 58 | * load its items one by one, sending itemCompleted() to any registered |
michael@0 | 59 | * observers. |
michael@0 | 60 | */ |
michael@0 | 61 | [scriptable, uuid(a4503a53-6ab8-4b50-b01e-1c4f393fc980)] |
michael@0 | 62 | interface nsIOfflineCacheUpdate : nsISupports { |
michael@0 | 63 | /** |
michael@0 | 64 | * Fetch the status of the running update. This will return a value |
michael@0 | 65 | * defined in nsIDOMOfflineResourceList. |
michael@0 | 66 | */ |
michael@0 | 67 | readonly attribute unsigned short status; |
michael@0 | 68 | |
michael@0 | 69 | /** |
michael@0 | 70 | * TRUE if the update is being used to add specific resources. |
michael@0 | 71 | * FALSE if the complete cache update process is happening. |
michael@0 | 72 | */ |
michael@0 | 73 | readonly attribute boolean partial; |
michael@0 | 74 | |
michael@0 | 75 | /** |
michael@0 | 76 | * TRUE if this is an upgrade attempt, FALSE if it is a new cache |
michael@0 | 77 | * attempt. |
michael@0 | 78 | */ |
michael@0 | 79 | readonly attribute boolean isUpgrade; |
michael@0 | 80 | |
michael@0 | 81 | /** |
michael@0 | 82 | * The domain being updated, and the domain that will own any URIs added |
michael@0 | 83 | * with this update. |
michael@0 | 84 | */ |
michael@0 | 85 | readonly attribute ACString updateDomain; |
michael@0 | 86 | |
michael@0 | 87 | /** |
michael@0 | 88 | * The manifest for the offline application being updated. |
michael@0 | 89 | */ |
michael@0 | 90 | readonly attribute nsIURI manifestURI; |
michael@0 | 91 | |
michael@0 | 92 | /** |
michael@0 | 93 | * TRUE if the cache update completed successfully. |
michael@0 | 94 | */ |
michael@0 | 95 | readonly attribute boolean succeeded; |
michael@0 | 96 | |
michael@0 | 97 | /** |
michael@0 | 98 | * Initialize the update. |
michael@0 | 99 | * |
michael@0 | 100 | * @param aManifestURI |
michael@0 | 101 | * The manifest URI to be checked. |
michael@0 | 102 | * @param aDocumentURI |
michael@0 | 103 | * The page that is requesting the update. |
michael@0 | 104 | */ |
michael@0 | 105 | void init(in nsIURI aManifestURI, in nsIURI aDocumentURI, in nsIDOMDocument aDocument, |
michael@0 | 106 | [optional] in nsIFile aCustomProfileDir, |
michael@0 | 107 | [optional] in unsigned long aAppId, |
michael@0 | 108 | [optional] in boolean aInBrowser); |
michael@0 | 109 | |
michael@0 | 110 | /** |
michael@0 | 111 | * Initialize the update for partial processing. |
michael@0 | 112 | * |
michael@0 | 113 | * @param aManifestURI |
michael@0 | 114 | * The manifest URI of the related cache. |
michael@0 | 115 | * @param aClientID |
michael@0 | 116 | * Client ID of the cache to store resource to. This ClientID |
michael@0 | 117 | * must be ID of cache in the cache group identified by |
michael@0 | 118 | * the manifest URI passed in the first parameter. |
michael@0 | 119 | * @param aDocumentURI |
michael@0 | 120 | * The page that is requesting the update. May be null |
michael@0 | 121 | * when this information is unknown. |
michael@0 | 122 | */ |
michael@0 | 123 | void initPartial(in nsIURI aManifestURI, in ACString aClientID, in nsIURI aDocumentURI); |
michael@0 | 124 | |
michael@0 | 125 | /** |
michael@0 | 126 | * Initialize the update to only check whether there is an update |
michael@0 | 127 | * to the manifest available (if it has actually changed on the server). |
michael@0 | 128 | * |
michael@0 | 129 | * @param aManifestURI |
michael@0 | 130 | * The manifest URI of the related cache. |
michael@0 | 131 | * @param aAppID |
michael@0 | 132 | * Local ID of an app (optional) to check the cache update for. |
michael@0 | 133 | * @param aInBrowser |
michael@0 | 134 | * Whether to check for a cache populated from browser element. |
michael@0 | 135 | * @param aObserver |
michael@0 | 136 | * nsIObserver implementation that receives the result. |
michael@0 | 137 | * When aTopic == "offline-cache-update-available" there is an update to |
michael@0 | 138 | * to download. Update of the app cache will lead to a new version |
michael@0 | 139 | * download. |
michael@0 | 140 | * When aTopic == "offline-cache-update-unavailable" then there is no |
michael@0 | 141 | * update available (the manifest has not changed on the server). |
michael@0 | 142 | */ |
michael@0 | 143 | void initForUpdateCheck(in nsIURI aManifestURI, |
michael@0 | 144 | in unsigned long aAppID, |
michael@0 | 145 | in boolean aInBrowser, |
michael@0 | 146 | in nsIObserver aObserver); |
michael@0 | 147 | |
michael@0 | 148 | /** |
michael@0 | 149 | * Add a dynamic URI to the offline cache as part of the update. |
michael@0 | 150 | * |
michael@0 | 151 | * @param aURI |
michael@0 | 152 | * The URI to add. |
michael@0 | 153 | */ |
michael@0 | 154 | void addDynamicURI(in nsIURI aURI); |
michael@0 | 155 | |
michael@0 | 156 | /** |
michael@0 | 157 | * Add the update to the offline update queue. An offline-cache-update-added |
michael@0 | 158 | * event will be sent to the observer service. |
michael@0 | 159 | */ |
michael@0 | 160 | void schedule(); |
michael@0 | 161 | |
michael@0 | 162 | /** |
michael@0 | 163 | * Observe loads that are added to the update. |
michael@0 | 164 | * |
michael@0 | 165 | * @param aObserver |
michael@0 | 166 | * object that notifications will be sent to. |
michael@0 | 167 | * @param aHoldWeak |
michael@0 | 168 | * TRUE if you want the update to hold a weak reference to the |
michael@0 | 169 | * observer, FALSE for a strong reference. |
michael@0 | 170 | */ |
michael@0 | 171 | void addObserver(in nsIOfflineCacheUpdateObserver aObserver, |
michael@0 | 172 | in boolean aHoldWeak); |
michael@0 | 173 | |
michael@0 | 174 | /** |
michael@0 | 175 | * Remove an observer from the update. |
michael@0 | 176 | * |
michael@0 | 177 | * @param aObserver |
michael@0 | 178 | * the observer to remove. |
michael@0 | 179 | */ |
michael@0 | 180 | void removeObserver(in nsIOfflineCacheUpdateObserver aObserver); |
michael@0 | 181 | |
michael@0 | 182 | /** |
michael@0 | 183 | * Cancel the update when still in progress. This stops all running resource |
michael@0 | 184 | * downloads and discards the downloaded cache version. Throws when update |
michael@0 | 185 | * has already finished and made the new cache version active. |
michael@0 | 186 | */ |
michael@0 | 187 | void cancel(); |
michael@0 | 188 | |
michael@0 | 189 | /** |
michael@0 | 190 | * Return the number of bytes downloaded so far |
michael@0 | 191 | */ |
michael@0 | 192 | readonly attribute uint64_t byteProgress; |
michael@0 | 193 | }; |
michael@0 | 194 | |
michael@0 | 195 | [scriptable, uuid(0668910d-d14f-4cee-8db5-25faebc360ab)] |
michael@0 | 196 | interface nsIOfflineCacheUpdateService : nsISupports { |
michael@0 | 197 | /** |
michael@0 | 198 | * Constants for the offline-app permission. |
michael@0 | 199 | * |
michael@0 | 200 | * XXX: This isn't a great place for this, but it's really the only |
michael@0 | 201 | * private offline-app-related interface |
michael@0 | 202 | */ |
michael@0 | 203 | |
michael@0 | 204 | /** |
michael@0 | 205 | * Allow the domain to use offline APIs, and don't warn about excessive |
michael@0 | 206 | * usage. |
michael@0 | 207 | */ |
michael@0 | 208 | const unsigned long ALLOW_NO_WARN = 3; |
michael@0 | 209 | |
michael@0 | 210 | /** |
michael@0 | 211 | * Access to the list of cache updates that have been scheduled. |
michael@0 | 212 | */ |
michael@0 | 213 | readonly attribute unsigned long numUpdates; |
michael@0 | 214 | nsIOfflineCacheUpdate getUpdate(in unsigned long index); |
michael@0 | 215 | |
michael@0 | 216 | /** |
michael@0 | 217 | * Schedule a cache update for a given offline manifest. If an |
michael@0 | 218 | * existing update is scheduled or running, that update will be returned. |
michael@0 | 219 | * Otherwise a new update will be scheduled. |
michael@0 | 220 | */ |
michael@0 | 221 | nsIOfflineCacheUpdate scheduleUpdate(in nsIURI aManifestURI, |
michael@0 | 222 | in nsIURI aDocumentURI, |
michael@0 | 223 | in nsIDOMWindow aWindow); |
michael@0 | 224 | |
michael@0 | 225 | /** |
michael@0 | 226 | * Schedule a cache update for a given offline manifest using app cache |
michael@0 | 227 | * bound to the given appID+inBrowser flag. If an existing update is |
michael@0 | 228 | * scheduled or running, that update will be returned. Otherwise a new |
michael@0 | 229 | * update will be scheduled. |
michael@0 | 230 | */ |
michael@0 | 231 | nsIOfflineCacheUpdate scheduleAppUpdate(in nsIURI aManifestURI, |
michael@0 | 232 | in nsIURI aDocumentURI, |
michael@0 | 233 | in unsigned long aAppID, |
michael@0 | 234 | in boolean aInBrowser, |
michael@0 | 235 | in nsIFile aProfileDir); |
michael@0 | 236 | |
michael@0 | 237 | /** |
michael@0 | 238 | * Schedule a cache update for a manifest when the document finishes |
michael@0 | 239 | * loading. |
michael@0 | 240 | */ |
michael@0 | 241 | void scheduleOnDocumentStop(in nsIURI aManifestURI, |
michael@0 | 242 | in nsIURI aDocumentURI, |
michael@0 | 243 | in nsIDOMDocument aDocument); |
michael@0 | 244 | |
michael@0 | 245 | /** |
michael@0 | 246 | * Schedule a check to see if an update is available. |
michael@0 | 247 | * |
michael@0 | 248 | * This will not update or make any changes to the appcache. |
michael@0 | 249 | * It only notifies the observer to indicate whether the manifest has |
michael@0 | 250 | * changed on the server (or not): a changed manifest means that an |
michael@0 | 251 | * update is available. |
michael@0 | 252 | * |
michael@0 | 253 | * For arguments see nsIOfflineCacheUpdate.initForUpdateCheck() method |
michael@0 | 254 | * description. |
michael@0 | 255 | */ |
michael@0 | 256 | void checkForUpdate(in nsIURI aManifestURI, |
michael@0 | 257 | in unsigned long aAppID, |
michael@0 | 258 | in boolean aInBrowser, |
michael@0 | 259 | in nsIObserver aObserver); |
michael@0 | 260 | |
michael@0 | 261 | /** |
michael@0 | 262 | * Checks whether a principal should have access to the offline |
michael@0 | 263 | * cache. |
michael@0 | 264 | * @param aPrincipal |
michael@0 | 265 | * The principal to check. |
michael@0 | 266 | * @param aPrefBranch |
michael@0 | 267 | * The pref branch to use to check the |
michael@0 | 268 | * offline-apps.allow_by_default pref. If not specified, |
michael@0 | 269 | * the pref service will be used. |
michael@0 | 270 | */ |
michael@0 | 271 | boolean offlineAppAllowed(in nsIPrincipal aPrincipal, |
michael@0 | 272 | in nsIPrefBranch aPrefBranch); |
michael@0 | 273 | |
michael@0 | 274 | /** |
michael@0 | 275 | * Checks whether a document at the given URI should have access |
michael@0 | 276 | * to the offline cache. |
michael@0 | 277 | * @param aURI |
michael@0 | 278 | * The URI to check |
michael@0 | 279 | * @param aPrefBranch |
michael@0 | 280 | * The pref branch to use to check the |
michael@0 | 281 | * offline-apps.allow_by_default pref. If not specified, |
michael@0 | 282 | * the pref service will be used. |
michael@0 | 283 | */ |
michael@0 | 284 | boolean offlineAppAllowedForURI(in nsIURI aURI, |
michael@0 | 285 | in nsIPrefBranch aPrefBranch); |
michael@0 | 286 | |
michael@0 | 287 | /** |
michael@0 | 288 | * Sets the "offline-app" permission for the principal. |
michael@0 | 289 | * In the single process model calls directly on permission manager. |
michael@0 | 290 | * In the multi process model dispatches to the parent process. |
michael@0 | 291 | */ |
michael@0 | 292 | void allowOfflineApp(in nsIDOMWindow aWindow, in nsIPrincipal aPrincipal); |
michael@0 | 293 | }; |