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

Unified Diff: chrome/browser/resources/file_manager/foreground/js/directory_contents.js

Issue 113293007: [Files.app] Change sort timing during metadata fetch (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years 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: chrome/browser/resources/file_manager/foreground/js/directory_contents.js
diff --git a/chrome/browser/resources/file_manager/foreground/js/directory_contents.js b/chrome/browser/resources/file_manager/foreground/js/directory_contents.js
index 919af1c248df660152c47bdff9228e7dbbda9ecb..8efc2fb9007f889c19cc879bca935004e1111d9e 100644
--- a/chrome/browser/resources/file_manager/foreground/js/directory_contents.js
+++ b/chrome/browser/resources/file_manager/foreground/js/directory_contents.js
@@ -458,7 +458,6 @@ function DirectoryContents(context, isSearch, directoryEntry,
this.scanner_ = null;
this.prefetchMetadataQueue_ = new AsyncUtil.Queue();
this.scanCancelled_ = false;
- this.fileList_.prepareSort = this.prepareSort_.bind(this);
}
/**
@@ -482,7 +481,7 @@ DirectoryContents.prototype.clone = function() {
*/
DirectoryContents.prototype.setFileList = function(fileList) {
this.fileList_ = fileList;
- this.fileList_.prepareSort = this.prepareSort_.bind(this);
+ this.context_.metadataCache.setCurrentContentNumber(this.fileList_.length);
};
/**
@@ -496,6 +495,7 @@ DirectoryContents.prototype.replaceContextFileList = function() {
spliceArgs.unshift(0, fileList.length);
fileList.splice.apply(fileList, spliceArgs);
this.fileList_ = fileList;
+ this.context_.metadataCache.setCurrentContentNumber(this.fileList_.length);
}
};
@@ -603,13 +603,15 @@ DirectoryContents.prototype.onNewEntries_ = function(entries) {
this.fileList_.push.apply(this.fileList_, entriesFiltered);
cr.dispatchSimpleEvent(this, 'scan-updated');
+ this.context_.metadataCache.setCurrentContentNumber(this.fileList_.length);
+
// Because the prefetchMetadata can be slow, throttling by splitting entries
// into smaller chunks to reduce UI latency.
// TODO(hidehiko,mtomasz): This should be handled in MetadataCache.
var MAX_CHUNK_SIZE = 50;
for (var i = 0; i < entriesFiltered.length; i += MAX_CHUNK_SIZE) {
var chunk = entriesFiltered.slice(i, i + MAX_CHUNK_SIZE);
- this.prefetchMetadataQueue_.run(function(chunk, callback) {
+ this.prefetchMetadataQueue_.run(function(i, chunk, callback) {
this.prefetchMetadata(chunk, function() {
if (this.scanCancelled_) {
// Do nothing if the scanning is cancelled.
@@ -617,27 +619,17 @@ DirectoryContents.prototype.onNewEntries_ = function(entries) {
return;
}
+ // Invoke an update event. It has the updated list sorted.
+ this.fileList_.updateIndex(i);
hirono 2013/12/17 11:35:15 How about the following? var status = this.list_.
yoshiki 2013/12/17 12:11:40 Done.
+
cr.dispatchSimpleEvent(this, 'scan-updated');
callback();
}.bind(this));
- }.bind(this, chunk));
+ }.bind(this, i, chunk));
}
};
/**
- * Cache necessary data before a sort happens.
- *
- * This is called by the table code before a sort happens, so that we can
- * go fetch data for the sort field that we may not have yet.
- * @param {string} field Sort field.
- * @param {function(Object)} callback Called when done.
- * @private
- */
-DirectoryContents.prototype.prepareSort_ = function(field, callback) {
- this.prefetchMetadata(this.fileList_.slice(), callback);
-};
-
-/**
* @param {Array.<Entry>} entries Files.
* @param {function(Object)} callback Callback on done.
*/

Powered by Google App Engine
This is Rietveld 408576698