| Index: chromeos/disks/disk_mount_manager.h
|
| diff --git a/chromeos/disks/disk_mount_manager.h b/chromeos/disks/disk_mount_manager.h
|
| index 0fe1a1ab0c0e640374ff543230ed57196b0ad884..895c6070bb8d32e75b0350c89b17cc670b95924a 100644
|
| --- a/chromeos/disks/disk_mount_manager.h
|
| +++ b/chromeos/disks/disk_mount_manager.h
|
| @@ -13,20 +13,6 @@
|
| namespace chromeos {
|
| namespace disks {
|
|
|
| -// Types of events DiskMountManager sends to its observers.
|
| -enum DiskMountManagerEventType {
|
| - MOUNT_DISK_ADDED,
|
| - MOUNT_DISK_REMOVED,
|
| - MOUNT_DISK_CHANGED,
|
| - MOUNT_DISK_MOUNTED,
|
| - MOUNT_DISK_UNMOUNTED,
|
| - MOUNT_DEVICE_ADDED,
|
| - MOUNT_DEVICE_REMOVED,
|
| - MOUNT_DEVICE_SCANNED,
|
| - MOUNT_FORMATTING_STARTED,
|
| - MOUNT_FORMATTING_FINISHED,
|
| -};
|
| -
|
| // Condition of mounted filesystem.
|
| enum MountCondition {
|
| MOUNT_CONDITION_NONE,
|
| @@ -38,12 +24,29 @@ enum MountCondition {
|
| // Other classes can add themselves as observers.
|
| class CHROMEOS_EXPORT DiskMountManager {
|
| public:
|
| - // Event type given to observers' MountCompleted method.
|
| + // Event types passed to the observers.
|
| + enum DiskEvent {
|
| + DISK_ADDED,
|
| + DISK_REMOVED,
|
| + DISK_CHANGED,
|
| + };
|
| +
|
| + enum DeviceEvent {
|
| + DEVICE_ADDED,
|
| + DEVICE_REMOVED,
|
| + DEVICE_SCANNED,
|
| + };
|
| +
|
| enum MountEvent {
|
| MOUNTING,
|
| UNMOUNTING,
|
| };
|
|
|
| + enum FormatEvent {
|
| + FORMAT_STARTED,
|
| + FORMAT_COMPLETED
|
| + };
|
| +
|
| // Used to house an instance of each found mount device.
|
| class Disk {
|
| public:
|
| @@ -196,16 +199,19 @@ class CHROMEOS_EXPORT DiskMountManager {
|
| public:
|
| virtual ~Observer() {}
|
|
|
| - // A function called when disk mount status is changed.
|
| - virtual void DiskChanged(DiskMountManagerEventType event,
|
| - const Disk* disk) = 0;
|
| - // A function called when device status is changed.
|
| - virtual void DeviceChanged(DiskMountManagerEventType event,
|
| + // Called when disk mount status is changed.
|
| + virtual void OnDiskEvent(DiskEvent event, const Disk* disk) = 0;
|
| + // Called when device status is changed.
|
| + virtual void OnDeviceEvent(DeviceEvent event,
|
| + const std::string& device_path) = 0;
|
| + // Called after a mount point has been mounted or unmounted.
|
| + virtual void OnMountEvent(MountEvent event,
|
| + MountError error_code,
|
| + const MountPointInfo& mount_info) = 0;
|
| + // Called on format process events.
|
| + virtual void OnFormatEvent(FormatEvent event,
|
| + FormatError error_code,
|
| const std::string& device_path) = 0;
|
| - // A function called after mount is completed.
|
| - virtual void MountCompleted(MountEvent event_type,
|
| - MountError error_code,
|
| - const MountPointInfo& mount_info) = 0;
|
| };
|
|
|
| virtual ~DiskMountManager() {}
|
| @@ -240,10 +246,6 @@ class CHROMEOS_EXPORT DiskMountManager {
|
| virtual void UnmountPath(const std::string& mount_path,
|
| UnmountOptions options) = 0;
|
|
|
| - // Formats device given its file path.
|
| - // Example: file_path: /dev/sdb1
|
| - virtual void FormatUnmountedDevice(const std::string& file_path) = 0;
|
| -
|
| // Formats Device given its mount path. Unmounts the device.
|
| // Example: mount_path: /media/VOLUME_LABEL
|
| virtual void FormatMountedDevice(const std::string& mount_path) = 0;
|
| @@ -254,6 +256,11 @@ class CHROMEOS_EXPORT DiskMountManager {
|
| UnmountDeviceRecursiveCallbackType callback,
|
| void* user_data) = 0;
|
|
|
| + // Used in tests to initialize the manager's disk and mount point sets.
|
| + // Default implementation does noting. It just fails.
|
| + virtual bool AddDiskForTest(Disk* disk);
|
| + virtual bool AddMountPointForTest(const MountPointInfo& mount_point);
|
| +
|
| // Returns corresponding string to |type| like "device" or "file".
|
| static std::string MountTypeToString(MountType type);
|
|
|
|
|