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, 8:54 a.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 cacheStorage = Services.cache2.diskCacheStorage(LoadContextInfo.fromLoad Context(
310 content.QueryInterface(Ci.nsIInterfaceRequestor)
311 .getInterface(Ci.nsIWebNavigation)
312 .QueryInterface(Ci.nsILoadContext), false), false);
Wladimir Palant 2014/07/04 18:09:00 Nit: The indentation here is strange, normally you
saroyanm 2014/07/04 19:32:12 Done.
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 ()
Wladimir Palant 2014/07/04 18:09:00 Please don't remove the parameters even if you don
saroyanm 2014/07/04 19:32:12 My bad.
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) {
329 if (!isNew) 333 if (!isNew)
330 showTooltipPreview(); 334 showTooltipPreview();
331 } 335 }
332 }); 336 });
333 } 337 }
334 else 338 else
335 { 339 {
336 cacheStorage.asyncOpenCacheEntry(item.location, Ci.nsICache.ACCESS_READ, { 340 cacheStorage.asyncOpenCacheEntry(item.location, Ci.nsICache.ACCESS_READ, {
337 onCacheEntryAvailable: function(descriptor, accessGranted, status) 341 onCacheEntryAvailable: function(descriptor)
338 { 342 {
339 if (!descriptor) 343 if (!descriptor)
340 return; 344 return;
341 descriptor.close(); 345 descriptor.close();
342 showTooltipPreview(); 346 showTooltipPreview();
343 }, 347 },
344 onCacheEntryDoomed: function(status) 348 onCacheEntryDoomed: function(status)
345 { 349 {
346 } 350 }
347 }); 351 });
(...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 return {tooltip: this.itemsDummyTooltip}; 1261 return {tooltip: this.itemsDummyTooltip};
1258 }, 1262 },
1259 1263
1260 invalidateItem: function(item) 1264 invalidateItem: function(item)
1261 { 1265 {
1262 let row = this.data.indexOf(item); 1266 let row = this.data.indexOf(item);
1263 if (row >= 0) 1267 if (row >= 0)
1264 this.boxObject.invalidateRow(row); 1268 this.boxObject.invalidateRow(row);
1265 } 1269 }
1266 } 1270 }
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