Index: chrome/browser/resources/file_manager/js/image_editor/image_view.js |
diff --git a/chrome/browser/resources/file_manager/js/image_editor/image_view.js b/chrome/browser/resources/file_manager/js/image_editor/image_view.js |
index 075e628d923e584ab9c1b2ee26fc3201d55a611a..06bcf4a41bed215801bf7c210b47ff8f5bfd9de1 100644 |
--- a/chrome/browser/resources/file_manager/js/image_editor/image_view.js |
+++ b/chrome/browser/resources/file_manager/js/image_editor/image_view.js |
@@ -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_) |