[email protected] | 2321d28 | 2012-01-31 23:06:59 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 64e19925 | 2012-04-06 01:54:36 | [diff] [blame] | 5 | #ifndef CHROMEOS_DBUS_CROS_DISKS_CLIENT_H_ |
| 6 | #define CHROMEOS_DBUS_CROS_DISKS_CLIENT_H_ |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 7 | |
avi | 6e1a22d | 2015-12-21 03:43:20 | [diff] [blame] | 8 | #include <stdint.h> |
| 9 | |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 10 | #include <string> |
| 11 | #include <vector> |
| 12 | |
[email protected] | 5624a25 | 2013-07-04 03:17:53 | [diff] [blame] | 13 | #include "base/callback_forward.h" |
avi | 6e1a22d | 2015-12-21 03:43:20 | [diff] [blame] | 14 | #include "base/macros.h" |
[email protected] | 64e19925 | 2012-04-06 01:54:36 | [diff] [blame] | 15 | #include "chromeos/chromeos_export.h" |
[email protected] | c5fd536 | 2013-08-27 12:23:04 | [diff] [blame] | 16 | #include "chromeos/dbus/dbus_client.h" |
jamescook | 9be05a4 | 2016-09-19 19:09:49 | [diff] [blame] | 17 | #include "chromeos/dbus/dbus_client_implementation_type.h" |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 18 | |
[email protected] | a5a8b41 | 2013-03-04 15:03:11 | [diff] [blame] | 19 | namespace base { |
| 20 | class FilePath; |
| 21 | } |
| 22 | |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 23 | namespace dbus { |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 24 | class Response; |
| 25 | } |
| 26 | |
[email protected] | e3c1fc9 | 2012-11-15 00:56:46 | [diff] [blame] | 27 | // TODO(tbarzic): We should move these enums inside CrosDisksClient, |
| 28 | // to be clearer where they come from. Also, most of these are partially or |
| 29 | // completely duplicated in third_party/dbus/service_constants.h. We should |
| 30 | // probably use enums from service_contstants directly. |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 31 | namespace chromeos { |
| 32 | |
| 33 | // Enum describing types of mount used by cros-disks. |
| 34 | enum MountType { |
| 35 | MOUNT_TYPE_INVALID, |
| 36 | MOUNT_TYPE_DEVICE, |
| 37 | MOUNT_TYPE_ARCHIVE, |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 38 | }; |
| 39 | |
| 40 | // Type of device. |
| 41 | enum DeviceType { |
[email protected] | 2321d28 | 2012-01-31 23:06:59 | [diff] [blame] | 42 | DEVICE_TYPE_UNKNOWN, |
| 43 | DEVICE_TYPE_USB, // USB stick. |
| 44 | DEVICE_TYPE_SD, // SD card. |
[email protected] | f4ae40ac | 2012-05-04 21:57:00 | [diff] [blame] | 45 | DEVICE_TYPE_OPTICAL_DISC, // e.g. Optical disc excluding DVD. |
| 46 | DEVICE_TYPE_MOBILE, // Storage on a mobile device (e.g. Android). |
| 47 | DEVICE_TYPE_DVD, // DVD. |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | // Mount error code used by cros-disks. |
| 51 | enum MountError { |
| 52 | MOUNT_ERROR_NONE = 0, |
| 53 | MOUNT_ERROR_UNKNOWN = 1, |
| 54 | MOUNT_ERROR_INTERNAL = 2, |
[email protected] | e3c1fc9 | 2012-11-15 00:56:46 | [diff] [blame] | 55 | MOUNT_ERROR_INVALID_ARGUMENT = 3, |
| 56 | MOUNT_ERROR_INVALID_PATH = 4, |
| 57 | MOUNT_ERROR_PATH_ALREADY_MOUNTED = 5, |
| 58 | MOUNT_ERROR_PATH_NOT_MOUNTED = 6, |
| 59 | MOUNT_ERROR_DIRECTORY_CREATION_FAILED = 7, |
| 60 | MOUNT_ERROR_INVALID_MOUNT_OPTIONS = 8, |
| 61 | MOUNT_ERROR_INVALID_UNMOUNT_OPTIONS = 9, |
| 62 | MOUNT_ERROR_INSUFFICIENT_PERMISSIONS = 10, |
| 63 | MOUNT_ERROR_MOUNT_PROGRAM_NOT_FOUND = 11, |
| 64 | MOUNT_ERROR_MOUNT_PROGRAM_FAILED = 12, |
| 65 | MOUNT_ERROR_INVALID_DEVICE_PATH = 100, |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 66 | MOUNT_ERROR_UNKNOWN_FILESYSTEM = 101, |
[email protected] | a66a23cb | 2012-06-19 23:15:33 | [diff] [blame] | 67 | MOUNT_ERROR_UNSUPPORTED_FILESYSTEM = 102, |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 68 | MOUNT_ERROR_INVALID_ARCHIVE = 201, |
[email protected] | 9bb2422 | 2012-02-09 02:00:43 | [diff] [blame] | 69 | MOUNT_ERROR_NOT_AUTHENTICATED = 601, |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 70 | MOUNT_ERROR_PATH_UNMOUNTED = 901, |
| 71 | // TODO(tbarzic): Add more error codes as they get added to cros-disks and |
| 72 | // consider doing explicit translation from cros-disks error_types. |
| 73 | }; |
| 74 | |
Klemen Kozjek | bf5610f | 2017-08-25 20:20:09 | [diff] [blame^] | 75 | // Rename error reported by cros-disks. |
| 76 | enum RenameError { |
| 77 | RENAME_ERROR_NONE, |
| 78 | RENAME_ERROR_UNKNOWN, |
| 79 | RENAME_ERROR_INTERNAL, |
| 80 | RENAME_ERROR_INVALID_DEVICE_PATH, |
| 81 | RENAME_ERROR_DEVICE_BEING_RENAMED, |
| 82 | RENAME_ERROR_UNSUPPORTED_FILESYSTEM, |
| 83 | RENAME_ERROR_RENAME_PROGRAM_NOT_FOUND, |
| 84 | RENAME_ERROR_RENAME_PROGRAM_FAILED, |
| 85 | RENAME_ERROR_DEVICE_NOT_ALLOWED, |
| 86 | RENAME_ERROR_LONG_NAME, |
| 87 | RENAME_ERROR_INVALID_CHARACTER, |
| 88 | }; |
| 89 | |
[email protected] | e3c1fc9 | 2012-11-15 00:56:46 | [diff] [blame] | 90 | // Format error reported by cros-disks. |
| 91 | enum FormatError { |
| 92 | FORMAT_ERROR_NONE, |
| 93 | FORMAT_ERROR_UNKNOWN, |
| 94 | FORMAT_ERROR_INTERNAL, |
| 95 | FORMAT_ERROR_INVALID_DEVICE_PATH, |
| 96 | FORMAT_ERROR_DEVICE_BEING_FORMATTED, |
| 97 | FORMAT_ERROR_UNSUPPORTED_FILESYSTEM, |
| 98 | FORMAT_ERROR_FORMAT_PROGRAM_NOT_FOUND, |
| 99 | FORMAT_ERROR_FORMAT_PROGRAM_FAILED, |
| 100 | FORMAT_ERROR_DEVICE_NOT_ALLOWED, |
| 101 | }; |
| 102 | |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 103 | // Event type each corresponding to a signal sent from cros-disks. |
| 104 | enum MountEventType { |
[email protected] | e3c1fc9 | 2012-11-15 00:56:46 | [diff] [blame] | 105 | CROS_DISKS_DISK_ADDED, |
| 106 | CROS_DISKS_DISK_REMOVED, |
| 107 | CROS_DISKS_DISK_CHANGED, |
| 108 | CROS_DISKS_DEVICE_ADDED, |
| 109 | CROS_DISKS_DEVICE_REMOVED, |
| 110 | CROS_DISKS_DEVICE_SCANNED, |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 111 | }; |
| 112 | |
[email protected] | 10795ae | 2012-10-10 07:33:49 | [diff] [blame] | 113 | // Additional unmount flags to be added to unmount request. |
| 114 | enum UnmountOptions { |
| 115 | UNMOUNT_OPTIONS_NONE, |
| 116 | UNMOUNT_OPTIONS_LAZY, // Do lazy unmount. |
| 117 | }; |
| 118 | |
yamaguchi | 585d540 | 2016-08-02 09:27:36 | [diff] [blame] | 119 | // Mount option to control write permission to a device. |
| 120 | enum MountAccessMode { |
| 121 | MOUNT_ACCESS_MODE_READ_WRITE, |
| 122 | MOUNT_ACCESS_MODE_READ_ONLY, |
| 123 | }; |
| 124 | |
yamaguchi | fa8efc7 | 2016-10-21 15:05:51 | [diff] [blame] | 125 | // Whether to mount to a new path or remount a device already mounted. |
| 126 | enum RemountOption { |
| 127 | // Mount a new device. If the device is already mounted, the mount status is |
| 128 | // unchanged and the callback for MountCompleted will receive |
| 129 | // MOUNT_ERROR_PATH_ALREADY_MOUNTED error code. |
| 130 | REMOUNT_OPTION_MOUNT_NEW_DEVICE, |
| 131 | // Remount a device that is already mounted. If the device is not mounted |
| 132 | // yet, it will do nothing and the callback for MountCompleted will receive |
| 133 | // MOUNT_ERROR_PATH_NOT_MOUNTED error code. |
| 134 | REMOUNT_OPTION_REMOUNT_EXISTING_DEVICE, |
| 135 | }; |
| 136 | |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 137 | // A class to represent information about a disk sent from cros-disks. |
[email protected] | daf0f6d | 2013-07-08 06:42:33 | [diff] [blame] | 138 | class CHROMEOS_EXPORT DiskInfo { |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 139 | public: |
| 140 | DiskInfo(const std::string& device_path, dbus::Response* response); |
| 141 | ~DiskInfo(); |
| 142 | |
| 143 | // Device path. (e.g. /sys/devices/pci0000:00/.../8:0:0:0/block/sdb/sdb1) |
[email protected] | 85b95a201 | 2012-08-07 18:57:27 | [diff] [blame] | 144 | const std::string& device_path() const { return device_path_; } |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 145 | |
| 146 | // Disk mount path. (e.g. /media/removable/VOLUME) |
[email protected] | 85b95a201 | 2012-08-07 18:57:27 | [diff] [blame] | 147 | const std::string& mount_path() const { return mount_path_; } |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 148 | |
| 149 | // Disk system path given by udev. |
| 150 | // (e.g. /sys/devices/pci0000:00/.../8:0:0:0/block/sdb/sdb1) |
[email protected] | 85b95a201 | 2012-08-07 18:57:27 | [diff] [blame] | 151 | const std::string& system_path() const { return system_path_; } |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 152 | |
| 153 | // Is a drive or not. (i.e. true with /dev/sdb, false with /dev/sdb1) |
| 154 | bool is_drive() const { return is_drive_; } |
| 155 | |
| 156 | // Does the disk have media content. |
| 157 | bool has_media() const { return has_media_; } |
| 158 | |
[email protected] | d776059 | 2014-05-16 07:57:52 | [diff] [blame] | 159 | // Is the disk on device we booted the machine from. |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 160 | bool on_boot_device() const { return on_boot_device_; } |
| 161 | |
[email protected] | 79ed457b | 2014-07-22 04:07:26 | [diff] [blame] | 162 | // Is the disk on a removable device. |
| 163 | bool on_removable_device() const { return on_removable_device_; } |
| 164 | |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 165 | // Disk file path (e.g. /dev/sdb). |
[email protected] | 85b95a201 | 2012-08-07 18:57:27 | [diff] [blame] | 166 | const std::string& file_path() const { return file_path_; } |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 167 | |
| 168 | // Disk label. |
[email protected] | 85b95a201 | 2012-08-07 18:57:27 | [diff] [blame] | 169 | const std::string& label() const { return label_; } |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 170 | |
[email protected] | 202e9fee | 2012-09-13 20:21:29 | [diff] [blame] | 171 | // Vendor ID of the device (e.g. "18d1"). |
| 172 | const std::string& vendor_id() const { return vendor_id_; } |
| 173 | |
| 174 | // Vendor name of the device (e.g. "Google Inc."). |
| 175 | const std::string& vendor_name() const { return vendor_name_; } |
| 176 | |
| 177 | // Product ID of the device (e.g. "4e11"). |
| 178 | const std::string& product_id() const { return product_id_; } |
| 179 | |
| 180 | // Product name of the device (e.g. "Nexus One"). |
| 181 | const std::string& product_name() const { return product_name_; } |
| 182 | |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 183 | // Disk model. (e.g. "TransMemory") |
[email protected] | 85b95a201 | 2012-08-07 18:57:27 | [diff] [blame] | 184 | const std::string& drive_label() const { return drive_model_; } |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 185 | |
| 186 | // Device type. Not working well, yet. |
| 187 | DeviceType device_type() const { return device_type_; } |
| 188 | |
| 189 | // Total size of the disk in bytes. |
avi | 6e1a22d | 2015-12-21 03:43:20 | [diff] [blame] | 190 | uint64_t total_size_in_bytes() const { return total_size_in_bytes_; } |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 191 | |
| 192 | // Is the device read-only. |
| 193 | bool is_read_only() const { return is_read_only_; } |
| 194 | |
| 195 | // Returns true if the device should be hidden from the file browser. |
| 196 | bool is_hidden() const { return is_hidden_; } |
| 197 | |
[email protected] | 9c5620d3 | 2012-07-31 01:00:38 | [diff] [blame] | 198 | // Returns file system uuid. |
[email protected] | 85b95a201 | 2012-08-07 18:57:27 | [diff] [blame] | 199 | const std::string& uuid() const { return uuid_; } |
[email protected] | 9c5620d3 | 2012-07-31 01:00:38 | [diff] [blame] | 200 | |
Klemen Kozjek | 46f1c619 | 2017-08-25 19:20:54 | [diff] [blame] | 201 | // Returns file system type identifier. |
| 202 | const std::string& file_system_type() const { return file_system_type_; } |
| 203 | |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 204 | private: |
| 205 | void InitializeFromResponse(dbus::Response* response); |
| 206 | |
| 207 | std::string device_path_; |
| 208 | std::string mount_path_; |
| 209 | std::string system_path_; |
| 210 | bool is_drive_; |
| 211 | bool has_media_; |
| 212 | bool on_boot_device_; |
[email protected] | 79ed457b | 2014-07-22 04:07:26 | [diff] [blame] | 213 | bool on_removable_device_; |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 214 | |
| 215 | std::string file_path_; |
| 216 | std::string label_; |
[email protected] | 202e9fee | 2012-09-13 20:21:29 | [diff] [blame] | 217 | std::string vendor_id_; |
| 218 | std::string vendor_name_; |
| 219 | std::string product_id_; |
| 220 | std::string product_name_; |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 221 | std::string drive_model_; |
| 222 | DeviceType device_type_; |
avi | 6e1a22d | 2015-12-21 03:43:20 | [diff] [blame] | 223 | uint64_t total_size_in_bytes_; |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 224 | bool is_read_only_; |
| 225 | bool is_hidden_; |
[email protected] | 9c5620d3 | 2012-07-31 01:00:38 | [diff] [blame] | 226 | std::string uuid_; |
Klemen Kozjek | 46f1c619 | 2017-08-25 19:20:54 | [diff] [blame] | 227 | std::string file_system_type_; |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 228 | }; |
| 229 | |
[email protected] | d776059 | 2014-05-16 07:57:52 | [diff] [blame] | 230 | // A struct to represent information about a mount point sent from cros-disks. |
| 231 | struct CHROMEOS_EXPORT MountEntry { |
| 232 | public: |
| 233 | MountEntry() |
| 234 | : error_code_(MOUNT_ERROR_UNKNOWN), mount_type_(MOUNT_TYPE_INVALID) { |
| 235 | } |
| 236 | |
| 237 | MountEntry(MountError error_code, |
| 238 | const std::string& source_path, |
| 239 | MountType mount_type, |
| 240 | const std::string& mount_path) |
| 241 | : error_code_(error_code), |
| 242 | source_path_(source_path), |
| 243 | mount_type_(mount_type), |
| 244 | mount_path_(mount_path) { |
| 245 | } |
| 246 | |
| 247 | MountError error_code() const { return error_code_; } |
| 248 | const std::string& source_path() const { return source_path_; } |
| 249 | MountType mount_type() const { return mount_type_; } |
| 250 | const std::string& mount_path() const { return mount_path_; } |
| 251 | |
| 252 | private: |
| 253 | MountError error_code_; |
| 254 | std::string source_path_; |
| 255 | MountType mount_type_; |
| 256 | std::string mount_path_; |
| 257 | }; |
| 258 | |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 259 | // A class to make the actual DBus calls for cros-disks service. |
| 260 | // This class only makes calls, result/error handling should be done |
| 261 | // by callbacks. |
[email protected] | c5fd536 | 2013-08-27 12:23:04 | [diff] [blame] | 262 | class CHROMEOS_EXPORT CrosDisksClient : public DBusClient { |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 263 | public: |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 264 | // A callback to handle the result of EnumerateAutoMountableDevices. |
| 265 | // The argument is the enumerated device paths. |
[email protected] | a0278d5 | 2014-05-06 03:36:15 | [diff] [blame] | 266 | typedef base::Callback<void(const std::vector<std::string>& device_paths)> |
| 267 | EnumerateAutoMountableDevicesCallback; |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 268 | |
[email protected] | d776059 | 2014-05-16 07:57:52 | [diff] [blame] | 269 | // A callback to handle the result of EnumerateMountEntries. |
| 270 | // The argument is the enumerated mount entries. |
| 271 | typedef base::Callback<void(const std::vector<MountEntry>& entries)> |
| 272 | EnumerateMountEntriesCallback; |
| 273 | |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 274 | // A callback to handle the result of GetDeviceProperties. |
| 275 | // The argument is the information about the specified device. |
[email protected] | a0278d5 | 2014-05-06 03:36:15 | [diff] [blame] | 276 | typedef base::Callback<void(const DiskInfo& disk_info)> |
| 277 | GetDevicePropertiesCallback; |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 278 | |
| 279 | // A callback to handle MountCompleted signal. |
[email protected] | d776059 | 2014-05-16 07:57:52 | [diff] [blame] | 280 | typedef base::Callback<void(const MountEntry& entry)> MountCompletedHandler; |
[email protected] | a0278d5 | 2014-05-06 03:36:15 | [diff] [blame] | 281 | |
| 282 | // A callback to handle FormatCompleted signal. |
| 283 | // The first argument is the error code. |
| 284 | // The second argument is the device path. |
| 285 | typedef base::Callback<void(FormatError error_code, |
| 286 | const std::string& device_path)> |
| 287 | FormatCompletedHandler; |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 288 | |
Klemen Kozjek | bf5610f | 2017-08-25 20:20:09 | [diff] [blame^] | 289 | // A callback to handle RenameCompleted signal. |
| 290 | // The first argument is the error code. |
| 291 | // The second argument is the device path. |
| 292 | typedef base::Callback<void(RenameError error_code, |
| 293 | const std::string& device_path)> |
| 294 | RenameCompletedHandler; |
| 295 | |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 296 | // A callback to handle mount events. |
| 297 | // The first argument is the event type. |
| 298 | // The second argument is the device path. |
[email protected] | 85b95a201 | 2012-08-07 18:57:27 | [diff] [blame] | 299 | typedef base::Callback<void(MountEventType event_type, |
[email protected] | a0278d5 | 2014-05-06 03:36:15 | [diff] [blame] | 300 | const std::string& device_path)> |
| 301 | MountEventHandler; |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 302 | |
dcheng | 0280cb6 | 2015-01-16 07:37:50 | [diff] [blame] | 303 | ~CrosDisksClient() override; |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 304 | |
| 305 | // Calls Mount method. |callback| is called after the method call succeeds, |
| 306 | // otherwise, |error_callback| is called. |
[email protected] | dcad8fc | 2012-04-30 23:31:33 | [diff] [blame] | 307 | // When mounting an archive, caller may set two optional arguments: |
| 308 | // - The |source_format| argument passes the file extension (with the leading |
| 309 | // dot, for example ".zip"). If |source_format| is empty then the source |
| 310 | // format is auto-detected. |
| 311 | // - The |mount_label| argument passes an optional mount label to be used as |
| 312 | // the directory name of the mount point. If |mount_label| is empty, the |
| 313 | // mount label will be based on the |source_path|. |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 314 | virtual void Mount(const std::string& source_path, |
[email protected] | b9f22d1 | 2012-04-25 21:46:48 | [diff] [blame] | 315 | const std::string& source_format, |
[email protected] | dcad8fc | 2012-04-30 23:31:33 | [diff] [blame] | 316 | const std::string& mount_label, |
yamaguchi | 585d540 | 2016-08-02 09:27:36 | [diff] [blame] | 317 | MountAccessMode access_mode, |
yamaguchi | fa8efc7 | 2016-10-21 15:05:51 | [diff] [blame] | 318 | RemountOption remount, |
[email protected] | 5624a25 | 2013-07-04 03:17:53 | [diff] [blame] | 319 | const base::Closure& callback, |
| 320 | const base::Closure& error_callback) = 0; |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 321 | |
| 322 | // Calls Unmount method. |callback| is called after the method call succeeds, |
| 323 | // otherwise, |error_callback| is called. |
| 324 | virtual void Unmount(const std::string& device_path, |
[email protected] | 10795ae | 2012-10-10 07:33:49 | [diff] [blame] | 325 | UnmountOptions options, |
[email protected] | ffdcc7a9c | 2013-07-02 06:59:39 | [diff] [blame] | 326 | const base::Closure& callback, |
| 327 | const base::Closure& error_callback) = 0; |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 328 | |
| 329 | // Calls EnumerateAutoMountableDevices method. |callback| is called after the |
| 330 | // method call succeeds, otherwise, |error_callback| is called. |
| 331 | virtual void EnumerateAutoMountableDevices( |
[email protected] | 4a404e5 | 2012-04-11 02:25:35 | [diff] [blame] | 332 | const EnumerateAutoMountableDevicesCallback& callback, |
[email protected] | 5624a25 | 2013-07-04 03:17:53 | [diff] [blame] | 333 | const base::Closure& error_callback) = 0; |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 334 | |
[email protected] | d776059 | 2014-05-16 07:57:52 | [diff] [blame] | 335 | // Calls EnumerateMountEntries. |callback| is called after the |
| 336 | // method call succeeds, otherwise, |error_callback| is called. |
| 337 | virtual void EnumerateMountEntries( |
| 338 | const EnumerateMountEntriesCallback& callback, |
| 339 | const base::Closure& error_callback) = 0; |
| 340 | |
[email protected] | f026c0f | 2014-05-06 21:52:35 | [diff] [blame] | 341 | // Calls Format method. |callback| is called after the method call succeeds, |
| 342 | // otherwise, |error_callback| is called. |
| 343 | virtual void Format(const std::string& device_path, |
| 344 | const std::string& filesystem, |
| 345 | const base::Closure& callback, |
| 346 | const base::Closure& error_callback) = 0; |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 347 | |
Klemen Kozjek | bf5610f | 2017-08-25 20:20:09 | [diff] [blame^] | 348 | // Calls Rename method. |callback| is called after the method call succeeds, |
| 349 | // otherwise, |error_callback| is called. |
| 350 | virtual void Rename(const std::string& device_path, |
| 351 | const std::string& volume_name, |
| 352 | const base::Closure& callback, |
| 353 | const base::Closure& error_callback) = 0; |
| 354 | |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 355 | // Calls GetDeviceProperties method. |callback| is called after the method |
| 356 | // call succeeds, otherwise, |error_callback| is called. |
| 357 | virtual void GetDeviceProperties(const std::string& device_path, |
[email protected] | 4a404e5 | 2012-04-11 02:25:35 | [diff] [blame] | 358 | const GetDevicePropertiesCallback& callback, |
[email protected] | 5624a25 | 2013-07-04 03:17:53 | [diff] [blame] | 359 | const base::Closure& error_callback) = 0; |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 360 | |
[email protected] | a0278d5 | 2014-05-06 03:36:15 | [diff] [blame] | 361 | // Registers |mount_event_handler| as a callback to be invoked when a mount |
| 362 | // event signal is received. |
| 363 | virtual void SetMountEventHandler( |
| 364 | const MountEventHandler& mount_event_handler) = 0; |
| 365 | |
| 366 | // Registers |mount_completed_handler| as a callback to be invoked when a |
| 367 | // MountCompleted signal is received. |
| 368 | virtual void SetMountCompletedHandler( |
[email protected] | 4a404e5 | 2012-04-11 02:25:35 | [diff] [blame] | 369 | const MountCompletedHandler& mount_completed_handler) = 0; |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 370 | |
[email protected] | a0278d5 | 2014-05-06 03:36:15 | [diff] [blame] | 371 | // Registers |format_completed_handler| as a callback to be invoked when a |
| 372 | // FormatCompleted signal is received. |
| 373 | virtual void SetFormatCompletedHandler( |
| 374 | const FormatCompletedHandler& format_completed_handler) = 0; |
| 375 | |
Klemen Kozjek | bf5610f | 2017-08-25 20:20:09 | [diff] [blame^] | 376 | // Registers |rename_completed_handler| as a callback to be invoked when a |
| 377 | // RenameCompleted signal is received. |
| 378 | virtual void SetRenameCompletedHandler( |
| 379 | const RenameCompletedHandler& rename_completed_handler) = 0; |
| 380 | |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 381 | // Factory function, creates a new instance and returns ownership. |
| 382 | // For normal usage, access the singleton via DBusThreadManager::Get(). |
[email protected] | c5fd536 | 2013-08-27 12:23:04 | [diff] [blame] | 383 | static CrosDisksClient* Create(DBusClientImplementationType type); |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 384 | |
[email protected] | a5a8b41 | 2013-03-04 15:03:11 | [diff] [blame] | 385 | // Returns the path of the mount point for archive files. |
| 386 | static base::FilePath GetArchiveMountPoint(); |
| 387 | |
| 388 | // Returns the path of the mount point for removable disks. |
| 389 | static base::FilePath GetRemovableDiskMountPoint(); |
| 390 | |
yamaguchi | 585d540 | 2016-08-02 09:27:36 | [diff] [blame] | 391 | // Composes a list of mount options. |
| 392 | static std::vector<std::string> ComposeMountOptions( |
| 393 | const std::string& mount_label, |
yamaguchi | fa8efc7 | 2016-10-21 15:05:51 | [diff] [blame] | 394 | MountAccessMode access_mode, |
| 395 | RemountOption remount); |
yamaguchi | 585d540 | 2016-08-02 09:27:36 | [diff] [blame] | 396 | |
[email protected] | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 397 | protected: |
| 398 | // Create() should be used instead. |
| 399 | CrosDisksClient(); |
| 400 | |
| 401 | private: |
| 402 | DISALLOW_COPY_AND_ASSIGN(CrosDisksClient); |
| 403 | }; |
| 404 | |
| 405 | } // namespace chromeos |
| 406 | |
[email protected] | 64e19925 | 2012-04-06 01:54:36 | [diff] [blame] | 407 | #endif // CHROMEOS_DBUS_CROS_DISKS_CLIENT_H_ |