Commit 18c3488c authored by mtomasz@chromium.org's avatar mtomasz@chromium.org

Fixed cache eviction in Files.app's slide mode.

Sometimes, prefetching was fast, which caused evicting the image being loaded from cache. As a result, full resolution image was not being loaded properly. This patch addresses this issue by evicting the full-resolution cache in advance, before loading an image from cache. As a result, there is always a space for cache, so there is a guarantee that the image just fetched from cache will not be evicted by the image being prefetched.

TEST=Follow the bug's description.
BUG=227264


Review URL: https://chromiumcodereview.appspot.com/13775010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193324 0039d316-1c4b-4281-b951-d872f2087c98
parent b7cfc63c
......@@ -352,6 +352,11 @@ ImageView.prototype.load = function(url, metadata, effect,
video.load();
return;
}
// Cache has to be evicted in advance, so the returned cached image is not
// evicted later by the prefetched image.
this.contentCache_.evictLRU();
var cached = this.contentCache_.getItem(this.contentID_);
if (cached) {
displayMainImage(ImageView.LOAD_TYPE_CACHED_FULL,
......@@ -804,9 +809,6 @@ ImageView.Cache.prototype.putItem = function(id, item, opt_keepLRU) {
if ((pos >= 0) != (id in this.map_))
throw new Error('Inconsistent cache state');
if ((pos >= 0) && (item != this.map_[id]))
this.deleteItem_(this.map_[id]);
if (id in this.map_) {
if (!opt_keepLRU) {
// Move to the end (most recently used).
......@@ -818,6 +820,8 @@ ImageView.Cache.prototype.putItem = function(id, item, opt_keepLRU) {
this.order_.push(id);
}
if ((pos >= 0) && (item != this.map_[id]))
this.deleteItem_(this.map_[id]);
this.map_[id] = item;
if (this.order_.length > this.capacity_)
......
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