netwerk/base/public/nsIApplicationCache.idl

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
michael@0 2 *
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #include "nsISupports.idl"
michael@0 8
michael@0 9 interface nsIArray;
michael@0 10 interface nsIFile;
michael@0 11 interface nsIURI;
michael@0 12
michael@0 13 /**
michael@0 14 * Application caches can store a set of namespace entries that affect
michael@0 15 * loads from the application cache. If a load from the cache fails
michael@0 16 * to match an exact cache entry, namespaces entries will be searched
michael@0 17 * for a substring match, and should be applied appropriately.
michael@0 18 */
michael@0 19 [scriptable, uuid(96e4c264-2065-4ce9-93bb-43734c62c4eb)]
michael@0 20 interface nsIApplicationCacheNamespace : nsISupports
michael@0 21 {
michael@0 22 /**
michael@0 23 * Items matching this namespace can be fetched from the network
michael@0 24 * when loading from this cache. The "data" attribute is unused.
michael@0 25 */
michael@0 26 const unsigned long NAMESPACE_BYPASS = 1 << 0;
michael@0 27
michael@0 28 /**
michael@0 29 * Items matching this namespace can be fetched from the network
michael@0 30 * when loading from this cache. If the load fails, the cache entry
michael@0 31 * specified by the "data" attribute should be loaded instead.
michael@0 32 */
michael@0 33 const unsigned long NAMESPACE_FALLBACK = 1 << 1;
michael@0 34
michael@0 35 /**
michael@0 36 * Items matching this namespace should be cached
michael@0 37 * opportunistically. Successful toplevel loads of documents
michael@0 38 * in this namespace should be placed in the application cache.
michael@0 39 * Namespaces specifying NAMESPACE_OPPORTUNISTIC may also specify
michael@0 40 * NAMESPACE_FALLBACK to supply a fallback entry.
michael@0 41 */
michael@0 42 const unsigned long NAMESPACE_OPPORTUNISTIC = 1 << 2;
michael@0 43
michael@0 44 /**
michael@0 45 * Initialize the namespace.
michael@0 46 */
michael@0 47 void init(in unsigned long itemType,
michael@0 48 in ACString namespaceSpec,
michael@0 49 in ACString data);
michael@0 50
michael@0 51 /**
michael@0 52 * The namespace type.
michael@0 53 */
michael@0 54 readonly attribute unsigned long itemType;
michael@0 55
michael@0 56 /**
michael@0 57 * The prefix of this namespace. This should be the asciiSpec of the
michael@0 58 * URI prefix.
michael@0 59 */
michael@0 60 readonly attribute ACString namespaceSpec;
michael@0 61
michael@0 62 /**
michael@0 63 * Data associated with this namespace, such as a fallback. URI data should
michael@0 64 * use the asciiSpec of the URI.
michael@0 65 */
michael@0 66 readonly attribute ACString data;
michael@0 67 };
michael@0 68
michael@0 69 /**
michael@0 70 * Application caches store resources for offline use. Each
michael@0 71 * application cache has a unique client ID for use with
michael@0 72 * nsICacheService::openSession() to access the cache's entries.
michael@0 73 *
michael@0 74 * Each entry in the application cache can be marked with a set of
michael@0 75 * types, as discussed in the WHAT-WG offline applications
michael@0 76 * specification.
michael@0 77 *
michael@0 78 * All application caches with the same group ID belong to a cache
michael@0 79 * group. Each group has one "active" cache that will service future
michael@0 80 * loads. Inactive caches will be removed from the cache when they are
michael@0 81 * no longer referenced.
michael@0 82 */
michael@0 83 [scriptable, uuid(06568DAE-C374-4383-A122-0CC96C7177F2)]
michael@0 84 interface nsIApplicationCache : nsISupports
michael@0 85 {
michael@0 86 /**
michael@0 87 * Init this application cache instance to just hold the group ID and
michael@0 88 * the client ID to work just as a handle to the real cache. Used on
michael@0 89 * content process to simplify the application cache code.
michael@0 90 */
michael@0 91 void initAsHandle(in ACString groupId, in ACString clientId);
michael@0 92
michael@0 93 /**
michael@0 94 * Entries in an application cache can be marked as one or more of
michael@0 95 * the following types.
michael@0 96 */
michael@0 97
michael@0 98 /* This item is the application manifest. */
michael@0 99 const unsigned long ITEM_MANIFEST = 1 << 0;
michael@0 100
michael@0 101 /* This item was explicitly listed in the application manifest. */
michael@0 102 const unsigned long ITEM_EXPLICIT = 1 << 1;
michael@0 103
michael@0 104 /* This item was navigated in a toplevel browsing context, and
michael@0 105 * named this cache's group as its manifest. */
michael@0 106 const unsigned long ITEM_IMPLICIT = 1 << 2;
michael@0 107
michael@0 108 /* This item was added by the dynamic scripting API */
michael@0 109 const unsigned long ITEM_DYNAMIC = 1 << 3;
michael@0 110
michael@0 111 /* This item was listed in the application manifest, but named a
michael@0 112 * different cache group as its manifest. */
michael@0 113 const unsigned long ITEM_FOREIGN = 1 << 4;
michael@0 114
michael@0 115 /* This item was listed as a fallback entry. */
michael@0 116 const unsigned long ITEM_FALLBACK = 1 << 5;
michael@0 117
michael@0 118 /* This item matched an opportunistic cache namespace and was
michael@0 119 * cached accordingly. */
michael@0 120 const unsigned long ITEM_OPPORTUNISTIC = 1 << 6;
michael@0 121
michael@0 122 /**
michael@0 123 * URI of the manfiest specifying this application cache.
michael@0 124 **/
michael@0 125 readonly attribute nsIURI manifestURI;
michael@0 126
michael@0 127 /**
michael@0 128 * The group ID for this cache group. It is an internally generated string
michael@0 129 * and cannot be used as manifest URL spec.
michael@0 130 **/
michael@0 131 readonly attribute ACString groupID;
michael@0 132
michael@0 133 /**
michael@0 134 * The client ID for this application cache. Clients can open a
michael@0 135 * session with nsICacheService::createSession() using this client
michael@0 136 * ID and a storage policy of STORE_OFFLINE to access this cache.
michael@0 137 */
michael@0 138 readonly attribute ACString clientID;
michael@0 139
michael@0 140 /**
michael@0 141 * TRUE if the cache is the active cache for this group.
michael@0 142 */
michael@0 143 readonly attribute boolean active;
michael@0 144
michael@0 145 /**
michael@0 146 * The disk usage of the application cache, in bytes.
michael@0 147 */
michael@0 148 readonly attribute unsigned long usage;
michael@0 149
michael@0 150 /**
michael@0 151 * Makes this cache the active application cache for this group.
michael@0 152 * Future loads associated with this group will come from this
michael@0 153 * cache. Other caches from this cache group will be deactivated.
michael@0 154 */
michael@0 155 void activate();
michael@0 156
michael@0 157 /**
michael@0 158 * Discard this application cache. Removes all cached resources
michael@0 159 * for this cache. If this is the active application cache for the
michael@0 160 * group, the group will be removed.
michael@0 161 */
michael@0 162 void discard();
michael@0 163
michael@0 164 /**
michael@0 165 * Adds item types to a given entry.
michael@0 166 */
michael@0 167 void markEntry(in ACString key, in unsigned long typeBits);
michael@0 168
michael@0 169 /**
michael@0 170 * Removes types from a given entry. If the resulting entry has
michael@0 171 * no types left, the entry is removed.
michael@0 172 */
michael@0 173 void unmarkEntry(in ACString key, in unsigned long typeBits);
michael@0 174
michael@0 175 /**
michael@0 176 * Gets the types for a given entry.
michael@0 177 */
michael@0 178 unsigned long getTypes(in ACString key);
michael@0 179
michael@0 180 /**
michael@0 181 * Returns any entries in the application cache whose type matches
michael@0 182 * one or more of the bits in typeBits.
michael@0 183 */
michael@0 184 void gatherEntries(in uint32_t typeBits,
michael@0 185 out unsigned long count,
michael@0 186 [array, size_is(count)] out string keys);
michael@0 187
michael@0 188 /**
michael@0 189 * Add a set of namespace entries to the application cache.
michael@0 190 * @param namespaces
michael@0 191 * An nsIArray of nsIApplicationCacheNamespace entries.
michael@0 192 */
michael@0 193 void addNamespaces(in nsIArray namespaces);
michael@0 194
michael@0 195 /**
michael@0 196 * Get the most specific namespace matching a given key.
michael@0 197 */
michael@0 198 nsIApplicationCacheNamespace getMatchingNamespace(in ACString key);
michael@0 199
michael@0 200 /**
michael@0 201 * If set, this offline cache is placed in a different directory
michael@0 202 * than the current application profile.
michael@0 203 */
michael@0 204 readonly attribute nsIFile profileDirectory;
michael@0 205 };

mercurial