Commit 6d570115 authored by mtomasz@chromium.org's avatar mtomasz@chromium.org

Get rid of mountPath dependency in Files app.

This patch simplifies the code and removed the dependency on mount path, which was redundant after migrating to volume ids and file systems per volume.

TEST=Tested manually, mounted and unmounted a archive and a usb device.
BUG=341263

Review URL: https://codereview.chromium.org/181203002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255348 0039d316-1c4b-4281-b951-d872f2087c98
parent 39542ac9
...@@ -249,12 +249,6 @@ void BroadcastMountCompletedEvent( ...@@ -249,12 +249,6 @@ void BroadcastMountCompletedEvent(
profile, volume_info, &event.volume_metadata); profile, volume_info, &event.volume_metadata);
event.is_remounting = is_remounting; event.is_remounting = is_remounting;
if (!volume_info.mount_path.empty() &&
event.volume_metadata.mount_path.empty()) {
event.status =
file_browser_private::MOUNT_COMPLETED_STATUS_ERROR_PATH_UNMOUNTED;
}
BroadcastEvent( BroadcastEvent(
profile, profile,
file_browser_private::OnMountCompleted::kEventName, file_browser_private::OnMountCompleted::kEventName,
......
...@@ -127,15 +127,6 @@ void VolumeInfoToVolumeMetadata( ...@@ -127,15 +127,6 @@ void VolumeInfoToVolumeMetadata(
DCHECK(volume_metadata); DCHECK(volume_metadata);
DCHECK(!volume_info.mount_path.empty()); DCHECK(!volume_info.mount_path.empty());
// Convert mount point path to relative path with the external file system
// exposed within File API.
base::FilePath relative_mount_path;
if (ConvertAbsoluteFilePathToRelativeFileSystemPath(
profile, kFileManagerAppId, base::FilePath(volume_info.mount_path),
&relative_mount_path)) {
volume_metadata->mount_path = "/" + relative_mount_path.AsUTF8Unsafe();
}
volume_metadata->volume_id = volume_info.volume_id; volume_metadata->volume_id = volume_info.volume_id;
// TODO(kinaba): fill appropriate information once multi-profile support is // TODO(kinaba): fill appropriate information once multi-profile support is
......
...@@ -544,57 +544,61 @@ VolumeManager.prototype.initialize_ = function(callback) { ...@@ -544,57 +544,61 @@ VolumeManager.prototype.initialize_ = function(callback) {
*/ */
VolumeManager.prototype.onMountCompleted_ = function(event) { VolumeManager.prototype.onMountCompleted_ = function(event) {
this.mountQueue_.run(function(callback) { this.mountQueue_.run(function(callback) {
if (event.eventType === 'mount') { switch (event.eventType) {
var requestKey = this.makeRequestKey_( case 'mount':
'mount', var requestKey = this.makeRequestKey_(
event.volumeMetadata.sourcePath); 'mount',
event.volumeMetadata.sourcePath);
// TODO(mtomasz): Migrate to volumeId once possible.
if (event.volumeMetadata.mountPath) {
var error = event.status === 'success' ? '' : event.status; var error = event.status === 'success' ? '' : event.status;
volumeManagerUtil.createVolumeInfo( if (!error || event.status === 'error_unknown_filesystem') {
event.volumeMetadata, volumeManagerUtil.createVolumeInfo(
function(volumeInfo) { event.volumeMetadata,
this.volumeInfoList.add(volumeInfo); function(volumeInfo) {
this.finishRequest_(requestKey, event.status, volumeInfo); this.volumeInfoList.add(volumeInfo);
if (volumeInfo.volumeType === util.VolumeType.DRIVE) { this.finishRequest_(requestKey, event.status, volumeInfo);
// Update the network connection status, because until the
// drive is initialized, the status is set to not ready.
// TODO(hidehiko): The connection status should be migrated into
// VolumeMetadata.
this.onDriveConnectionStatusChanged_();
}
callback();
}.bind(this));
} else {
console.warn('No mount path.');
this.finishRequest_(requestKey, event.status);
callback();
}
} else if (event.eventType === 'unmount') {
var volumeId = event.volumeMetadata.volumeId;
var status = event.status;
if (status === util.VolumeError.PATH_UNMOUNTED) {
console.warn('Volume already unmounted: ', volumeId);
status = 'success';
}
var requestKey = this.makeRequestKey_('unmount', volumeId);
var requested = requestKey in this.requests_;
var volumeInfoIndex =
this.volumeInfoList.findIndex(volumeId);
var volumeInfo = volumeInfoIndex !== -1 ?
this.volumeInfoList.item(volumeInfoIndex) : null;
if (event.status === 'success' && !requested && volumeInfo) {
console.warn('Mounted volume without a request: ', volumeId);
var e = new Event('externally-unmounted');
e.volumeInfo = volumeInfo;
this.dispatchEvent(e);
}
this.finishRequest_(requestKey, status);
if (event.status === 'success') if (volumeInfo.volumeType === util.VolumeType.DRIVE) {
this.volumeInfoList.remove(event.volumeMetadata.volumeId); // Update the network connection status, because until the
callback(); // drive is initialized, the status is set to not ready.
// TODO(mtomasz): The connection status should be migrated
// into VolumeMetadata.
this.onDriveConnectionStatusChanged_();
}
callback();
}.bind(this));
} else {
console.warn('Failed to mount a volume: ' + event.status);
this.finishRequest_(requestKey, event.status);
callback();
}
break;
case 'unmount':
var volumeId = event.volumeMetadata.volumeId;
var status = event.status;
if (status === util.VolumeError.PATH_UNMOUNTED) {
console.warn('Volume already unmounted: ', volumeId);
status = 'success';
}
var requestKey = this.makeRequestKey_('unmount', volumeId);
var requested = requestKey in this.requests_;
var volumeInfoIndex =
this.volumeInfoList.findIndex(volumeId);
var volumeInfo = volumeInfoIndex !== -1 ?
this.volumeInfoList.item(volumeInfoIndex) : null;
if (event.status === 'success' && !requested && volumeInfo) {
console.warn('Mounted volume without a request: ' + volumeId);
var e = new Event('externally-unmounted');
e.volumeInfo = volumeInfo;
this.dispatchEvent(e);
}
this.finishRequest_(requestKey, status);
if (event.status === 'success')
this.volumeInfoList.remove(event.volumeMetadata.volumeId);
callback();
break;
} }
}.bind(this)); }.bind(this));
}; };
...@@ -706,7 +710,6 @@ VolumeManager.prototype.getLocationInfo = function(entry) { ...@@ -706,7 +710,6 @@ VolumeManager.prototype.getLocationInfo = function(entry) {
return null; return null;
} }
} else { } else {
// Otherwise, root path is same with a mount path of the volume.
switch (volumeInfo.volumeType) { switch (volumeInfo.volumeType) {
case util.VolumeType.DOWNLOADS: case util.VolumeType.DOWNLOADS:
rootType = RootType.DOWNLOADS; rootType = RootType.DOWNLOADS;
......
...@@ -42,8 +42,7 @@ function ImageLoader() { ...@@ -42,8 +42,7 @@ function ImageLoader() {
// Listen for mount events, and grant permissions to volumes being mounted. // Listen for mount events, and grant permissions to volumes being mounted.
chrome.fileBrowserPrivate.onMountCompleted.addListener( chrome.fileBrowserPrivate.onMountCompleted.addListener(
function(event) { function(event) {
// TODO(mtomasz): Get rid of mountPath when possible. if (event.eventType == 'mount' && event.status == 'success') {
if (event.eventType == 'mount' && event.volumeMetadata.mountPath) {
chrome.fileBrowserPrivate.requestFileSystem( chrome.fileBrowserPrivate.requestFileSystem(
event.volumeMetadata.volumeId, function() {}); event.volumeMetadata.volumeId, function() {});
} }
......
...@@ -212,12 +212,9 @@ dictionary VolumeMetadata { ...@@ -212,12 +212,9 @@ dictionary VolumeMetadata {
// Description of the profile where the volume belongs. // Description of the profile where the volume belongs.
// TODO(hirono): Remove the property because of the design change of // TODO(hirono): Remove the property because of the design change of
// multi-profile suuport. // multi-profile support.
ProfileInfo profile; ProfileInfo profile;
// Disk volume mount point path.
DOMString mountPath;
// The path to the mounted device, archive file or network resource. // The path to the mounted device, archive file or network resource.
DOMString? sourcePath; DOMString? sourcePath;
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
// These have to be sync'd with file_browser_private_apitest.cc // These have to be sync'd with file_browser_private_apitest.cc
var expectedVolume1 = { var expectedVolume1 = {
volumeId: 'removable:mount_path1', volumeId: 'removable:mount_path1',
mountPath: '/removable/mount_path1',
sourcePath: 'device_path1', sourcePath: 'device_path1',
volumeType: 'removable', volumeType: 'removable',
deviceType: 'usb', deviceType: 'usb',
...@@ -18,7 +17,6 @@ var expectedVolume1 = { ...@@ -18,7 +17,6 @@ var expectedVolume1 = {
var expectedVolume2 = { var expectedVolume2 = {
volumeId: 'removable:mount_path2', volumeId: 'removable:mount_path2',
mountPath: '/removable/mount_path2',
sourcePath: 'device_path2', sourcePath: 'device_path2',
volumeType: 'removable', volumeType: 'removable',
deviceType: 'mobile', deviceType: 'mobile',
...@@ -31,7 +29,6 @@ var expectedVolume2 = { ...@@ -31,7 +29,6 @@ var expectedVolume2 = {
var expectedVolume3 = { var expectedVolume3 = {
volumeId: 'removable:mount_path3', volumeId: 'removable:mount_path3',
mountPath: '/removable/mount_path3',
sourcePath: 'device_path3', sourcePath: 'device_path3',
volumeType: 'removable', volumeType: 'removable',
deviceType: 'optical', deviceType: 'optical',
...@@ -44,7 +41,6 @@ var expectedVolume3 = { ...@@ -44,7 +41,6 @@ var expectedVolume3 = {
var expectedDownloadsVolume = { var expectedDownloadsVolume = {
volumeId: /^downloads:Downloads[^\/]*$/, volumeId: /^downloads:Downloads[^\/]*$/,
mountPath: /^\/Downloads[^\/]*$/,
volumeType: 'downloads', volumeType: 'downloads',
isReadOnly: false, isReadOnly: false,
profile: {profileId: "", displayName: "", isCurrentProfile: true} profile: {profileId: "", displayName: "", isCurrentProfile: true}
...@@ -52,7 +48,6 @@ var expectedDownloadsVolume = { ...@@ -52,7 +48,6 @@ var expectedDownloadsVolume = {
var expectedDriveVolume = { var expectedDriveVolume = {
volumeId: /^drive:drive[^\/]*$/, volumeId: /^drive:drive[^\/]*$/,
mountPath: /^\/drive[^\/]*$/,
sourcePath: /^\/special\/drive[^\/]*$/, sourcePath: /^\/special\/drive[^\/]*$/,
volumeType: 'drive', volumeType: 'drive',
isReadOnly: false, isReadOnly: false,
...@@ -61,7 +56,6 @@ var expectedDriveVolume = { ...@@ -61,7 +56,6 @@ var expectedDriveVolume = {
var expectedArchiveVolume = { var expectedArchiveVolume = {
volumeId: 'archive:archive_mount_path', volumeId: 'archive:archive_mount_path',
mountPath: '/archive/archive_mount_path',
sourcePath: /removable\/mount_path3\/archive.zip$/, sourcePath: /removable\/mount_path3\/archive.zip$/,
volumeType: 'archive', volumeType: 'archive',
isReadOnly: true, isReadOnly: true,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment