nsIApplicationCache 编辑

netwerk/base/public/nsIApplicationCache.idlScriptable This interface represents an application cache, which stores resources for offline use. 1.0 66 Introduced Gecko 1.9.1 Inherits from: nsISupports Last changed in Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)

Each application cache has a unique client ID for use with nsICacheService.openSession() method, to access the cache's entries.

Each entry in the cache can be marked with a set of types, specified in the Constants section.

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 are removed from the cache when no longer referenced.

Method overview

void activate();
void addNamespaces(in nsIArray namespaces);
void discard();
void gatherEntries(in PRUint32 typeBits, out unsigned long count, [array, size_is(count)] out string keys);
nsIApplicationCacheNamespace getMatchingNamespace(in ACString key);
unsigned long getTypes(in ACString key);
void initAsHandle(in ACString groupId, in ACString clientId);
void markEntry(in ACString key, in unsigned long typeBits);
void unmarkEntry(in ACString key, in unsigned long typeBits);

Attributes

AttributeTypeDescription
activebooleantrue if the cache is the active cache for this group, otherwise false. Read only.
clientIDACStringThe 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. Read only.
groupIDACStringThe group ID for this cache group. This is the URI of the cache manifest file. Read only.
usageunsigned longThe disk usage of the application cache, in bytes. Read only.

Constants

ConstantValueDescription
ITEM_MANIFEST1This item is the application manifest.
ITEM_EXPLICIT2This item was explicitly listed in the application manifest.
ITEM_IMPLICIT4This item was navigated to in a top level browsing context, and named this cache's group as its manifest.
ITEM_DYNAMIC8This item was added to the cache using the dynamic scripting API.
ITEM_FOREIGN16This item was listed in the application manifest, but named a different cache group as its manifest.
ITEM_FALLBACK32This item was listed as a fallback entry.
ITEM_OPPORTUNISTIC64This item matched an opportunistic cache namespace and was cached for that reason.

Methods

activate()

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();
Parameters

None.

addNamespaces()

Add a set of namespace entries to the application cache.

void addNamespaces(
  in nsIArray namespaces
);
Parameters
namespaces
An nsIArray of nsIApplicationCacheNamespace objects describing the namespaces to add to the cache.

discard()

Discards this application cache. This removes all resources it has cached. If this is the active application cache for the group, the group is removed.

void discard();
Parameters

None.

gatherEntries()

Returns a list of entries in the cache whose type matches one or more of the specified types.

void gatherEntries(
  in PRUint32 typeBits,
  out unsigned long count,
  [array, size_is(count)] out string keys
);
Parameters
typeBits
A bit field indicating the types against which to match. See Constants for a list of types.
count
On return, indicates how many matching entries were found.
keys
An array of the keys matching one or more of the types indicated by typeBits.

getMatchingNamespace()

Returns the most specific namespace matching a given key.

nsIApplicationCacheNamespace getMatchingNamespace(
  in ACString key
);
Parameters
key
The key for the cache entry whose most specific namespace is to be returned.
Return value

An nsIApplicationCacheNamespace object describing the most specific namespace matching the given key.

getTypes()

Gets the types for a given entry in the cache.

unsigned long getTypes(
  in ACString key
);
Parameters
key
The key for the cache entry whose types you wish to retrieve.
Return value

A bit field indicating the entry's types. See Constants for a list of types.

initAsHandle()

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
);
Parameters
groupId
Missing Description
clientId
Missing Description

markEntry()

Adds item types to a given entry.

void markEntry(
  in ACString key,
  in unsigned long typeBits
);
Parameters
key
The key for the cache entry to which to add types.
typeBits
A bit field indicating the types to add to the entry. See Constants for a list of types.

unmarkEntry()

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
);
Parameters
key
The key for the cache entry from which to remove types.
typeBits
A bit field indicating the types to remove from the entry. See Constants for a list of types.

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:79 次

字数:11518

最后编辑:8 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文