summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhidehiko@chromium.org <hidehiko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-27 08:07:56 +0000
committerhidehiko@chromium.org <hidehiko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-27 08:07:56 +0000
commitb4e501395a95c48335139b36ee3b9c917549e862 (patch)
tree20bcc8888362289f48b28218e5b5c2477d841094
parent2f7265c6c9feeb73d5432ef0021bfad598842297 (diff)
downloadchromium_src-b4e501395a95c48335139b36ee3b9c917549e862.zip
chromium_src-b4e501395a95c48335139b36ee3b9c917549e862.tar.gz
chromium_src-b4e501395a95c48335139b36ee3b9c917549e862.tar.bz2
Introduce root entry to VolumeInfo.
This CL introduces root entry into VolumeInfo. The resolving root entry should be lightweight (even for Drive file system, as we don't need to access to the server via network). This is the preparation to replace NavigationList's rootsList with volume info. BUG=268817 TEST=Ran browser_tests --gtest_filter="*FileSystemExtensionApiTest*:*FileManagerBrowserTest*:*FileBrowserPrivateApiTest*" and tested manually. Review URL: https://chromiumcodereview.appspot.com/23420002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@219739 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/resources/file_manager/js/volume_manager.js47
1 files changed, 31 insertions, 16 deletions
diff --git a/chrome/browser/resources/file_manager/js/volume_manager.js b/chrome/browser/resources/file_manager/js/volume_manager.js
index b00eb36..f7edcbc 100644
--- a/chrome/browser/resources/file_manager/js/volume_manager.js
+++ b/chrome/browser/resources/file_manager/js/volume_manager.js
@@ -9,6 +9,7 @@
* flush storage", or "mounted zip archive" etc.
*
* @param {string} mountPath Where the volume is mounted.
+ * @param {DirectoryEntry} root The root directory entry of this volume.
* @param {string} error The error if an error is found.
* @param {string} deviceType The type of device ('usb'|'sd'|'optical'|'mobile'
* |'unknown') (as defined in chromeos/disks/disk_mount_manager.cc).
@@ -16,21 +17,18 @@
* @param {boolean} isReadOnly True if the volume is read only.
* @constructor
*/
-function VolumeInfo(mountPath, error, deviceType, isReadOnly) {
+function VolumeInfo(mountPath, root, error, deviceType, isReadOnly) {
// TODO(hidehiko): This should include FileSystem instance.
- this.mountPath_ = mountPath;
- this.error_ = error;
- this.deviceType_ = deviceType;
- this.isReadOnly_ = !!isReadOnly;
+ this.mountPath = mountPath;
+ this.root = root;
+ this.error = error;
+ this.deviceType = deviceType;
+ this.isReadOnly = isReadOnly;
+
+ // VolumeInfo is immutable.
+ Object.freeze(this);
}
-VolumeInfo.prototype = {
- get mountPath() { return this.mountPath_; },
- get error() { return this.error_; },
- get deviceType() { return this.deviceType_; },
- get isReadOnly() { return this.isReadOnly_; },
-};
-
/**
* Utilities for volume manager implementation.
*/
@@ -93,10 +91,27 @@ volumeManagerUtil.createVolumeInfo = function(mountPath, error, callback) {
function(metadata) {
if (chrome.runtime.lastError && !error)
error = VolumeManager.Error.UNKNOWN;
- callback(new VolumeInfo(
- mountPath, error,
- metadata && metadata.deviceType,
- !!metadata && metadata.isReadOnly));
+
+ var deviceType = null;
+ var isReadOnly = false;
+ if (metadata) {
+ deviceType = metadata.deviceType;
+ isReadOnly = metadata.isReadOnly;
+ }
+
+ // TODO(hidehiko): After multi-filesystem is supported,
+ // FileSystem object holds its root entry. So, we won't need this
+ // resolving.
+ webkitResolveLocalFileSystemURL(
+ util.makeFilesystemUrl(mountPath),
+ function(entry) {
+ callback(new VolumeInfo(
+ mountPath, entry, error, deviceType, isReadOnly));
+ },
+ function(error) {
+ callback(new VolumeInfo(
+ mountPath, null, error, deviceType, isReadOnly));
+ });
});
};