Chromium Code Reviews| 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..d07a1c1d64218fa25d01107e28134cb1e06f4679 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,6 +603,8 @@ 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. |
| @@ -617,6 +619,16 @@ DirectoryContents.prototype.onNewEntries_ = function(entries) { |
| return; |
| } |
| + // TODO(yoshiki): Here we should fire the update event of changed |
| + // items. Currenyly we have a method this.fileList_.updateIndex() to |
|
mtomasz
2013/12/24 00:22:10
typo: Currently.
yoshiki
2014/01/08 08:08:31
Done.
|
| + // fire an event, but this method takes only 1 argument and invokes sort |
| + // one by one. It is obviously time wasting. Instead, we call sort |
| + // directory. |
| + // In future, we should implement a good method like updateIndexes and |
| + // use it here. |
| + var status = this.list_.sortStatus; |
| + this.list_.sort(status.field, status.direction); |
|
mtomasz
2013/12/24 00:22:10
Please check if it is not a performance killer for
mtomasz
2013/12/24 00:22:10
In 'scan-completed' handler in file_manager.js, th
yoshiki
2014/01/08 08:08:31
I agree. Done.
yoshiki
2014/01/08 08:08:31
This increases the number of executed sort and the
|
| + |
| cr.dispatchSimpleEvent(this, 'scan-updated'); |
| callback(); |
| }.bind(this)); |
| @@ -625,19 +637,6 @@ DirectoryContents.prototype.onNewEntries_ = function(entries) { |
| }; |
| /** |
| - * 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. |
| */ |