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

Unified Diff: ui/file_manager/file_manager/background/js/import_history.js

Issue 2856533003: Add background-wide file metadata cache. (Closed)
Patch Set: Fix unit tests. Created 3 years, 7 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
Index: ui/file_manager/file_manager/background/js/import_history.js
diff --git a/ui/file_manager/file_manager/background/js/import_history.js b/ui/file_manager/file_manager/background/js/import_history.js
index aba2c16f454cc3be96b0e405c3f1d4a5d2e19c09..f507fd28782016aa8f68cbb2e3473863694df313 100644
--- a/ui/file_manager/file_manager/background/js/import_history.js
+++ b/ui/file_manager/file_manager/background/js/import_history.js
@@ -1011,3 +1011,37 @@ importer.RuntimeHistoryLoader.prototype.addHistoryLoadedListener =
function(listener) {
this.historyResolver_.promise.then(listener);
};
+
+/**
+ * @param {!FileEntry} fileEntry
+ * @return {!Promise<string>} Resolves with a "hashcode" consisting of
+ * just the last modified time and the file size.
+ */
+importer.createMetadataHashcode = function(fileEntry) {
+ return new Promise(
+ /**
+ * @param {function()} resolve
+ * @param {function()} reject
+ * @this {importer.PersistentImportHistory}
+ */
+ function(resolve, reject) {
+ getEntryMetadata(fileEntry).then(
+ /**
+ * @param {!Object} metadata
fukino 2017/06/01 03:37:46 Correct the indentation.
tetsui 2017/06/01 04:46:58 Done.
+ * @return {!Promise<string>}
+ * @this {importer.PersistentImportHistory}
+ */
+ function(metadata) {
+ if (!('modificationTime' in metadata)) {
+ reject('File entry missing "modificationTime" field.');
+ } else if (!('size' in metadata)) {
+ reject('File entry missing "size" field.');
+ } else {
+ var secondsSinceEpoch = importer.toSecondsFromEpoch(
+ metadata.modificationTime);
+ resolve(secondsSinceEpoch + '_' + metadata.size);
+ }
+ }.bind(this));
+ }.bind(this))
+ .catch(importer.getLogger().catcher('importer-common-create-hashcode'));
+};

Powered by Google App Engine
This is Rietveld 408576698