Skip to content

Commit

Permalink
Revert "Revert "Don't cache suggestion or download thumbnails on low-…
Browse files Browse the repository at this point in the history
…memory devices.""

This reverts commit b087611.

Reason for revert: Not cause of test failure.

Original change's description:
> Revert "Don't cache suggestion or download thumbnails on low-memory devices."
> 
> This reverts commit 78ff44b.
> 
> Reason for revert: Suspect change braking tablet testers:
> https://uberchromegw.corp.google.com/i/chromium.android/builders/KitKat%20Tablet%20Tester
> 
> TileGridLayoutTest#testNumColumnsCalculatedEqualToMeasurement:
> java.lang.AssertionError: The calculated number of columns should be equal to the minimum number of columns across screen orientations. expected:<6> but was:<5>
> 
> Will reland if bots are not fixed.
> 
> Original change's description:
> > Don't cache suggestion or download thumbnails on low-memory devices.
> > 
> > Bug: 718925
> > Change-Id: Ie11a88d9864bf6e4a4e85f7dc15c4e4e01bb00fe
> > Reviewed-on: https://chromium-review.googlesource.com/574856
> > Reviewed-by: Maria Khomenko <mariakhomenko@chromium.org>
> > Reviewed-by: Theresa <twellington@chromium.org>
> > Commit-Queue: Bernhard Bauer <bauerb@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#488639}
> 
> TBR=bauerb@chromium.org,mariakhomenko@chromium.org,twellington@chromium.org
> 
> # Not skipping CQ checks because original CL landed > 1 day ago.
> 
> Bug: 718925
> Change-Id: I281ef5ea1430dac383eaaf11a63ce34db8ab45ab
> Reviewed-on: https://chromium-review.googlesource.com/583546
> Commit-Queue: Matthew Jones <mdjones@chromium.org>
> Reviewed-by: Matthew Jones <mdjones@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#489113}

TBR=bauerb@chromium.org,mariakhomenko@chromium.org,twellington@chromium.org,mdjones@chromium.org,sfiera@chromium.org

Change-Id: If5647bde5e90bf34bf96c6d4177e0eba1c1103eb
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 718925
Reviewed-on: https://chromium-review.googlesource.com/583794
Reviewed-by: Matthew Jones <mdjones@chromium.org>
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#489122}
  • Loading branch information
iotitan authored and Commit Bot committed Jul 24, 2017
1 parent 09a9c27 commit 7eaaf65
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.text.TextUtils;
import android.util.Pair;

import org.chromium.base.SysUtils;
import org.chromium.base.ThreadUtils;
import org.chromium.base.annotations.CalledByNative;

Expand Down Expand Up @@ -144,8 +145,10 @@ private void onThumbnailRetrieved(String filePath, @Nullable Bitmap bitmap) {

// We set the key pair to contain the required size instead of the minimal dimension so
// that future fetches of this thumbnail can recognise the key in the cache.
getBitmapCache().put(Pair.create(filePath, mCurrentRequest.getIconSize()),
Pair.create(bitmap, bitmap.getByteCount()));
if (!SysUtils.isLowEndDevice()) {
getBitmapCache().put(Pair.create(filePath, mCurrentRequest.getIconSize()),
Pair.create(bitmap, bitmap.getByteCount()));
}
mCurrentRequest.onThumbnailRetrieved(filePath, bitmap);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.Callback;
import org.chromium.base.Promise;
import org.chromium.base.SysUtils;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.compositor.layouts.ChromeAnimation;
Expand Down Expand Up @@ -357,8 +358,11 @@ public void onResult(Bitmap thumbnail) {
Drawable drawable = ThumbnailGradient.createDrawableWithGradientIfNeeded(
thumbnail, mThumbnailView.getResources());

// Store the bitmap to skip the download task next time we display this snippet.
mCapturedSuggestion.setThumbnail(mUiDelegate.getReferencePool().put(drawable));
// If the device has sufficient memory, store the image to skip the download task
// next time we display this snippet.
if (!SysUtils.isLowEndDevice()) {
mCapturedSuggestion.setThumbnail(mUiDelegate.getReferencePool().put(drawable));
}

// Check whether the suggestions currently displayed in the view holder is the same as
// the suggestion whose thumbnail we have just fetched.
Expand Down

0 comments on commit 7eaaf65

Please sign in to comment.