Bug 1254663 - Process too-small downloaded icons to avoid multiple downloads r?sebastian draft
authorAndrzej Hunt <ahunt@mozilla.com>
Thu, 15 Sep 2016 14:52:55 -0700
changeset 414211 4bd8ef4d32d3274dfd895b906e854208b051d0ab
parent 414210 02dc468f30d658d8c5636057b85c74af274617a0
child 531393 95eae909f7accb6eafd4e5a0324f1a84ab3e4d61
push id29618
push userahunt@mozilla.com
push dateThu, 15 Sep 2016 21:56:06 +0000
reviewerssebastian
bugs1254663
milestone51.0a1
Bug 1254663 - Process too-small downloaded icons to avoid multiple downloads r?sebastian MozReview-Commit-ID: A9L9R0NwV1o
mobile/android/base/java/org/mozilla/gecko/icons/IconTask.java
--- a/mobile/android/base/java/org/mozilla/gecko/icons/IconTask.java
+++ b/mobile/android/base/java/org/mozilla/gecko/icons/IconTask.java
@@ -130,21 +130,26 @@ import java.util.concurrent.Callable;
 
                 logLoader(request, loader, response);
 
                 if (response != null) {
                     // Ignore icons that are less than 2/3 the requested size: we fallback
                     // to generated icons in this case. We want to do this here since the smaller
                     // icon may already be in memory, in which case we can skip directly to generated
                     // icons.
-
-                    // TODO: we should still store this smaller icon in memory / process it for those
-                    // requests where it is useful?
                     if (request.ignoreSmallIcons &&
                             response.getBitmap().getWidth() < 2 * request.targetSize / 3) {
+
+                        // Process the loaded icon to ensure that the icon is cached: the first load
+                        // will download the icon: if we don't store the icon on disk / in-memory,
+                        // then we will end up downloading the same (too-small) icon every time
+                        // an icon is requested, unless we put it in local storage first.
+                        // Our response will be discarded (and the generated response returned instead),
+                        // hence we don't need to care about any changes any of the processors might make.
+                        processIcon(request, response);
                         break;
                     }
 
                     return response;
                 }
             }
 
             request.moveToNextIcon();