Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: chrome/content/ui/sidebar.js

Issue 29333327: Issue 3491 - Fix cache handling for blockable items tooltip (Closed)
Patch Set: Created Jan. 7, 2016, 8:37 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/content/ui/sidebar.js
===================================================================
--- a/chrome/content/ui/sidebar.js
+++ b/chrome/content/ui/sidebar.js
@@ -344,65 +344,38 @@ function fillInTooltip(e) {
showPreview = showPreview && item.type == "IMAGE";
showPreview = showPreview && (!filter || filter.disabled || filter instanceof WhitelistFilter);
E("tooltipPreviewBox").hidden = true;
if (showPreview)
{
if (!cacheStorage)
{
let {Services} = Cu.import("resource://gre/modules/Services.jsm", null);
- // Cache v2 API is enabled by default starting with Gecko 32
- if (Services.vc.compare(Utils.platformVersion, "32.0a1") >= 0)
- {
- let {LoadContextInfo} = Cu.import("resource://gre/modules/LoadContextInfo.jsm", null);
- let loadContext = content.QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsIWebNavigation)
- .QueryInterface(Ci.nsILoadContext);
- cacheStorage = Services.cache2.diskCacheStorage(LoadContextInfo.fromLoadContext(loadContext, false), false);
- }
- else
- cacheStorage = Services.cache.createSession("HTTP", Ci.nsICache.STORE_ANYWHERE, true);
+ let {LoadContextInfo} = Cu.import("resource://gre/modules/LoadContextInfo.jsm", null);
+ cacheStorage = Services.cache2.diskCacheStorage(LoadContextInfo.default, false);
Thomas Greiner 2016/01/08 13:43:49 I noticed that we intentionally decided not to go
Wladimir Palant 2016/01/08 13:51:33 Please see my explanations in the description of t
Thomas Greiner 2016/01/08 14:12:26 The review description mentioned that we were usin
}
let showTooltipPreview = function ()
{
E("tooltipPreview").setAttribute("src", item.location);
E("tooltipPreviewBox").hidden = false;
};
try
{
- if (Ci.nsICacheStorage && cacheStorage instanceof Ci.nsICacheStorage)
- {
- cacheStorage.asyncOpenURI(Utils.makeURI(item.location), "", Ci.nsICacheStorage.OPEN_READONLY, {
- onCacheEntryCheck: function (entry, appCache)
- {
- return Ci.nsICacheEntryOpenCallback.ENTRY_WANTED;
- },
- onCacheEntryAvailable: function (entry, isNew, appCache, status)
- {
- if (!isNew)
- showTooltipPreview();
- }
- });
- }
- else
- {
- cacheStorage.asyncOpenCacheEntry(item.location, Ci.nsICache.ACCESS_READ, {
- onCacheEntryAvailable: function(descriptor, accessGranted, status)
- {
- if (!descriptor)
- return;
- descriptor.close();
+ cacheStorage.asyncOpenURI(Utils.makeURI(item.location), "", Ci.nsICacheStorage.OPEN_READONLY, {
+ onCacheEntryCheck: function (entry, appCache)
+ {
+ return Ci.nsICacheEntryOpenCallback.ENTRY_WANTED;
+ },
+ onCacheEntryAvailable: function (entry, isNew, appCache, status)
+ {
+ if (Components.isSuccessCode(status) && !isNew)
showTooltipPreview();
- },
- onCacheEntryDoomed: function(status)
- {
- }
- });
- }
+ }
+ });
}
catch (e)
{
Cu.reportError(e);
}
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld