netwerk/base/public/nsIApplicationCache.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/base/public/nsIApplicationCache.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,205 @@
     1.4 +/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.5 + *
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#include "nsISupports.idl"
    1.11 +
    1.12 +interface nsIArray;
    1.13 +interface nsIFile;
    1.14 +interface nsIURI;
    1.15 +
    1.16 +/**
    1.17 + * Application caches can store a set of namespace entries that affect
    1.18 + * loads from the application cache.  If a load from the cache fails
    1.19 + * to match an exact cache entry, namespaces entries will be searched
    1.20 + * for a substring match, and should be applied appropriately.
    1.21 + */
    1.22 +[scriptable, uuid(96e4c264-2065-4ce9-93bb-43734c62c4eb)]
    1.23 +interface nsIApplicationCacheNamespace : nsISupports
    1.24 +{
    1.25 +    /**
    1.26 +     * Items matching this namespace can be fetched from the network
    1.27 +     * when loading from this cache.  The "data" attribute is unused.
    1.28 +     */
    1.29 +    const unsigned long NAMESPACE_BYPASS = 1 << 0;
    1.30 +
    1.31 +    /**
    1.32 +     * Items matching this namespace can be fetched from the network
    1.33 +     * when loading from this cache.  If the load fails, the cache entry
    1.34 +     * specified by the "data" attribute should be loaded instead.
    1.35 +     */
    1.36 +    const unsigned long NAMESPACE_FALLBACK = 1 << 1;
    1.37 +
    1.38 +    /**
    1.39 +     * Items matching this namespace should be cached
    1.40 +     * opportunistically.  Successful toplevel loads of documents
    1.41 +     * in this namespace should be placed in the application cache.
    1.42 +     * Namespaces specifying NAMESPACE_OPPORTUNISTIC may also specify
    1.43 +     * NAMESPACE_FALLBACK to supply a fallback entry.
    1.44 +     */
    1.45 +    const unsigned long NAMESPACE_OPPORTUNISTIC = 1 << 2;
    1.46 +
    1.47 +    /**
    1.48 +     * Initialize the namespace.
    1.49 +     */
    1.50 +    void init(in unsigned long itemType,
    1.51 +              in ACString namespaceSpec,
    1.52 +              in ACString data);
    1.53 +
    1.54 +    /**
    1.55 +     * The namespace type.
    1.56 +     */
    1.57 +    readonly attribute unsigned long itemType;
    1.58 +
    1.59 +    /**
    1.60 +     * The prefix of this namespace.  This should be the asciiSpec of the
    1.61 +     * URI prefix.
    1.62 +     */
    1.63 +    readonly attribute ACString namespaceSpec;
    1.64 +
    1.65 +    /**
    1.66 +     * Data associated with this namespace, such as a fallback.  URI data should
    1.67 +     * use the asciiSpec of the URI.
    1.68 +     */
    1.69 +    readonly attribute ACString data;
    1.70 +};
    1.71 +
    1.72 +/**
    1.73 + * Application caches store resources for offline use.  Each
    1.74 + * application cache has a unique client ID for use with
    1.75 + * nsICacheService::openSession() to access the cache's entries.
    1.76 + *
    1.77 + * Each entry in the application cache can be marked with a set of
    1.78 + * types, as discussed in the WHAT-WG offline applications
    1.79 + * specification.
    1.80 + *
    1.81 + * All application caches with the same group ID belong to a cache
    1.82 + * group.  Each group has one "active" cache that will service future
    1.83 + * loads.  Inactive caches will be removed from the cache when they are
    1.84 + * no longer referenced.
    1.85 + */
    1.86 +[scriptable, uuid(06568DAE-C374-4383-A122-0CC96C7177F2)]
    1.87 +interface nsIApplicationCache : nsISupports
    1.88 +{
    1.89 +    /**
    1.90 +     * Init this application cache instance to just hold the group ID and
    1.91 +     * the client ID to work just as a handle to the real cache. Used on
    1.92 +     * content process to simplify the application cache code.
    1.93 +     */
    1.94 +    void initAsHandle(in ACString groupId, in ACString clientId);
    1.95 +
    1.96 +    /**
    1.97 +     * Entries in an application cache can be marked as one or more of
    1.98 +     * the following types.
    1.99 +     */
   1.100 +
   1.101 +    /* This item is the application manifest. */
   1.102 +    const unsigned long ITEM_MANIFEST =      1 << 0;
   1.103 +
   1.104 +    /* This item was explicitly listed in the application manifest. */
   1.105 +    const unsigned long ITEM_EXPLICIT =      1 << 1;
   1.106 +
   1.107 +    /* This item was navigated in a toplevel browsing context, and
   1.108 +     * named this cache's group as its manifest. */
   1.109 +    const unsigned long ITEM_IMPLICIT =      1 << 2;
   1.110 +
   1.111 +    /* This item was added by the dynamic scripting API */
   1.112 +    const unsigned long ITEM_DYNAMIC =       1 << 3;
   1.113 +
   1.114 +    /* This item was listed in the application manifest, but named a
   1.115 +     * different cache group as its manifest. */
   1.116 +    const unsigned long ITEM_FOREIGN = 1 << 4;
   1.117 +
   1.118 +    /* This item was listed as a fallback entry. */
   1.119 +    const unsigned long ITEM_FALLBACK = 1 << 5;
   1.120 +
   1.121 +    /* This item matched an opportunistic cache namespace and was
   1.122 +     * cached accordingly. */
   1.123 +    const unsigned long ITEM_OPPORTUNISTIC = 1 << 6;
   1.124 +
   1.125 +    /**
   1.126 +     * URI of the manfiest specifying this application cache.
   1.127 +     **/
   1.128 +    readonly attribute nsIURI manifestURI;
   1.129 +
   1.130 +    /**
   1.131 +     * The group ID for this cache group.  It is an internally generated string
   1.132 +     * and cannot be used as manifest URL spec.
   1.133 +     **/
   1.134 +    readonly attribute ACString groupID;
   1.135 +
   1.136 +    /**
   1.137 +     * The client ID for this application cache.  Clients can open a
   1.138 +     * session with nsICacheService::createSession() using this client
   1.139 +     * ID and a storage policy of STORE_OFFLINE to access this cache.
   1.140 +     */
   1.141 +    readonly attribute ACString clientID;
   1.142 +
   1.143 +    /**
   1.144 +     * TRUE if the cache is the active cache for this group.
   1.145 +     */
   1.146 +    readonly attribute boolean active;
   1.147 +
   1.148 +    /**
   1.149 +     * The disk usage of the application cache, in bytes.
   1.150 +     */
   1.151 +    readonly attribute unsigned long usage;
   1.152 +
   1.153 +    /**
   1.154 +     * Makes this cache the active application cache for this group.
   1.155 +     * Future loads associated with this group will come from this
   1.156 +     * cache.  Other caches from this cache group will be deactivated.
   1.157 +     */
   1.158 +    void activate();
   1.159 +
   1.160 +    /**
   1.161 +     * Discard this application cache.  Removes all cached resources
   1.162 +     * for this cache.  If this is the active application cache for the
   1.163 +     * group, the group will be removed.
   1.164 +     */
   1.165 +    void discard();
   1.166 +
   1.167 +    /**
   1.168 +     * Adds item types to a given entry.
   1.169 +     */
   1.170 +    void markEntry(in ACString key, in unsigned long typeBits);
   1.171 +
   1.172 +    /**
   1.173 +     * Removes types from a given entry.  If the resulting entry has
   1.174 +     * no types left, the entry is removed.
   1.175 +     */
   1.176 +    void unmarkEntry(in ACString key, in unsigned long typeBits);
   1.177 +
   1.178 +    /**
   1.179 +     * Gets the types for a given entry.
   1.180 +     */
   1.181 +    unsigned long getTypes(in ACString key);
   1.182 +
   1.183 +    /**
   1.184 +     * Returns any entries in the application cache whose type matches
   1.185 +     * one or more of the bits in typeBits.
   1.186 +     */
   1.187 +    void gatherEntries(in uint32_t typeBits,
   1.188 +                       out unsigned long count,
   1.189 +                       [array, size_is(count)] out string keys);
   1.190 +
   1.191 +    /**
   1.192 +     * Add a set of namespace entries to the application cache.
   1.193 +     * @param namespaces
   1.194 +     *        An nsIArray of nsIApplicationCacheNamespace entries.
   1.195 +     */
   1.196 +    void addNamespaces(in nsIArray namespaces);
   1.197 +
   1.198 +    /**
   1.199 +     * Get the most specific namespace matching a given key.
   1.200 +     */
   1.201 +    nsIApplicationCacheNamespace getMatchingNamespace(in ACString key);
   1.202 +
   1.203 +    /**
   1.204 +     * If set, this offline cache is placed in a different directory
   1.205 +     * than the current application profile.
   1.206 +     */
   1.207 +    readonly attribute nsIFile profileDirectory;
   1.208 +};

mercurial