summaryrefslogtreecommitdiffstats
path: root/ui/file_manager
diff options
context:
space:
mode:
authorryoh <ryoh@chromium.org>2016-03-02 02:35:34 -0800
committerCommit bot <commit-bot@chromium.org>2016-03-02 10:37:42 +0000
commit7167267460ddd9485f6bffba6999fda15f4d07ac (patch)
treedfc6ffe9f10140e52956fad874c1df88f64177e2 /ui/file_manager
parent016b0bb5d7443a82f3422df93b2deeb739501835 (diff)
downloadchromium_src-7167267460ddd9485f6bffba6999fda15f4d07ac.zip
chromium_src-7167267460ddd9485f6bffba6999fda15f4d07ac.tar.gz
chromium_src-7167267460ddd9485f6bffba6999fda15f4d07ac.tar.bz2
Gallery: Load images sequentially, stop chunking loading requests.
BUG=577345 Review URL: https://codereview.chromium.org/1751423002 Cr-Commit-Position: refs/heads/master@{#378714}
Diffstat (limited to 'ui/file_manager')
-rw-r--r--ui/file_manager/gallery/js/gallery.js51
1 files changed, 17 insertions, 34 deletions
diff --git a/ui/file_manager/gallery/js/gallery.js b/ui/file_manager/gallery/js/gallery.js
index 13c0020..761a75b 100644
--- a/ui/file_manager/gallery/js/gallery.js
+++ b/ui/file_manager/gallery/js/gallery.js
@@ -368,19 +368,6 @@ Gallery.prototype.loadInternal_ = function(entries, selectedEntries) {
}
this.onSelection_();
- // Obtains max chank size.
- var maxChunkSize = 20;
- var volumeInfo = this.volumeManager_.getVolumeInfo(entries[0]);
- if (volumeInfo) {
- if (GalleryUtil.isOnMTPVolume(entries[0], this.volumeManager_))
- maxChunkSize = 1;
-
- if (volumeInfo.isReadOnly ||
- GalleryUtil.isOnMTPVolume(entries[0], this.volumeManager_)) {
- this.context_.readonlyDirName = volumeInfo.label;
- }
- }
-
// If items are empty, stop initialization.
if (items.length === 0) {
this.dataModel_.splice(0, this.dataModel_.length);
@@ -401,33 +388,29 @@ Gallery.prototype.loadInternal_ = function(entries, selectedEntries) {
// Use the self variable capture-by-closure because it is faster than bind.
var self = this;
var thumbnailModel = new ThumbnailModel(this.metadataModel_);
- var loadChunk = function() {
+ var loadNext = function(index) {
// Extract chunk.
- var chunk = items.splice(0, maxChunkSize);
- if (!chunk.length)
+ if (index >= items.length)
return;
- var entries = chunk.map(function(chunkItem) {
- return chunkItem.getEntry();
- });
- var metadataPromise = self.metadataModel_.get(
- entries, Gallery.PREFETCH_PROPERTY_NAMES);
- var thumbnailPromise = thumbnailModel.get(entries);
+ var item = items[index];
+ var entry = item.getEntry();
+ var metadataPromise = self.metadataModel_.get([entry],
+ Gallery.PREFETCH_PROPERTY_NAMES);
+ var thumbnailPromise = thumbnailModel.get([entry]);
return Promise.all([metadataPromise, thumbnailPromise]).then(
function(metadataLists) {
// Add items to the model.
- chunk.forEach(function(chunkItem, index) {
- chunkItem.setMetadataItem(metadataLists[0][index]);
- chunkItem.setThumbnailMetadataItem(metadataLists[1][index]);
-
- var event = new Event('content');
- event.item = chunkItem;
- event.oldEntry = chunkItem.getEntry();
- event.thumbnailChanged = true;
- self.dataModel_.dispatchEvent(event);
- });
+ item.setMetadataItem(metadataLists[0][0]);
+ item.setThumbnailMetadataItem(metadataLists[1][0]);
+
+ var event = new Event('content');
+ event.item = item;
+ event.oldEntry = entry;
+ event.thumbnailChanged = true;
+ self.dataModel_.dispatchEvent(event);
// Continue to load chunks.
- return loadChunk();
+ return loadNext(/* index */ index + 1);
});
};
// init modes before loading images.
@@ -454,7 +437,7 @@ Gallery.prototype.loadInternal_ = function(entries, selectedEntries) {
}
this.initialized_ = true;
}
- loadChunk().catch(function(error) {
+ loadNext(/* index */ 0).catch(function(error) {
console.error(error.stack || error);
});
};