gecko/netwerk/base/public/nsIApplicationCache.idl

226 lines
7.7 KiB
Plaintext
Raw Normal View History

/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is nsIApplicationCache.idl.
*
* The Initial Developer of the Original Code is
* Mozilla Corporation.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Dave Camp <dcamp@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
interface nsIArray;
/**
* Application caches can store a set of namespace entries that affect
* loads from the application cache. If a load from the cache fails
* to match an exact cache entry, namespaces entries will be searched
* for a substring match, and should be applied appropriately.
*/
[scriptable, uuid(96e4c264-2065-4ce9-93bb-43734c62c4eb)]
interface nsIApplicationCacheNamespace : nsISupports
{
/**
* Items matching this namespace can be fetched from the network
* when loading from this cache. The "data" attribute is unused.
*/
const unsigned long NAMESPACE_BYPASS = 1 << 0;
/**
* Items matching this namespace can be fetched from the network
* when loading from this cache. If the load fails, the cache entry
* specified by the "data" attribute should be loaded instead.
*/
const unsigned long NAMESPACE_FALLBACK = 1 << 1;
/**
* Items matching this namespace should be cached
* opportunistically. Successful toplevel loads of documents
* in this namespace should be placed in the application cache.
* Namespaces specifying NAMESPACE_OPPORTUNISTIC may also specify
* NAMESPACE_FALLBACK to supply a fallback entry.
*/
const unsigned long NAMESPACE_OPPORTUNISTIC = 1 << 2;
/**
* Initialize the namespace.
*/
void init(in unsigned long itemType,
in ACString namespaceSpec,
in ACString data);
/**
* The namespace type.
*/
readonly attribute unsigned long itemType;
/**
* The prefix of this namespace. This should be the asciiSpec of the
* URI prefix.
*/
readonly attribute ACString namespaceSpec;
/**
* Data associated with this namespace, such as a fallback. URI data should
* use the asciiSpec of the URI.
*/
readonly attribute ACString data;
};
/**
* Application caches store resources for offline use. Each
* application cache has a unique client ID for use with
* nsICacheService::openSession() to access the cache's entries.
*
* Each entry in the application cache can be marked with a set of
* types, as discussed in the WHAT-WG offline applications
* specification.
*
* All application caches with the same group ID belong to a cache
* group. Each group has one "active" cache that will service future
* loads. Inactive caches will be removed from the cache when they are
* no longer referenced.
*/
[scriptable, uuid(32f83e3f-470c-4423-a86a-d35d1c215ccb)]
interface nsIApplicationCache : nsISupports
{
/**
* Init this application cache instance to just hold the group ID and
* the client ID to work just as a handle to the real cache. Used on
* content process to simplify the application cache code.
*/
void initAsHandle(in ACString groupId, in ACString clientId);
/**
* Entries in an application cache can be marked as one or more of
* the following types.
*/
/* This item is the application manifest. */
const unsigned long ITEM_MANIFEST = 1 << 0;
/* This item was explicitly listed in the application manifest. */
const unsigned long ITEM_EXPLICIT = 1 << 1;
/* This item was navigated in a toplevel browsing context, and
* named this cache's group as its manifest. */
const unsigned long ITEM_IMPLICIT = 1 << 2;
/* This item was added by the dynamic scripting API */
const unsigned long ITEM_DYNAMIC = 1 << 3;
/* This item was listed in the application manifest, but named a
* different cache group as its manifest. */
const unsigned long ITEM_FOREIGN = 1 << 4;
/* This item was listed as a fallback entry. */
const unsigned long ITEM_FALLBACK = 1 << 5;
/* This item matched an opportunistic cache namespace and was
* cached accordingly. */
const unsigned long ITEM_OPPORTUNISTIC = 1 << 6;
/**
* The group ID for this cache group. This is the URI of the
* manifest file.
**/
readonly attribute ACString groupID;
/**
* The client ID for this application cache. Clients can open a
* session with nsICacheService::createSession() using this client
* ID and a storage policy of STORE_OFFLINE to access this cache.
*/
readonly attribute ACString clientID;
/**
* TRUE if the cache is the active cache for this group.
*/
readonly attribute boolean active;
/**
* The disk usage of the application cache, in bytes.
*/
readonly attribute unsigned long usage;
/**
* Makes this cache the active application cache for this group.
* Future loads associated with this group will come from this
* cache. Other caches from this cache group will be deactivated.
*/
void activate();
/**
* Discard this application cache. Removes all cached resources
* for this cache. If this is the active application cache for the
* group, the group will be removed.
*/
void discard();
/**
* Adds item types to a given entry.
*/
void markEntry(in ACString key, in unsigned long typeBits);
/**
* Removes types from a given entry. If the resulting entry has
* no types left, the entry is removed.
*/
void unmarkEntry(in ACString key, in unsigned long typeBits);
/**
* Gets the types for a given entry.
*/
unsigned long getTypes(in ACString key);
/**
* Returns any entries in the application cache whose type matches
* one or more of the bits in typeBits.
*/
void gatherEntries(in PRUint32 typeBits,
out unsigned long count,
[array, size_is(count)] out string keys);
/**
* Add a set of namespace entries to the application cache.
* @param namespaces
* An nsIArray of nsIApplicationCacheNamespace entries.
*/
void addNamespaces(in nsIArray namespaces);
/**
* Get the most specific namespace matching a given key.
*/
nsIApplicationCacheNamespace getMatchingNamespace(in ACString key);
};