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