Index: chrome/browser/resources/file_manager/background/js/volume_manager.js |
diff --git a/chrome/browser/resources/file_manager/background/js/volume_manager.js b/chrome/browser/resources/file_manager/background/js/volume_manager.js |
index eeb58782213f2f3dd26eec62f777b27b18ac260f..dc4fef9f92a7039c3facd44ad5c53d966376f94b 100644 |
--- a/chrome/browser/resources/file_manager/background/js/volume_manager.js |
+++ b/chrome/browser/resources/file_manager/background/js/volume_manager.js |
@@ -35,35 +35,27 @@ function VolumeInfo( |
this.mountPath = mountPath; |
this.volumeId = volumeId; |
this.root = root; |
+ this.displayRoot = null; |
this.fakeEntries = {}; |
+ this.resolveQueue_ = new AsyncUtil.Queue(); |
if (volumeType === util.VolumeType.DRIVE) { |
- this.fakeEntries[RootType.DRIVE] = { |
- fullPath: RootDirectory.DRIVE + '/' + DriveSubRootDirectory.ROOT, |
- isDirectory: true, |
- rootType: RootType.DRIVE, |
- label: PathUtil.getRootLabel(RootType.DRIVE), |
- toURL: function() { return 'fake-entry://' + this.fullPath; } |
- }; |
this.fakeEntries[RootType.DRIVE_OFFLINE] = { |
fullPath: RootDirectory.DRIVE_OFFLINE, |
isDirectory: true, |
rootType: RootType.DRIVE_OFFLINE, |
- label: PathUtil.getRootLabel(RootType.DRIVE_OFFLINE), |
toURL: function() { return 'fake-entry://' + this.fullPath; } |
}; |
this.fakeEntries[RootType.DRIVE_SHARED_WITH_ME] = { |
fullPath: RootDirectory.DRIVE_SHARED_WITH_ME, |
isDirectory: true, |
rootType: RootType.DRIVE_SHARED_WITH_ME, |
- label: PathUtil.getRootLabel(RootType.DRIVE_SHARED_WITH_ME), |
toURL: function() { return 'fake-entry://' + this.fullPath; } |
}; |
this.fakeEntries[RootType.DRIVE_RECENT] = { |
fullPath: RootDirectory.DRIVE_RECENT, |
isDirectory: true, |
rootType: RootType.DRIVE_RECENT, |
- label: PathUtil.getRootLabel(RootType.DRIVE_RECENT), |
toURL: function() { return 'fake-entry://' + this.fullPath; } |
}; |
} |
@@ -76,20 +68,49 @@ function VolumeInfo( |
this.isReadOnly = isReadOnly; |
this.profile = Object.freeze(profile); |
- // VolumeInfo is immutable. |
- Object.freeze(this); |
+ Object.seal(this); |
yoshiki
2014/01/15 07:33:13
Since you're changing this class into non-immutabl
mtomasz
2014/01/16 01:31:58
Done.
|
} |
/** |
* Obtains a URL of the display root directory that users can see as a root. |
* @return {string} URL of root entry. |
+ * @private |
*/ |
-VolumeInfo.prototype.getDisplayRootDirectoryURL = function() { |
+VolumeInfo.prototype.getDisplayRootURL_ = function() { |
return this.root.toURL() + |
yoshiki
2014/01/15 07:33:13
I'm not sure but this.root seems null-able, so ple
mtomasz
2014/01/16 01:31:58
In general I think we should not have a volumeInfo
yoshiki
2014/01/17 01:57:52
Ok. Got it.
|
(this.volumeType === util.VolumeType.DRIVE ? '/root' : ''); |
}; |
/** |
+ * Obtains the display root of the entry. It may take long time for Drive. Once |
+ * resolved, it is cached. |
+ * |
+ * @param {function(DirectoryEntry)} onSuccess Success callback with the display |
+ * root directory as an argument. |
+ * @param {function(FileError)} onFailure Failure callback. |
+ */ |
+VolumeInfo.prototype.resolveDisplayRoot = function(onSuccess, onFailure) { |
yoshiki
2014/01/15 07:33:13
When on non-drive, can't we just use this.root?
mtomasz
2014/01/16 01:31:58
Done.
|
+ this.resolveQueue_.run(function(callback) { |
+ if (this.displayRoot) { |
+ onSuccess(this.displayRoot); |
+ callback(); |
+ return; |
+ } |
+ webkitResolveLocalFileSystemURL( |
+ this.getDisplayRootURL_(), function(directoryEntry) { |
+ console.log('found', directoryEntry); |
yoshiki
2014/01/15 07:33:13
nit: remove
mtomasz
2014/01/16 01:31:58
Done.
|
+ this.displayRoot = directoryEntry; |
+ onSuccess(directoryEntry); |
+ callback(); |
+ }.bind(this), function(fileError) { |
+ console.log('not found', fileError); |
yoshiki
2014/01/15 07:33:13
ditto
mtomasz
2014/01/16 01:31:58
Done.
|
+ onFailure(fileError); |
+ callback(); |
+ }.bind(this)); |
+ }.bind(this)); |
+}; |
+ |
+/** |
* Obtains volume label. |
* @return {string} Label for the volume. |
*/ |