imgICache 编辑

image/public/imgICache.idlScriptable Please add a summary to this article. Inherits from: nsISupports Last changed in Gecko 1.8 (Firefox 1.5 / Thunderbird 1.5 / SeaMonkey 1.0)

As of Firefox 18, there is no longer a single image cache. That means that using getService in order to obtain it will yield incorrect results. Use the following snippet to obtain a relevant image cache for a given document or channel (where relevantDocument is a Document object that contains images you care about, or relevantChannel is an nsIChannel that is used for fetching images):

var tools = Components.classes["@mozilla.org/image/tools;1"].getService(Components.interfaces.imgITools);
var cache = tools.getImgCacheForDocument(relevantDocument);
// alternatively, tools.getImgCacheForChannel(relevantChannel)

If there is no relevant document or channel, null may be passed, but this will cause any image cache requests to use the permanent storage cache (ie. any images from windows in private browsing mode will not be present in the cache returned from a call with a null parameter).

Method overview

void clearCache(in boolean chrome);
nsIProperties findEntryProperties(in nsIURI uri);
void removeEntry(in nsIURI uri);

Methods

clearCache()

Evict images from the cache.

void clearCache(
  in boolean chrome
);
Parameters
chrome
If true, evict only chrome images. If false, evict everything except chrome images.

findEntryProperties()

Find Properties Used to get properties such as 'type' and 'content-disposition' 'type' is a nsISupportsCString containing the images' mime type such as 'image/png' 'content-disposition' will be a nsISupportsCString containing the header If you call this before any data has been loaded from a URI, it will succeed, but come back empty.

nsIProperties findEntryProperties(
  in nsIURI uri
);
Parameters
uri
The URI to look up.
Return value

null if the URL was not found in the cache.

removeEntry()

Evict images from the cache.

void removeEntry(
  in nsIURI uri
);
Parameters
uri
The URI to remove.
Exceptions thrown
NS_OK
If a uri was removed from the cache.
NS_ERROR_NOT_AVAILABLE
If a uri was unable to be removed from the cache.

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

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

发布评论

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

词条统计

浏览:52 次

字数:4262

最后编辑:8年前

编辑次数:0 次

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