Commit 0bff4aef authored by Anand K. Mistry's avatar Anand K. Mistry Committed by Commit Bot

Use lazy unmount for read-only mount points.

A lazy unmount detaches the mount point immediately. Existing file
accesses will continue, but any new accesses will fail. For read-only
mounts, we do this because there are no changes to sync back to the
volume and therefore it is ok if the volume is removed without waiting
for the unmount.

Note, this doesn't take into account the safety of removing media that
should be "safely removed", such as hard disks.

BUG=789562,680903

Change-Id: I4dca06f825d5f3b4012bafa9a43e05bfe6455d23
Reviewed-on: https://chromium-review.googlesource.com/1184645Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Commit-Queue: Anand Mistry <amistry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585410}
parent c9522de8
......@@ -375,11 +375,19 @@ IN_PROC_BROWSER_TEST_F(FileManagerPrivateApiTest, Mount) {
// check that UnmountPath is really called with the same value.
EXPECT_CALL(*disk_mount_manager_mock_, UnmountPath(_, _, _))
.Times(0);
EXPECT_CALL(
*disk_mount_manager_mock_,
UnmountPath(chromeos::CrosDisksClient::GetRemovableDiskMountPoint()
.AppendASCII("mount_path1")
.AsUTF8Unsafe(),
chromeos::UNMOUNT_OPTIONS_NONE, _))
.Times(1);
EXPECT_CALL(*disk_mount_manager_mock_,
UnmountPath(
chromeos::CrosDisksClient::GetArchiveMountPoint().AppendASCII(
"archive_mount_path").AsUTF8Unsafe(),
chromeos::UNMOUNT_OPTIONS_NONE, _)).Times(1);
UnmountPath(chromeos::CrosDisksClient::GetArchiveMountPoint()
.AppendASCII("archive_mount_path")
.AsUTF8Unsafe(),
chromeos::UNMOUNT_OPTIONS_LAZY, _))
.Times(1);
ASSERT_TRUE(RunComponentExtensionTest("file_browser/mount_test"))
<< message_;
......
......@@ -225,8 +225,12 @@ bool FileManagerPrivateRemoveMountFunction::RunAsync() {
switch (volume->type()) {
case file_manager::VOLUME_TYPE_REMOVABLE_DISK_PARTITION:
case file_manager::VOLUME_TYPE_MOUNTED_ARCHIVE_FILE: {
chromeos::UnmountOptions unmount_options = chromeos::UNMOUNT_OPTIONS_NONE;
if (volume->is_read_only())
unmount_options = chromeos::UNMOUNT_OPTIONS_LAZY;
DiskMountManager::GetInstance()->UnmountPath(
volume->mount_path().value(), chromeos::UNMOUNT_OPTIONS_NONE,
volume->mount_path().value(), unmount_options,
DiskMountManager::UnmountPathCallback());
break;
}
......
......@@ -179,6 +179,14 @@ function validateObject(received, expected, name) {
chrome.test.runTests([
function removeMount() {
chrome.fileManagerPrivate.removeMount('removable:mount_path1');
// We actually check this one on C++ side. If MountLibrary.RemoveMount
// doesn't get called, test will fail.
chrome.test.succeed();
},
function removeMountArchive() {
chrome.fileManagerPrivate.removeMount('archive:archive_mount_path');
// We actually check this one on C++ side. If MountLibrary.RemoveMount
......
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