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