michael@0: /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: michael@0: interface nsIArray; michael@0: interface nsIFile; michael@0: interface nsIURI; michael@0: michael@0: /** michael@0: * Application caches can store a set of namespace entries that affect michael@0: * loads from the application cache. If a load from the cache fails michael@0: * to match an exact cache entry, namespaces entries will be searched michael@0: * for a substring match, and should be applied appropriately. michael@0: */ michael@0: [scriptable, uuid(96e4c264-2065-4ce9-93bb-43734c62c4eb)] michael@0: interface nsIApplicationCacheNamespace : nsISupports michael@0: { michael@0: /** michael@0: * Items matching this namespace can be fetched from the network michael@0: * when loading from this cache. The "data" attribute is unused. michael@0: */ michael@0: const unsigned long NAMESPACE_BYPASS = 1 << 0; michael@0: michael@0: /** michael@0: * Items matching this namespace can be fetched from the network michael@0: * when loading from this cache. If the load fails, the cache entry michael@0: * specified by the "data" attribute should be loaded instead. michael@0: */ michael@0: const unsigned long NAMESPACE_FALLBACK = 1 << 1; michael@0: michael@0: /** michael@0: * Items matching this namespace should be cached michael@0: * opportunistically. Successful toplevel loads of documents michael@0: * in this namespace should be placed in the application cache. michael@0: * Namespaces specifying NAMESPACE_OPPORTUNISTIC may also specify michael@0: * NAMESPACE_FALLBACK to supply a fallback entry. michael@0: */ michael@0: const unsigned long NAMESPACE_OPPORTUNISTIC = 1 << 2; michael@0: michael@0: /** michael@0: * Initialize the namespace. michael@0: */ michael@0: void init(in unsigned long itemType, michael@0: in ACString namespaceSpec, michael@0: in ACString data); michael@0: michael@0: /** michael@0: * The namespace type. michael@0: */ michael@0: readonly attribute unsigned long itemType; michael@0: michael@0: /** michael@0: * The prefix of this namespace. This should be the asciiSpec of the michael@0: * URI prefix. michael@0: */ michael@0: readonly attribute ACString namespaceSpec; michael@0: michael@0: /** michael@0: * Data associated with this namespace, such as a fallback. URI data should michael@0: * use the asciiSpec of the URI. michael@0: */ michael@0: readonly attribute ACString data; michael@0: }; michael@0: michael@0: /** michael@0: * Application caches store resources for offline use. Each michael@0: * application cache has a unique client ID for use with michael@0: * nsICacheService::openSession() to access the cache's entries. michael@0: * michael@0: * Each entry in the application cache can be marked with a set of michael@0: * types, as discussed in the WHAT-WG offline applications michael@0: * specification. michael@0: * michael@0: * All application caches with the same group ID belong to a cache michael@0: * group. Each group has one "active" cache that will service future michael@0: * loads. Inactive caches will be removed from the cache when they are michael@0: * no longer referenced. michael@0: */ michael@0: [scriptable, uuid(06568DAE-C374-4383-A122-0CC96C7177F2)] michael@0: interface nsIApplicationCache : nsISupports michael@0: { michael@0: /** michael@0: * Init this application cache instance to just hold the group ID and michael@0: * the client ID to work just as a handle to the real cache. Used on michael@0: * content process to simplify the application cache code. michael@0: */ michael@0: void initAsHandle(in ACString groupId, in ACString clientId); michael@0: michael@0: /** michael@0: * Entries in an application cache can be marked as one or more of michael@0: * the following types. michael@0: */ michael@0: michael@0: /* This item is the application manifest. */ michael@0: const unsigned long ITEM_MANIFEST = 1 << 0; michael@0: michael@0: /* This item was explicitly listed in the application manifest. */ michael@0: const unsigned long ITEM_EXPLICIT = 1 << 1; michael@0: michael@0: /* This item was navigated in a toplevel browsing context, and michael@0: * named this cache's group as its manifest. */ michael@0: const unsigned long ITEM_IMPLICIT = 1 << 2; michael@0: michael@0: /* This item was added by the dynamic scripting API */ michael@0: const unsigned long ITEM_DYNAMIC = 1 << 3; michael@0: michael@0: /* This item was listed in the application manifest, but named a michael@0: * different cache group as its manifest. */ michael@0: const unsigned long ITEM_FOREIGN = 1 << 4; michael@0: michael@0: /* This item was listed as a fallback entry. */ michael@0: const unsigned long ITEM_FALLBACK = 1 << 5; michael@0: michael@0: /* This item matched an opportunistic cache namespace and was michael@0: * cached accordingly. */ michael@0: const unsigned long ITEM_OPPORTUNISTIC = 1 << 6; michael@0: michael@0: /** michael@0: * URI of the manfiest specifying this application cache. michael@0: **/ michael@0: readonly attribute nsIURI manifestURI; michael@0: michael@0: /** michael@0: * The group ID for this cache group. It is an internally generated string michael@0: * and cannot be used as manifest URL spec. michael@0: **/ michael@0: readonly attribute ACString groupID; michael@0: michael@0: /** michael@0: * The client ID for this application cache. Clients can open a michael@0: * session with nsICacheService::createSession() using this client michael@0: * ID and a storage policy of STORE_OFFLINE to access this cache. michael@0: */ michael@0: readonly attribute ACString clientID; michael@0: michael@0: /** michael@0: * TRUE if the cache is the active cache for this group. michael@0: */ michael@0: readonly attribute boolean active; michael@0: michael@0: /** michael@0: * The disk usage of the application cache, in bytes. michael@0: */ michael@0: readonly attribute unsigned long usage; michael@0: michael@0: /** michael@0: * Makes this cache the active application cache for this group. michael@0: * Future loads associated with this group will come from this michael@0: * cache. Other caches from this cache group will be deactivated. michael@0: */ michael@0: void activate(); michael@0: michael@0: /** michael@0: * Discard this application cache. Removes all cached resources michael@0: * for this cache. If this is the active application cache for the michael@0: * group, the group will be removed. michael@0: */ michael@0: void discard(); michael@0: michael@0: /** michael@0: * Adds item types to a given entry. michael@0: */ michael@0: void markEntry(in ACString key, in unsigned long typeBits); michael@0: michael@0: /** michael@0: * Removes types from a given entry. If the resulting entry has michael@0: * no types left, the entry is removed. michael@0: */ michael@0: void unmarkEntry(in ACString key, in unsigned long typeBits); michael@0: michael@0: /** michael@0: * Gets the types for a given entry. michael@0: */ michael@0: unsigned long getTypes(in ACString key); michael@0: michael@0: /** michael@0: * Returns any entries in the application cache whose type matches michael@0: * one or more of the bits in typeBits. michael@0: */ michael@0: void gatherEntries(in uint32_t typeBits, michael@0: out unsigned long count, michael@0: [array, size_is(count)] out string keys); michael@0: michael@0: /** michael@0: * Add a set of namespace entries to the application cache. michael@0: * @param namespaces michael@0: * An nsIArray of nsIApplicationCacheNamespace entries. michael@0: */ michael@0: void addNamespaces(in nsIArray namespaces); michael@0: michael@0: /** michael@0: * Get the most specific namespace matching a given key. michael@0: */ michael@0: nsIApplicationCacheNamespace getMatchingNamespace(in ACString key); michael@0: michael@0: /** michael@0: * If set, this offline cache is placed in a different directory michael@0: * than the current application profile. michael@0: */ michael@0: readonly attribute nsIFile profileDirectory; michael@0: };