Commit 78ff44b8 authored by Bernhard Bauer's avatar Bernhard Bauer Committed by Commit Bot

Don't cache suggestion or download thumbnails on low-memory devices.

Bug: 718925
Change-Id: Ie11a88d9864bf6e4a4e85f7dc15c4e4e01bb00fe
Reviewed-on: https://chromium-review.googlesource.com/574856Reviewed-by: default avatarMaria Khomenko <mariakhomenko@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Bernhard Bauer <bauerb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488639}
parent 527bb24f
...@@ -12,6 +12,7 @@ import android.support.v4.util.LruCache; ...@@ -12,6 +12,7 @@ import android.support.v4.util.LruCache;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Pair; import android.util.Pair;
import org.chromium.base.SysUtils;
import org.chromium.base.ThreadUtils; import org.chromium.base.ThreadUtils;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
...@@ -144,8 +145,10 @@ public class ThumbnailProviderImpl implements ThumbnailProvider { ...@@ -144,8 +145,10 @@ public class ThumbnailProviderImpl implements ThumbnailProvider {
// We set the key pair to contain the required size instead of the minimal dimension so // 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. // that future fetches of this thumbnail can recognise the key in the cache.
getBitmapCache().put(Pair.create(filePath, mCurrentRequest.getIconSize()), if (!SysUtils.isLowEndDevice()) {
Pair.create(bitmap, bitmap.getByteCount())); getBitmapCache().put(Pair.create(filePath, mCurrentRequest.getIconSize()),
Pair.create(bitmap, bitmap.getByteCount()));
}
mCurrentRequest.onThumbnailRetrieved(filePath, bitmap); mCurrentRequest.onThumbnailRetrieved(filePath, bitmap);
} }
......
...@@ -25,6 +25,7 @@ import android.widget.TextView; ...@@ -25,6 +25,7 @@ import android.widget.TextView;
import org.chromium.base.ApiCompatibilityUtils; import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.Callback; import org.chromium.base.Callback;
import org.chromium.base.Promise; import org.chromium.base.Promise;
import org.chromium.base.SysUtils;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeFeatureList; import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.compositor.layouts.ChromeAnimation; import org.chromium.chrome.browser.compositor.layouts.ChromeAnimation;
...@@ -354,8 +355,12 @@ public class SuggestionsBinder { ...@@ -354,8 +355,12 @@ public class SuggestionsBinder {
mCapturedSuggestion.isArticle() ? ThumbnailUtils.OPTIONS_RECYCLE_INPUT : 0); mCapturedSuggestion.isArticle() ? ThumbnailUtils.OPTIONS_RECYCLE_INPUT : 0);
} }
// Store the bitmap to skip the download task next time we display this snippet. // If the device has sufficient memory, store the bitmap to skip the download task
mCapturedSuggestion.setThumbnailBitmap(mUiDelegate.getReferencePool().put(thumbnail)); // next time we display this snippet.
if (!SysUtils.isLowEndDevice()) {
mCapturedSuggestion.setThumbnailBitmap(
mUiDelegate.getReferencePool().put(thumbnail));
}
// Check whether the suggestions currently displayed in the view holder is the same as // Check whether the suggestions currently displayed in the view holder is the same as
// the suggestion whose thumbnail we have just fetched. // the suggestion whose thumbnail we have just fetched.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment