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

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

Issue 9379023: Tweaks for improving file manager performance (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix comment typo Created 8 years, 10 months 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/js/file_manager.js
diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js
index ce566b237d5e1a4fdc4a96bb49454ec02cb1942e..add59ae0c240fbc62c2f702ab688d706d6134832 100644
--- a/chrome/browser/resources/file_manager/js/file_manager.js
+++ b/chrome/browser/resources/file_manager/js/file_manager.js
@@ -482,7 +482,7 @@ FileManager.prototype = {
(this.dialogType_ == FileManager.DialogType.FULL_PAGE ||
this.dialogType_ == FileManager.DialogType.SELECT_OPEN_MULTI_FILE);
- this.table_.list.startBatchUpdates();
+ this.table_.startBatchUpdates();
this.grid_.startBatchUpdates();
this.initFileList_();
@@ -550,7 +550,7 @@ FileManager.prototype = {
this.createMetadataProvider_();
- this.table_.list.endBatchUpdates();
+ this.table_.endBatchUpdates();
this.grid_.endBatchUpdates();
metrics.recordInterval('Load.DOM');
@@ -761,7 +761,9 @@ FileManager.prototype = {
// TODO(dgozman): add "Add a drive" item.
this.rootsList_.dataModel = this.directoryModel_.rootsList;
- this.directoryModel_.updateRoots();
+ this.directoryModel_.updateRoots(function() {
+ self.rootsList_.endBatchUpdates();
+ });
};
FileManager.prototype.initGData_ = function() {
@@ -1400,6 +1402,14 @@ FileManager.prototype = {
* window has neither.
*/
FileManager.prototype.setupCurrentDirectory_ = function() {
+ // Avoid a bunch of intermediate list redraws while the data model is
+ // cleared and updated. Note that it may (or may not) be desirable to draw
+ // partial results as we get them, but today the DirectoryReader API
+ // generally returns all entries in one chunk so even without this batching
+ // we wouldn't have incremental updates.
+ this.table_.startBatchUpdates();
+ var onLoaded = this.table_.endBatchUpdates.bind(this.table_);
+
if (location.hash) {
// Location hash has the highest priority.
var path = decodeURI(location.hash.substr(1));
@@ -1415,10 +1425,15 @@ FileManager.prototype = {
this.document_.body.appendChild(shade);
function removeShade() { shade.parentNode.removeChild(shade) }
+ // Keep track of whether the path is identified as an existing leaf
+ // node. Note that onResolve is guaranteed to be called (exactly once)
+ // before onLoadedActivateLeaf.
+ var foundLeaf = true;
Rick Byers 2012/03/02 00:19:46 Here's where I handled the special 'onFileSelected
function onResolve(baseName, leafName, exists) {
if (!exists || leafName == '') {
// Non-existent file or a directory. Remove the shade immediately.
removeShade();
+ foundLeaf = false;
}
}
@@ -1426,33 +1441,38 @@ FileManager.prototype = {
// of urls instead of a selection. This will remove the need to wait
// until the selection is done.
var self = this;
- function onFileSelected() {
- self.dispatchDefaultTask_();
- setTimeout(removeShade, 1000);
+ function onLoadedActivateLeaf() {
+ onLoaded();
+ if (foundLeaf) {
+ self.dispatchDefaultTask_();
+ setTimeout(removeShade, 1000);
+ }
}
- this.directoryModel_.setupPath(path, onResolve, onFileSelected);
+ this.directoryModel_.setupPath(path, onLoadedActivateLeaf, onResolve);
+
return;
}
- this.directoryModel_.setupPath(path);
+ this.directoryModel_.setupPath(path, onLoaded);
return;
}
if (this.params_.defaultPath) {
var path = this.params_.defaultPath;
if (this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE) {
- this.directoryModel_.setupPath(path, function(basePath, leafName) {
- this.filenameInput_.value = leafName;
- this.selectDefaultPathInFilenameInput_();
- }.bind(this));
+ this.directoryModel_.setupPath(path, onLoaded,
+ function(basePath, leafName) {
+ this.filenameInput_.value = leafName;
+ this.selectDefaultPathInFilenameInput_();
+ }.bind(this));
return;
}
- this.directoryModel_.setupPath(path);
+ this.directoryModel_.setupPath(path, onLoaded);
return;
}
- this.directoryModel_.setupDefaultPath();
+ this.directoryModel_.setupDefaultPath(onLoaded);
};
/**
@@ -2401,7 +2421,11 @@ FileManager.prototype = {
// Even if something failed root list should be rescanned.
// Failed mounts can "give" us new devices which might be formatted,
// so we have to refresh root list then.
- self.directoryModel_.updateRoots(changeDirectoryTo);
+ self.directoryModel_.updateRoots(function() {
+ if (changeDirectoryTo) {
+ self.directoryModel_.changeDirectory(changeDirectoryTo);
+ }
+ });
});
};
« no previous file with comments | « chrome/browser/resources/file_manager/js/directory_model.js ('k') | chrome/browser/resources/shared/js/cr/ui/table.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698