Commit a8d56dec authored by fukino's avatar fukino Committed by Commit bot

Files.app: Mitigate performance issue on select-all by prefetching content mime type.

BUG=458915
TEST=Select 2000 photos by Ctrl+A and check that UI responds in less than 500ms.

Review URL: https://codereview.chromium.org/973483002

Cr-Commit-Position: refs/heads/master@{#318853}
parent 32b8f25c
...@@ -580,6 +580,11 @@ FileListContext.createPrefetchPropertyNames_ = function() { ...@@ -580,6 +580,11 @@ FileListContext.createPrefetchPropertyNames_ = function() {
for (var i = 0; i < Command.METADATA_PREFETCH_PROPERTY_NAMES.length; i++) { for (var i = 0; i < Command.METADATA_PREFETCH_PROPERTY_NAMES.length; i++) {
set[Command.METADATA_PREFETCH_PROPERTY_NAMES[i]] = true; set[Command.METADATA_PREFETCH_PROPERTY_NAMES[i]] = true;
} }
for (var i = 0;
i < FileSelection.METADATA_PREFETCH_PROPERTY_NAMES.length;
i++) {
set[FileSelection.METADATA_PREFETCH_PROPERTY_NAMES[i]] = true;
}
return Object.keys(set); return Object.keys(set);
}; };
......
...@@ -103,6 +103,17 @@ function FileSelection(fileManager, indexes) { ...@@ -103,6 +103,17 @@ function FileSelection(fileManager, indexes) {
} }
} }
/**
* Metadata property names used by FileSelection.
* These metadata is expected to be cached to accelerate completeInit() of
* FileSelection. crbug.com/458915.
* @const {!Array<string>}
*/
FileSelection.METADATA_PREFETCH_PROPERTY_NAMES = [
'availableOffline',
'contentMimeType',
];
/** /**
* Computes data required to get file tasks and requests the tasks. * Computes data required to get file tasks and requests the tasks.
* @return {!Promise} * @return {!Promise}
......
...@@ -1093,9 +1093,11 @@ FileTransferController.prototype.onFileSelectionChangedThrottled_ = function() { ...@@ -1093,9 +1093,11 @@ FileTransferController.prototype.onFileSelectionChangedThrottled_ = function() {
// asynchronous operations. // asynchronous operations.
if (!containsDirectory) { if (!containsDirectory) {
for (var i = 0; i < fileEntries.length; i++) { for (var i = 0; i < fileEntries.length; i++) {
fileEntries[i].file(function(data, file) { (function(fileEntry) {
data.file = file; fileEntry.file(function(file) {
}.bind(null, asyncData[fileEntries[i].toURL()])); asyncData[fileEntry.toURL()].file = file;
});
})(fileEntries[i]);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment