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

Side by Side Diff: chrome/content/ui/sidebar.js

Issue 4875867805188096: issue #660 - HTTP cache api v2 fixes (Closed)
Patch Set: Created July 4, 2014, 7:24 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 if (requestNotifier) 193 if (requestNotifier)
194 requestNotifier.shutdown(); 194 requestNotifier.shutdown();
195 195
196 treeView.clearData(); 196 treeView.clearData();
197 treeView.itemToSelect = RequestNotifier.getSelection(window.content); 197 treeView.itemToSelect = RequestNotifier.getSelection(window.content);
198 requestNotifier = new RequestNotifier(window.content, function(wnd, node, item , scanComplete) 198 requestNotifier = new RequestNotifier(window.content, function(wnd, node, item , scanComplete)
199 { 199 {
200 if (item) 200 if (item)
201 treeView.addItem(node, item, scanComplete); 201 treeView.addItem(node, item, scanComplete);
202 }); 202 });
203 cacheStorage = null;
203 } 204 }
204 205
205 // Fills a box with text splitting it up into multiple lines if necessary 206 // Fills a box with text splitting it up into multiple lines if necessary
206 function setMultilineContent(box, text, noRemove) 207 function setMultilineContent(box, text, noRemove)
207 { 208 {
208 if (!noRemove) 209 if (!noRemove)
209 while (box.firstChild) 210 while (box.firstChild)
210 box.removeChild(box.firstChild); 211 box.removeChild(box.firstChild);
211 212
212 for (var i = 0; i < text.length; i += 80) 213 for (var i = 0; i < text.length; i += 80)
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 var showPreview = Prefs.previewimages && !("tooltip" in item); 296 var showPreview = Prefs.previewimages && !("tooltip" in item);
296 showPreview = showPreview && item.typeDescr == "IMAGE"; 297 showPreview = showPreview && item.typeDescr == "IMAGE";
297 showPreview = showPreview && (!item.filter || item.filter.disabled || item.fil ter instanceof WhitelistFilter); 298 showPreview = showPreview && (!item.filter || item.filter.disabled || item.fil ter instanceof WhitelistFilter);
298 E("tooltipPreviewBox").hidden = true; 299 E("tooltipPreviewBox").hidden = true;
299 if (showPreview) 300 if (showPreview)
300 { 301 {
301 if (!cacheStorage) 302 if (!cacheStorage)
302 { 303 {
303 let {Services} = Cu.import("resource://gre/modules/Services.jsm", null); 304 let {Services} = Cu.import("resource://gre/modules/Services.jsm", null);
304 // Cache v2 API is enabled by default starting with Gecko 32 305 // Cache v2 API is enabled by default starting with Gecko 32
305 if (Services.vc.compare(Utils.platformVersion, "32.0") >= 0) 306 if (Services.vc.compare(Utils.platformVersion, "32.0a1") >= 0)
306 { 307 {
307 let {LoadContextInfo} = Cu.import("resource://gre/modules/LoadContextInf o.jsm", null); 308 let {LoadContextInfo} = Cu.import("resource://gre/modules/LoadContextInf o.jsm", null);
308 cacheStorage = Services.cache2.diskCacheStorage(LoadContextInfo.default, true); 309 let loadContext = content.QueryInterface(Ci.nsIInterfaceRequestor)
310 .getInterface(Ci.nsIWebNavigation)
311 .QueryInterface(Ci.nsILoadContext);
312 cacheStorage = Services.cache2.diskCacheStorage(LoadContextInfo.fromLoad Context(loadContext, false), false);
309 } 313 }
310 else 314 else
311 cacheStorage = Services.cache.createSession("HTTP", Ci.nsICache.STORE_AN YWHERE, true); 315 cacheStorage = Services.cache.createSession("HTTP", Ci.nsICache.STORE_AN YWHERE, true);
312 } 316 }
313 317
314 let showTooltipPreview = function () 318 let showTooltipPreview = function ()
315 { 319 {
316 E("tooltipPreview").setAttribute("src", item.location); 320 E("tooltipPreview").setAttribute("src", item.location);
317 E("tooltipPreviewBox").hidden = false; 321 E("tooltipPreviewBox").hidden = false;
318 }; 322 };
319 try 323 try
320 { 324 {
321 if (Ci.nsICacheStorage && cacheStorage instanceof Ci.nsICacheStorage) 325 if (Ci.nsICacheStorage && cacheStorage instanceof Ci.nsICacheStorage)
322 { 326 {
323 cacheStorage.asyncOpenURI(Utils.makeURI(item.location), "", Ci.nsICacheS torage.OPEN_READONLY, { 327 cacheStorage.asyncOpenURI(Utils.makeURI(item.location), "", Ci.nsICacheS torage.OPEN_READONLY, {
324 onCacheEntryCheck: function (entry, appCache) 328 onCacheEntryCheck: function (entry, appCache)
325 { 329 {
326 return Ci.nsICacheEntryOpenCallback.ENTRY_WANTED; 330 return Ci.nsICacheEntryOpenCallback.ENTRY_WANTED;
327 }, 331 },
328 onCacheEntryAvailable: function (entry, isNew, appCache, status) { 332 onCacheEntryAvailable: function (entry, isNew, appCache, status)
333 {
329 if (!isNew) 334 if (!isNew)
330 showTooltipPreview(); 335 showTooltipPreview();
331 } 336 }
332 }); 337 });
333 } 338 }
334 else 339 else
335 { 340 {
336 cacheStorage.asyncOpenCacheEntry(item.location, Ci.nsICache.ACCESS_READ, { 341 cacheStorage.asyncOpenCacheEntry(item.location, Ci.nsICache.ACCESS_READ, {
337 onCacheEntryAvailable: function(descriptor, accessGranted, status) 342 onCacheEntryAvailable: function(descriptor, accessGranted, status)
338 { 343 {
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 return {tooltip: this.itemsDummyTooltip}; 1262 return {tooltip: this.itemsDummyTooltip};
1258 }, 1263 },
1259 1264
1260 invalidateItem: function(item) 1265 invalidateItem: function(item)
1261 { 1266 {
1262 let row = this.data.indexOf(item); 1267 let row = this.data.indexOf(item);
1263 if (row >= 0) 1268 if (row >= 0)
1264 this.boxObject.invalidateRow(row); 1269 this.boxObject.invalidateRow(row);
1265 } 1270 }
1266 } 1271 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld