| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROMEOS_DBUS_CROS_DISKS_CLIENT_H_ | 5 #ifndef CHROMEOS_DBUS_CROS_DISKS_CLIENT_H_ |
| 6 #define CHROMEOS_DBUS_CROS_DISKS_CLIENT_H_ | 6 #define CHROMEOS_DBUS_CROS_DISKS_CLIENT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
| 13 #include "chromeos/chromeos_export.h" | 13 #include "chromeos/chromeos_export.h" |
| 14 #include "chromeos/dbus/dbus_client.h" | 14 #include "chromeos/dbus/dbus_client.h" |
| 15 #include "chromeos/dbus/dbus_client_implementation_type.h" | 15 #include "chromeos/dbus/dbus_client_implementation_type.h" |
| 16 | 16 |
| 17 namespace base { | 17 namespace base { |
| 18 class FilePath; | 18 class FilePath; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace dbus { | 21 namespace dbus { |
| 22 class MessageReader; |
| 22 class Response; | 23 class Response; |
| 23 } | 24 } |
| 24 | 25 |
| 25 // TODO(tbarzic): We should move these enums inside CrosDisksClient, | 26 // TODO(tbarzic): We should move these enums inside CrosDisksClient, |
| 26 // to be clearer where they come from. Also, most of these are partially or | 27 // to be clearer where they come from. Also, most of these are partially or |
| 27 // completely duplicated in third_party/dbus/service_constants.h. We should | 28 // completely duplicated in third_party/dbus/service_constants.h. We should |
| 28 // probably use enums from service_contstants directly. | 29 // probably use enums from service_contstants directly. |
| 29 namespace chromeos { | 30 namespace chromeos { |
| 30 | 31 |
| 31 // Enum describing types of mount used by cros-disks. | 32 // Enum describing types of mount used by cros-disks. |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 // Disk system path given by udev. | 115 // Disk system path given by udev. |
| 115 // (e.g. /sys/devices/pci0000:00/.../8:0:0:0/block/sdb/sdb1) | 116 // (e.g. /sys/devices/pci0000:00/.../8:0:0:0/block/sdb/sdb1) |
| 116 const std::string& system_path() const { return system_path_; } | 117 const std::string& system_path() const { return system_path_; } |
| 117 | 118 |
| 118 // Is a drive or not. (i.e. true with /dev/sdb, false with /dev/sdb1) | 119 // Is a drive or not. (i.e. true with /dev/sdb, false with /dev/sdb1) |
| 119 bool is_drive() const { return is_drive_; } | 120 bool is_drive() const { return is_drive_; } |
| 120 | 121 |
| 121 // Does the disk have media content. | 122 // Does the disk have media content. |
| 122 bool has_media() const { return has_media_; } | 123 bool has_media() const { return has_media_; } |
| 123 | 124 |
| 124 // Is the disk on deveice we booted the machine from. | 125 // Is the disk on device we booted the machine from. |
| 125 bool on_boot_device() const { return on_boot_device_; } | 126 bool on_boot_device() const { return on_boot_device_; } |
| 126 | 127 |
| 127 // Disk file path (e.g. /dev/sdb). | 128 // Disk file path (e.g. /dev/sdb). |
| 128 const std::string& file_path() const { return file_path_; } | 129 const std::string& file_path() const { return file_path_; } |
| 129 | 130 |
| 130 // Disk label. | 131 // Disk label. |
| 131 const std::string& label() const { return label_; } | 132 const std::string& label() const { return label_; } |
| 132 | 133 |
| 133 // Vendor ID of the device (e.g. "18d1"). | 134 // Vendor ID of the device (e.g. "18d1"). |
| 134 const std::string& vendor_id() const { return vendor_id_; } | 135 const std::string& vendor_id() const { return vendor_id_; } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 std::string product_id_; | 178 std::string product_id_; |
| 178 std::string product_name_; | 179 std::string product_name_; |
| 179 std::string drive_model_; | 180 std::string drive_model_; |
| 180 DeviceType device_type_; | 181 DeviceType device_type_; |
| 181 uint64 total_size_in_bytes_; | 182 uint64 total_size_in_bytes_; |
| 182 bool is_read_only_; | 183 bool is_read_only_; |
| 183 bool is_hidden_; | 184 bool is_hidden_; |
| 184 std::string uuid_; | 185 std::string uuid_; |
| 185 }; | 186 }; |
| 186 | 187 |
| 188 // A struct to represent information about a mount point sent from cros-disks. |
| 189 struct CHROMEOS_EXPORT MountEntry { |
| 190 public: |
| 191 MountEntry() |
| 192 : error_code_(MOUNT_ERROR_UNKNOWN), mount_type_(MOUNT_TYPE_INVALID) { |
| 193 } |
| 194 |
| 195 MountEntry(MountError error_code, |
| 196 const std::string& source_path, |
| 197 MountType mount_type, |
| 198 const std::string& mount_path) |
| 199 : error_code_(error_code), |
| 200 source_path_(source_path), |
| 201 mount_type_(mount_type), |
| 202 mount_path_(mount_path) { |
| 203 } |
| 204 |
| 205 MountError error_code() const { return error_code_; } |
| 206 const std::string& source_path() const { return source_path_; } |
| 207 MountType mount_type() const { return mount_type_; } |
| 208 const std::string& mount_path() const { return mount_path_; } |
| 209 |
| 210 private: |
| 211 MountError error_code_; |
| 212 std::string source_path_; |
| 213 MountType mount_type_; |
| 214 std::string mount_path_; |
| 215 }; |
| 216 |
| 187 // A class to make the actual DBus calls for cros-disks service. | 217 // A class to make the actual DBus calls for cros-disks service. |
| 188 // This class only makes calls, result/error handling should be done | 218 // This class only makes calls, result/error handling should be done |
| 189 // by callbacks. | 219 // by callbacks. |
| 190 class CHROMEOS_EXPORT CrosDisksClient : public DBusClient { | 220 class CHROMEOS_EXPORT CrosDisksClient : public DBusClient { |
| 191 public: | 221 public: |
| 192 // A callback to handle the result of EnumerateAutoMountableDevices. | 222 // A callback to handle the result of EnumerateAutoMountableDevices. |
| 193 // The argument is the enumerated device paths. | 223 // The argument is the enumerated device paths. |
| 194 typedef base::Callback<void(const std::vector<std::string>& device_paths)> | 224 typedef base::Callback<void(const std::vector<std::string>& device_paths)> |
| 195 EnumerateAutoMountableDevicesCallback; | 225 EnumerateAutoMountableDevicesCallback; |
| 196 | 226 |
| 227 // A callback to handle the result of EnumerateMountEntries. |
| 228 // The argument is the enumerated mount entries. |
| 229 typedef base::Callback<void(const std::vector<MountEntry>& entries)> |
| 230 EnumerateMountEntriesCallback; |
| 231 |
| 197 // A callback to handle the result of GetDeviceProperties. | 232 // A callback to handle the result of GetDeviceProperties. |
| 198 // The argument is the information about the specified device. | 233 // The argument is the information about the specified device. |
| 199 typedef base::Callback<void(const DiskInfo& disk_info)> | 234 typedef base::Callback<void(const DiskInfo& disk_info)> |
| 200 GetDevicePropertiesCallback; | 235 GetDevicePropertiesCallback; |
| 201 | 236 |
| 202 // A callback to handle MountCompleted signal. | 237 // A callback to handle MountCompleted signal. |
| 203 // The first argument is the error code. | 238 typedef base::Callback<void(const MountEntry& entry)> MountCompletedHandler; |
| 204 // The second argument is the source path. | |
| 205 // The third argument is the mount type. | |
| 206 // The fourth argument is the mount path. | |
| 207 typedef base::Callback<void(MountError error_code, | |
| 208 const std::string& source_path, | |
| 209 MountType mount_type, | |
| 210 const std::string& mount_path)> | |
| 211 MountCompletedHandler; | |
| 212 | 239 |
| 213 // A callback to handle FormatCompleted signal. | 240 // A callback to handle FormatCompleted signal. |
| 214 // The first argument is the error code. | 241 // The first argument is the error code. |
| 215 // The second argument is the device path. | 242 // The second argument is the device path. |
| 216 typedef base::Callback<void(FormatError error_code, | 243 typedef base::Callback<void(FormatError error_code, |
| 217 const std::string& device_path)> | 244 const std::string& device_path)> |
| 218 FormatCompletedHandler; | 245 FormatCompletedHandler; |
| 219 | 246 |
| 220 // A callback to handle mount events. | 247 // A callback to handle mount events. |
| 221 // The first argument is the event type. | 248 // The first argument is the event type. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 247 UnmountOptions options, | 274 UnmountOptions options, |
| 248 const base::Closure& callback, | 275 const base::Closure& callback, |
| 249 const base::Closure& error_callback) = 0; | 276 const base::Closure& error_callback) = 0; |
| 250 | 277 |
| 251 // Calls EnumerateAutoMountableDevices method. |callback| is called after the | 278 // Calls EnumerateAutoMountableDevices method. |callback| is called after the |
| 252 // method call succeeds, otherwise, |error_callback| is called. | 279 // method call succeeds, otherwise, |error_callback| is called. |
| 253 virtual void EnumerateAutoMountableDevices( | 280 virtual void EnumerateAutoMountableDevices( |
| 254 const EnumerateAutoMountableDevicesCallback& callback, | 281 const EnumerateAutoMountableDevicesCallback& callback, |
| 255 const base::Closure& error_callback) = 0; | 282 const base::Closure& error_callback) = 0; |
| 256 | 283 |
| 284 // Calls EnumerateMountEntries. |callback| is called after the |
| 285 // method call succeeds, otherwise, |error_callback| is called. |
| 286 virtual void EnumerateMountEntries( |
| 287 const EnumerateMountEntriesCallback& callback, |
| 288 const base::Closure& error_callback) = 0; |
| 289 |
| 257 // Calls Format method. |callback| is called after the method call succeeds, | 290 // Calls Format method. |callback| is called after the method call succeeds, |
| 258 // otherwise, |error_callback| is called. | 291 // otherwise, |error_callback| is called. |
| 259 virtual void Format(const std::string& device_path, | 292 virtual void Format(const std::string& device_path, |
| 260 const std::string& filesystem, | 293 const std::string& filesystem, |
| 261 const base::Closure& callback, | 294 const base::Closure& callback, |
| 262 const base::Closure& error_callback) = 0; | 295 const base::Closure& error_callback) = 0; |
| 263 | 296 |
| 264 // Calls GetDeviceProperties method. |callback| is called after the method | 297 // Calls GetDeviceProperties method. |callback| is called after the method |
| 265 // call succeeds, otherwise, |error_callback| is called. | 298 // call succeeds, otherwise, |error_callback| is called. |
| 266 virtual void GetDeviceProperties(const std::string& device_path, | 299 virtual void GetDeviceProperties(const std::string& device_path, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 296 // Create() should be used instead. | 329 // Create() should be used instead. |
| 297 CrosDisksClient(); | 330 CrosDisksClient(); |
| 298 | 331 |
| 299 private: | 332 private: |
| 300 DISALLOW_COPY_AND_ASSIGN(CrosDisksClient); | 333 DISALLOW_COPY_AND_ASSIGN(CrosDisksClient); |
| 301 }; | 334 }; |
| 302 | 335 |
| 303 } // namespace chromeos | 336 } // namespace chromeos |
| 304 | 337 |
| 305 #endif // CHROMEOS_DBUS_CROS_DISKS_CLIENT_H_ | 338 #endif // CHROMEOS_DBUS_CROS_DISKS_CLIENT_H_ |
| OLD | NEW |