diff options
author | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-01 11:16:41 +0000 |
---|---|---|
committer | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-01 11:16:41 +0000 |
commit | df8c07449a2357a199cbd2949bbe4f6765768153 (patch) | |
tree | ce57d84b90878c39f4dd87bc8a9d428876c878ba | |
parent | 6e455808751ee47e0435ae70f9db742d269185d6 (diff) | |
download | chromium_src-df8c07449a2357a199cbd2949bbe4f6765768153.zip chromium_src-df8c07449a2357a199cbd2949bbe4f6765768153.tar.gz chromium_src-df8c07449a2357a199cbd2949bbe4f6765768153.tar.bz2 |
files: Stop computing a directory size when selected
Selecting a directory was expensive because Files.app computed the size of
a directory by recursively visiting all the sub directories and summing up
sizes of all files underneath. This is super expensive with a large directory
tree with thousands of directories and files underneath.
BUG=179000
TEST=Select a directory, size is not shown. Select a file, size is shown.
Review URL: https://chromiumcodereview.appspot.com/12379037
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@185527 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/resources/file_manager/js/file_selection.js | 32 | ||||
-rw-r--r-- | chrome/browser/resources/file_manager/js/util.js | 4 |
2 files changed, 21 insertions, 15 deletions
diff --git a/chrome/browser/resources/file_manager/js/file_selection.js b/chrome/browser/resources/file_manager/js/file_selection.js index ca78735..8796461 100644 --- a/chrome/browser/resources/file_manager/js/file_selection.js +++ b/chrome/browser/resources/file_manager/js/file_selection.js @@ -106,23 +106,25 @@ FileSelection.prototype.computeBytes = function(callback) { maybeDone(); }.bind(this); - var onEntry = function(entry) { - if (entry) { - if (entry.isFile) { - this.showBytes |= !FileType.isHosted(entry); - pendingMetadataCount++; - this.fileManager_.metadataCache_.get(entry, 'filesystem', onProps); - } - } else { - countdown--; - maybeDone(); - } - return !this.cancelled_; - }.bind(this); - for (var index = 0; index < this.entries.length; index++) { - util.forEachEntryInTree(this.entries[index], onEntry); + if (this.cancelled_) + break; + + var entry = this.entries[index]; + if (entry.isFile) { + this.showBytes |= !FileType.isHosted(entry); + pendingMetadataCount++; + this.fileManager_.metadataCache_.get(entry, 'filesystem', onProps); + } else if (entry.isDirectory) { + // Don't compute the directory size as it's expensive. + // crbug.com/179073. + this.showBytes = false; + countdown = 0; + break; + } + countdown--; } + maybeDone(); }; /** diff --git a/chrome/browser/resources/file_manager/js/util.js b/chrome/browser/resources/file_manager/js/util.js index 90c4f06..97999b3a 100644 --- a/chrome/browser/resources/file_manager/js/util.js +++ b/chrome/browser/resources/file_manager/js/util.js @@ -198,6 +198,8 @@ util.recurseAndResolveEntries = function(entries, recurse, successCallback) { /** * Utility function to invoke callback once for each entry in dirEntry. + * callback is called with 'null' after all entries are visited to indicate + * the end of the directory scan. * * @param {DirectoryEntry} dirEntry The directory entry to enumerate. * @param {function(Entry)} callback The function to invoke for each entry in @@ -643,6 +645,8 @@ util.traverseTree = function(root, callback, max_depth, opt_filter) { /** * Traverses a tree up to a certain depth, and calls a callback for each entry. + * callback is called with 'null' after all entries are visited to indicate + * the end of the traversal. * @param {FileEntry} root Root entry. * @param {function(Entry):boolean} callback The callback is called for each * entry, and then once with null passed. If callback returns false once, |