summaryrefslogtreecommitdiffstats
path: root/chromeos/disks
diff options
context:
space:
mode:
authorbenchan@chromium.org <benchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-22 04:07:26 +0000
committerbenchan@chromium.org <benchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-22 04:07:26 +0000
commit79ed457b7066e33d1b06916d1eced173dfdcc901 (patch)
tree8bf395ac882ba2c0f1d4e62acc2473176ea62ef5 /chromeos/disks
parente56da5b189a7843c9f94c9afaede1fccc73d5cd0 (diff)
downloadchromium_src-79ed457b7066e33d1b06916d1eced173dfdcc901.zip
chromium_src-79ed457b7066e33d1b06916d1eced173dfdcc901.tar.gz
chromium_src-79ed457b7066e33d1b06916d1eced173dfdcc901.tar.bz2
Read from CrosDisks to determine If a disk is on a removable device.
https://chromium-review.googlesource.com/207610 modified cros-disks to report, via the GetDeviceProperties DBus method, if a disk is on a removable device. This CL updates the CrosDisksClient to make sure of that. BUG=393345 TEST=Unit tests and manually tested a few removable USB/SD media. Review URL: https://codereview.chromium.org/391783002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284620 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/disks')
-rw-r--r--chromeos/disks/disk_mount_manager.cc3
-rw-r--r--chromeos/disks/disk_mount_manager.h5
-rw-r--r--chromeos/disks/disk_mount_manager_unittest.cc3
-rw-r--r--chromeos/disks/mock_disk_mount_manager.cc7
-rw-r--r--chromeos/disks/mock_disk_mount_manager.h3
5 files changed, 19 insertions, 2 deletions
diff --git a/chromeos/disks/disk_mount_manager.cc b/chromeos/disks/disk_mount_manager.cc
index a1f6db8..291263a 100644
--- a/chromeos/disks/disk_mount_manager.cc
+++ b/chromeos/disks/disk_mount_manager.cc
@@ -462,6 +462,7 @@ class DiskMountManagerImpl : public DiskMountManager {
disk_info.is_read_only(),
disk_info.has_media(),
disk_info.on_boot_device(),
+ disk_info.on_removable_device(),
disk_info.is_hidden());
disks_.insert(std::make_pair(disk_info.device_path(), disk));
NotifyDiskStatusUpdate(is_new ? DISK_ADDED : DISK_CHANGED, disk);
@@ -653,6 +654,7 @@ DiskMountManager::Disk::Disk(const std::string& device_path,
bool is_read_only,
bool has_media,
bool on_boot_device,
+ bool on_removable_device,
bool is_hidden)
: device_path_(device_path),
mount_path_(mount_path),
@@ -672,6 +674,7 @@ DiskMountManager::Disk::Disk(const std::string& device_path,
is_read_only_(is_read_only),
has_media_(has_media),
on_boot_device_(on_boot_device),
+ on_removable_device_(on_removable_device),
is_hidden_(is_hidden) {
}
diff --git a/chromeos/disks/disk_mount_manager.h b/chromeos/disks/disk_mount_manager.h
index 4f8862c..59f7d5a 100644
--- a/chromeos/disks/disk_mount_manager.h
+++ b/chromeos/disks/disk_mount_manager.h
@@ -69,6 +69,7 @@ class CHROMEOS_EXPORT DiskMountManager {
bool is_read_only,
bool has_media,
bool on_boot_device,
+ bool on_removable_device,
bool is_hidden);
~Disk();
@@ -134,6 +135,9 @@ class CHROMEOS_EXPORT DiskMountManager {
// Is the device on the boot device.
bool on_boot_device() const { return on_boot_device_; }
+ // Is the device on the removable device.
+ bool on_removable_device() const { return on_removable_device_; }
+
// Shoud the device be shown in the UI, or automounted.
bool is_hidden() const { return is_hidden_; }
@@ -162,6 +166,7 @@ class CHROMEOS_EXPORT DiskMountManager {
bool is_read_only_;
bool has_media_;
bool on_boot_device_;
+ bool on_removable_device_;
bool is_hidden_;
};
typedef std::map<std::string, Disk*> DiskMap;
diff --git a/chromeos/disks/disk_mount_manager_unittest.cc b/chromeos/disks/disk_mount_manager_unittest.cc
index fd2fab0..b7a8e49 100644
--- a/chromeos/disks/disk_mount_manager_unittest.cc
+++ b/chromeos/disks/disk_mount_manager_unittest.cc
@@ -41,6 +41,7 @@ struct TestDiskInfo {
bool is_read_only;
bool has_media;
bool on_boot_device;
+ bool on_removable_device;
bool is_hidden;
};
@@ -73,6 +74,7 @@ const TestDiskInfo kTestDisks[] = {
false, // is read only
true, // has media
false, // is on boot device
+ true, // is on removable device
false // is hidden
},
};
@@ -173,6 +175,7 @@ class DiskMountManagerTest : public testing::Test {
disk.is_read_only,
disk.has_media,
disk.on_boot_device,
+ disk.on_removable_device,
disk.is_hidden)));
}
diff --git a/chromeos/disks/mock_disk_mount_manager.cc b/chromeos/disks/mock_disk_mount_manager.cc
index a023b1a..f4bfce7 100644
--- a/chromeos/disks/mock_disk_mount_manager.cc
+++ b/chromeos/disks/mock_disk_mount_manager.cc
@@ -88,6 +88,7 @@ void MockDiskMountManager::NotifyDeviceInsertEvents() {
false, // is_read_only
true, // has_media
false, // on_boot_device
+ true, // on_removable_device
false)); // is_hidden
disks_.clear();
@@ -120,6 +121,7 @@ void MockDiskMountManager::NotifyDeviceInsertEvents() {
false, // is_read_only
true, // has_media
false, // on_boot_device
+ true, // on_removable_device
false)); // is_hidden
disks_.clear();
disks_.insert(std::pair<std::string, DiskMountManager::Disk*>(
@@ -147,6 +149,7 @@ void MockDiskMountManager::NotifyDeviceRemoveEvents() {
false, // is_read_only
true, // has_media
false, // on_boot_device
+ true, // on_removable_device
false)); // is_hidden
disks_.clear();
disks_.insert(std::pair<std::string, DiskMountManager::Disk*>(
@@ -187,7 +190,8 @@ void MockDiskMountManager::CreateDiskEntryForMountDevice(
uint64 total_size_in_bytes,
bool is_parent,
bool has_media,
- bool on_boot_device) {
+ bool on_boot_device,
+ bool on_removable_device) {
Disk* disk = new DiskMountManager::Disk(mount_info.source_path,
mount_info.mount_path,
std::string(), // system_path
@@ -206,6 +210,7 @@ void MockDiskMountManager::CreateDiskEntryForMountDevice(
false, // is_read_only
has_media,
on_boot_device,
+ on_removable_device,
false); // is_hidden
DiskMountManager::DiskMap::iterator it = disks_.find(mount_info.source_path);
if (it == disks_.end()) {
diff --git a/chromeos/disks/mock_disk_mount_manager.h b/chromeos/disks/mock_disk_mount_manager.h
index e00278ac..8593626 100644
--- a/chromeos/disks/mock_disk_mount_manager.h
+++ b/chromeos/disks/mock_disk_mount_manager.h
@@ -66,7 +66,8 @@ class MockDiskMountManager : public DiskMountManager {
uint64 total_size_in_bytes,
bool is_parent,
bool has_media,
- bool on_boot_device);
+ bool on_boot_device,
+ bool on_removable_device);
// Removes the fake disk entry associated with the mounted device. This
// function is primarily for StorageMonitorTest.