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

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

Issue 9855024: Postpone connecting to GData even more, provide progress indication. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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/directory_model.js
diff --git a/chrome/browser/resources/file_manager/js/directory_model.js b/chrome/browser/resources/file_manager/js/directory_model.js
index aa3bfecebb92f75de2ea8dd23d76203f49e3dd23..24852b60bd3184075269c8b0f3098f2f705771bf 100644
--- a/chrome/browser/resources/file_manager/js/directory_model.js
+++ b/chrome/browser/resources/file_manager/js/directory_model.js
@@ -754,10 +754,11 @@ DirectoryModel.prototype = {
},
/**
- * Get root entries asynchronously. Invokes callback
- * when have finished.
+ * Get root entries asynchronously.
+ * @param {function(Array.<Entry>} callback Called when roots are resolved.
+ * @param {boolean} resolveGData See comment for updateRoots.
*/
- resolveRoots_: function(callback) {
+ resolveRoots_: function(callback, resolveGData) {
var groups = {
downloads: null,
archives: null,
@@ -807,6 +808,8 @@ DirectoryModel.prototype = {
console.log('onGDataError');
console.log(error);
self.unmountedGDataEntry_ = {
+ unmounted: true, // Clients use this field to distinguish a fake root.
+ toURL: function() { return '' },
fullPath: '/' + DirectoryModel.GDATA_DIRECTORY
};
groups.gdata = [self.unmountedGDataEntry_];
@@ -821,14 +824,23 @@ DirectoryModel.prototype = {
util.readDirectory(root, DirectoryModel.REMOVABLE_DIRECTORY,
append.bind(this, 'removables'));
if (this.showGData_) {
- root.getDirectory(DirectoryModel.GDATA_DIRECTORY, { create: false },
- onGData, onGDataError);
+ if (resolveGData) {
+ root.getDirectory(DirectoryModel.GDATA_DIRECTORY, { create: false },
+ onGData, onGDataError);
+ } else {
+ onGDataError('lazy mount');
+ }
} else {
groups.gdata = [];
}
},
- updateRoots: function(opt_callback) {
+ /**
+ * @param {function} opt_callback Called when all roots are resolved.
+ * @param {boolean} opt_resolveGData If true GData should be resolved for real,
+ * If false a stub entry should be created.
+ */
+ updateRoots: function(opt_callback, opt_resolveGData) {
console.log('directoryModel_.updateRoots');
var self = this;
this.resolveRoots_(function(rootEntries) {
@@ -842,7 +854,7 @@ DirectoryModel.prototype = {
if (opt_callback)
opt_callback();
- });
+ }, opt_resolveGData);
},
onRootsSelectionChanged_: function(event) {

Powered by Google App Engine
This is Rietveld 408576698