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

Unified Diff: ui/file_manager/gallery/js/gallery_item.js

Issue 420743002: Gallery: Store image caches in Gallery items. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed. Created 6 years, 5 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 | « ui/file_manager/gallery/js/gallery.js ('k') | ui/file_manager/gallery/js/image_editor/image_view.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/gallery/js/gallery_item.js
diff --git a/ui/file_manager/gallery/js/gallery_item.js b/ui/file_manager/gallery/js/gallery_item.js
index 18c9c95043050a6a1e5a065cb6ac44b8a3cb17f7..96e0362d0f2fce9667dc6b44e984c28d2fcffbae 100644
--- a/ui/file_manager/gallery/js/gallery_item.js
+++ b/ui/file_manager/gallery/js/gallery_item.js
@@ -27,10 +27,34 @@ Gallery.Item = function(entry, metadata, metadataCache, original) {
/**
* @type {MetadataCache}
+ * @private
*/
this.metadataCache_ = metadataCache;
/**
+ * The content cache is used for prefetching the next image when going through
+ * the images sequentially. The real life photos can be large (18Mpix = 72Mb
+ * pixel array) so we want only the minimum amount of caching.
+ * @type {Canvas}
+ */
+ this.screenImage = null;
+
+ /**
+ * We reuse previously generated screen-scale images so that going back to a
+ * recently loaded image looks instant even if the image is not in the content
+ * cache any more. Screen-scale images are small (~1Mpix) so we can afford to
+ * cache more of them.
+ * @type {Canvas}
+ */
+ this.contentImage = null;
+
+ /**
+ * Last accessed date to be used for selecting items whose cache are evicted.
+ * @type {number}
+ */
+ this.lastAccessed_ = Date.now();
+
+ /**
* @type {boolean}
* @private
*/
@@ -90,6 +114,22 @@ Gallery.Item.prototype.getFileName = function() {
*/
Gallery.Item.prototype.isOriginal = function() { return this.original_; };
+/**
+ * Obtains the last accessed date.
+ * @return {number} Last accessed date.
+ */
+Gallery.Item.prototype.getLastAccessedDate = function() {
+ return this.lastAccessed_;
+};
+
+/**
+ * Updates the last accessed date.
+ */
+Gallery.Item.prototype.touch = function() {
+ return this.lastAccessed_ = Date.now();
mtomasz 2014/07/28 10:07:43 nit: Do we need to return?
hirono 2014/07/28 10:31:29 Done.
+};
+
+
// TODO: Localize?
/**
* @type {string} Suffix for a edited copy file name.
« no previous file with comments | « ui/file_manager/gallery/js/gallery.js ('k') | ui/file_manager/gallery/js/image_editor/image_view.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698