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

Unified Diff: ui/file_manager/file_manager/foreground/js/metadata/metadata_cache_item.js

Issue 898533003: Files.app: Add createSnapshot, clone, hasFreashCache methods to metadata models. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 | ui/file_manager/file_manager/foreground/js/metadata/metadata_cache_item_unittest.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/file_manager/foreground/js/metadata/metadata_cache_item.js
diff --git a/ui/file_manager/file_manager/foreground/js/metadata/metadata_cache_item.js b/ui/file_manager/file_manager/foreground/js/metadata/metadata_cache_item.js
index 925941429246723e0e79762c43259ae300cf0721..5f39497756eadcef51946d8bcd8526139f45a2ec 100644
--- a/ui/file_manager/file_manager/foreground/js/metadata/metadata_cache_item.js
+++ b/ui/file_manager/file_manager/foreground/js/metadata/metadata_cache_item.js
@@ -99,6 +99,38 @@ MetadataCacheItem.prototype.get = function(names) {
};
/**
+ * Creates deep copy of the item.
+ * @return {!MetadataCacheItem}
+ */
+MetadataCacheItem.prototype.clone = function() {
+ var clonedItem = new MetadataCacheItem();
+ for (var name in this.properties_) {
+ var property = this.properties_[name];
+ clonedItem.properties_[name] = new MetadataCacheItemProperty();
+ clonedItem.properties_[name].value = property.value;
+ clonedItem.properties_[name].requestId = property.requestId;
+ clonedItem.properties_[name].state = property.state;
+ }
+ return clonedItem;
+};
+
+/**
+ * Returns whether all the given properties are fulfilled.
+ * @param {!Array<string>} names Property names.
+ * @return {boolean}
+ */
+MetadataCacheItem.prototype.hasFreshCache = function(names) {
+ for (var i = 0; i < names.length; i++) {
+ if (!(this.properties_[names[i]] &&
+ this.properties_[names[i]].state ===
+ MetadataCacheItemPropertyState.FULFILLED)) {
+ return false;
+ }
+ }
+ return true;
+};
+
+/**
* @enum {string}
*/
var MetadataCacheItemPropertyState = {
« no previous file with comments | « no previous file | ui/file_manager/file_manager/foreground/js/metadata/metadata_cache_item_unittest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698