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

Side by Side 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.
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 <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 342
343 var showPreview = Prefs.previewimages && !("tooltip" in item); 343 var showPreview = Prefs.previewimages && !("tooltip" in item);
344 showPreview = showPreview && item.type == "IMAGE"; 344 showPreview = showPreview && item.type == "IMAGE";
345 showPreview = showPreview && (!filter || filter.disabled || filter instanceof WhitelistFilter); 345 showPreview = showPreview && (!filter || filter.disabled || filter instanceof WhitelistFilter);
346 E("tooltipPreviewBox").hidden = true; 346 E("tooltipPreviewBox").hidden = true;
347 if (showPreview) 347 if (showPreview)
348 { 348 {
349 if (!cacheStorage) 349 if (!cacheStorage)
350 { 350 {
351 let {Services} = Cu.import("resource://gre/modules/Services.jsm", null); 351 let {Services} = Cu.import("resource://gre/modules/Services.jsm", null);
352 // Cache v2 API is enabled by default starting with Gecko 32 352 let {LoadContextInfo} = Cu.import("resource://gre/modules/LoadContextInfo. jsm", null);
353 if (Services.vc.compare(Utils.platformVersion, "32.0a1") >= 0) 353 cacheStorage = Services.cache2.diskCacheStorage(LoadContextInfo.default, f alse);
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
354 {
355 let {LoadContextInfo} = Cu.import("resource://gre/modules/LoadContextInf o.jsm", null);
356 let loadContext = content.QueryInterface(Ci.nsIInterfaceRequestor)
357 .getInterface(Ci.nsIWebNavigation)
358 .QueryInterface(Ci.nsILoadContext);
359 cacheStorage = Services.cache2.diskCacheStorage(LoadContextInfo.fromLoad Context(loadContext, false), false);
360 }
361 else
362 cacheStorage = Services.cache.createSession("HTTP", Ci.nsICache.STORE_AN YWHERE, true);
363 } 354 }
364 355
365 let showTooltipPreview = function () 356 let showTooltipPreview = function ()
366 { 357 {
367 E("tooltipPreview").setAttribute("src", item.location); 358 E("tooltipPreview").setAttribute("src", item.location);
368 E("tooltipPreviewBox").hidden = false; 359 E("tooltipPreviewBox").hidden = false;
369 }; 360 };
370 try 361 try
371 { 362 {
372 if (Ci.nsICacheStorage && cacheStorage instanceof Ci.nsICacheStorage) 363 cacheStorage.asyncOpenURI(Utils.makeURI(item.location), "", Ci.nsICacheSto rage.OPEN_READONLY, {
373 { 364 onCacheEntryCheck: function (entry, appCache)
374 cacheStorage.asyncOpenURI(Utils.makeURI(item.location), "", Ci.nsICacheS torage.OPEN_READONLY, { 365 {
375 onCacheEntryCheck: function (entry, appCache) 366 return Ci.nsICacheEntryOpenCallback.ENTRY_WANTED;
376 { 367 },
377 return Ci.nsICacheEntryOpenCallback.ENTRY_WANTED; 368 onCacheEntryAvailable: function (entry, isNew, appCache, status)
378 }, 369 {
379 onCacheEntryAvailable: function (entry, isNew, appCache, status) 370 if (Components.isSuccessCode(status) && !isNew)
380 {
381 if (!isNew)
382 showTooltipPreview();
383 }
384 });
385 }
386 else
387 {
388 cacheStorage.asyncOpenCacheEntry(item.location, Ci.nsICache.ACCESS_READ, {
389 onCacheEntryAvailable: function(descriptor, accessGranted, status)
390 {
391 if (!descriptor)
392 return;
393 descriptor.close();
394 showTooltipPreview(); 371 showTooltipPreview();
395 }, 372 }
396 onCacheEntryDoomed: function(status) 373 });
397 {
398 }
399 });
400 }
401 } 374 }
402 catch (e) 375 catch (e)
403 { 376 {
404 Cu.reportError(e); 377 Cu.reportError(e);
405 } 378 }
406 } 379 }
407 } 380 }
408 381
409 const visual = { 382 const visual = {
410 OTHER: true, 383 OTHER: true,
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 return {tooltip: this.itemsDummyTooltip}; 1309 return {tooltip: this.itemsDummyTooltip};
1337 }, 1310 },
1338 1311
1339 invalidateItem: function(item) 1312 invalidateItem: function(item)
1340 { 1313 {
1341 let row = this.data.indexOf(item); 1314 let row = this.data.indexOf(item);
1342 if (row >= 0) 1315 if (row >= 0)
1343 this.boxObject.invalidateRow(row); 1316 this.boxObject.invalidateRow(row);
1344 } 1317 }
1345 } 1318 }
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