Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1646)

Unified Diff: chrome/browser/resources/file_manager/js/image_editor/image_view.js

Issue 13775010: Fixed cache eviction in Files.app's slide mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaned up. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698