| 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 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 FORMATTING_FINISHED, | 64 FORMATTING_FINISHED, |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 // A class to represent information about a disk sent from cros-disks. | 67 // A class to represent information about a disk sent from cros-disks. |
| 68 class DiskInfo { | 68 class DiskInfo { |
| 69 public: | 69 public: |
| 70 DiskInfo(const std::string& device_path, dbus::Response* response); | 70 DiskInfo(const std::string& device_path, dbus::Response* response); |
| 71 ~DiskInfo(); | 71 ~DiskInfo(); |
| 72 | 72 |
| 73 // Device path. (e.g. /sys/devices/pci0000:00/.../8:0:0:0/block/sdb/sdb1) | 73 // Device path. (e.g. /sys/devices/pci0000:00/.../8:0:0:0/block/sdb/sdb1) |
| 74 std::string device_path() const { return device_path_; } | 74 const std::string& device_path() const { return device_path_; } |
| 75 | 75 |
| 76 // Disk mount path. (e.g. /media/removable/VOLUME) | 76 // Disk mount path. (e.g. /media/removable/VOLUME) |
| 77 std::string mount_path() const { return mount_path_; } | 77 const std::string& mount_path() const { return mount_path_; } |
| 78 | 78 |
| 79 // Disk system path given by udev. | 79 // Disk system path given by udev. |
| 80 // (e.g. /sys/devices/pci0000:00/.../8:0:0:0/block/sdb/sdb1) | 80 // (e.g. /sys/devices/pci0000:00/.../8:0:0:0/block/sdb/sdb1) |
| 81 std::string system_path() const { return system_path_; } | 81 const std::string& system_path() const { return system_path_; } |
| 82 | 82 |
| 83 // Is a drive or not. (i.e. true with /dev/sdb, false with /dev/sdb1) | 83 // Is a drive or not. (i.e. true with /dev/sdb, false with /dev/sdb1) |
| 84 bool is_drive() const { return is_drive_; } | 84 bool is_drive() const { return is_drive_; } |
| 85 | 85 |
| 86 // Does the disk have media content. | 86 // Does the disk have media content. |
| 87 bool has_media() const { return has_media_; } | 87 bool has_media() const { return has_media_; } |
| 88 | 88 |
| 89 // Is the disk on deveice we booted the machine from. | 89 // Is the disk on deveice we booted the machine from. |
| 90 bool on_boot_device() const { return on_boot_device_; } | 90 bool on_boot_device() const { return on_boot_device_; } |
| 91 | 91 |
| 92 // Disk file path (e.g. /dev/sdb). | 92 // Disk file path (e.g. /dev/sdb). |
| 93 std::string file_path() const { return file_path_; } | 93 const std::string& file_path() const { return file_path_; } |
| 94 | 94 |
| 95 // Disk label. | 95 // Disk label. |
| 96 std::string label() const { return label_; } | 96 const std::string& label() const { return label_; } |
| 97 | 97 |
| 98 // Disk model. (e.g. "TransMemory") | 98 // Disk model. (e.g. "TransMemory") |
| 99 std::string drive_label() const { return drive_model_; } | 99 const std::string& drive_label() const { return drive_model_; } |
| 100 | 100 |
| 101 // Device type. Not working well, yet. | 101 // Device type. Not working well, yet. |
| 102 DeviceType device_type() const { return device_type_; } | 102 DeviceType device_type() const { return device_type_; } |
| 103 | 103 |
| 104 // Total size of the disk in bytes. | 104 // Total size of the disk in bytes. |
| 105 uint64 total_size_in_bytes() const { return total_size_in_bytes_; } | 105 uint64 total_size_in_bytes() const { return total_size_in_bytes_; } |
| 106 | 106 |
| 107 // Is the device read-only. | 107 // Is the device read-only. |
| 108 bool is_read_only() const { return is_read_only_; } | 108 bool is_read_only() const { return is_read_only_; } |
| 109 | 109 |
| 110 // Returns true if the device should be hidden from the file browser. | 110 // Returns true if the device should be hidden from the file browser. |
| 111 bool is_hidden() const { return is_hidden_; } | 111 bool is_hidden() const { return is_hidden_; } |
| 112 | 112 |
| 113 // Returns file system uuid. | 113 // Returns file system uuid. |
| 114 std::string uuid() const { return uuid_; } | 114 const std::string& uuid() const { return uuid_; } |
| 115 | 115 |
| 116 private: | 116 private: |
| 117 void InitializeFromResponse(dbus::Response* response); | 117 void InitializeFromResponse(dbus::Response* response); |
| 118 | 118 |
| 119 std::string device_path_; | 119 std::string device_path_; |
| 120 std::string mount_path_; | 120 std::string mount_path_; |
| 121 std::string system_path_; | 121 std::string system_path_; |
| 122 bool is_drive_; | 122 bool is_drive_; |
| 123 bool has_media_; | 123 bool has_media_; |
| 124 bool on_boot_device_; | 124 bool on_boot_device_; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 139 class CHROMEOS_EXPORT CrosDisksClient { | 139 class CHROMEOS_EXPORT CrosDisksClient { |
| 140 public: | 140 public: |
| 141 // A callback to be called when DBus method call fails. | 141 // A callback to be called when DBus method call fails. |
| 142 typedef base::Callback<void()> ErrorCallback; | 142 typedef base::Callback<void()> ErrorCallback; |
| 143 | 143 |
| 144 // A callback to handle the result of Mount. | 144 // A callback to handle the result of Mount. |
| 145 typedef base::Callback<void()> MountCallback; | 145 typedef base::Callback<void()> MountCallback; |
| 146 | 146 |
| 147 // A callback to handle the result of Unmount. | 147 // A callback to handle the result of Unmount. |
| 148 // The argument is the device path. | 148 // The argument is the device path. |
| 149 typedef base::Callback<void(const std::string&)> UnmountCallback; | 149 typedef base::Callback<void(const std::string& device_path)> UnmountCallback; |
| 150 | 150 |
| 151 // A callback to handle the result of EnumerateAutoMountableDevices. | 151 // A callback to handle the result of EnumerateAutoMountableDevices. |
| 152 // The argument is the enumerated device paths. | 152 // The argument is the enumerated device paths. |
| 153 typedef base::Callback<void(const std::vector<std::string>&) | 153 typedef base::Callback<void(const std::vector<std::string>& device_paths) |
| 154 > EnumerateAutoMountableDevicesCallback; | 154 > EnumerateAutoMountableDevicesCallback; |
| 155 | 155 |
| 156 // A callback to handle the result of FormatDevice. | 156 // A callback to handle the result of FormatDevice. |
| 157 // The first argument is the device path. | 157 // The first argument is the device path. |
| 158 // The second argument is true when formatting succeeded, false otherwise. | 158 // The second argument is true when formatting succeeded, false otherwise. |
| 159 typedef base::Callback<void(const std::string&, bool)> FormatDeviceCallback; | 159 typedef base::Callback<void(const std::string& device_path, |
| 160 bool format_succeeded)> FormatDeviceCallback; |
| 160 | 161 |
| 161 // A callback to handle the result of GetDeviceProperties. | 162 // A callback to handle the result of GetDeviceProperties. |
| 162 // The argument is the information about the specified device. | 163 // The argument is the information about the specified device. |
| 163 typedef base::Callback<void(const DiskInfo&)> GetDevicePropertiesCallback; | 164 typedef base::Callback<void(const DiskInfo& disk_info) |
| 165 > GetDevicePropertiesCallback; |
| 164 | 166 |
| 165 // A callback to handle MountCompleted signal. | 167 // A callback to handle MountCompleted signal. |
| 166 // The first argument is the error code. | 168 // The first argument is the error code. |
| 167 // The second argument is the source path. | 169 // The second argument is the source path. |
| 168 // The third argument is the mount type. | 170 // The third argument is the mount type. |
| 169 // The fourth argument is the mount path. | 171 // The fourth argument is the mount path. |
| 170 typedef base::Callback<void(MountError, const std::string&, MountType, | 172 typedef base::Callback<void(MountError error_code, |
| 171 const std::string&)> MountCompletedHandler; | 173 const std::string& source_path, |
| 174 MountType mount_type, |
| 175 const std::string& mount_path) |
| 176 > MountCompletedHandler; |
| 172 | 177 |
| 173 // A callback to handle mount events. | 178 // A callback to handle mount events. |
| 174 // The first argument is the event type. | 179 // The first argument is the event type. |
| 175 // The second argument is the device path. | 180 // The second argument is the device path. |
| 176 typedef base::Callback<void(MountEventType, const std::string&) | 181 typedef base::Callback<void(MountEventType event_type, |
| 182 const std::string& device_path) |
| 177 > MountEventHandler; | 183 > MountEventHandler; |
| 178 | 184 |
| 179 virtual ~CrosDisksClient(); | 185 virtual ~CrosDisksClient(); |
| 180 | 186 |
| 181 // Calls Mount method. |callback| is called after the method call succeeds, | 187 // Calls Mount method. |callback| is called after the method call succeeds, |
| 182 // otherwise, |error_callback| is called. | 188 // otherwise, |error_callback| is called. |
| 183 // When mounting an archive, caller may set two optional arguments: | 189 // When mounting an archive, caller may set two optional arguments: |
| 184 // - The |source_format| argument passes the file extension (with the leading | 190 // - The |source_format| argument passes the file extension (with the leading |
| 185 // dot, for example ".zip"). If |source_format| is empty then the source | 191 // dot, for example ".zip"). If |source_format| is empty then the source |
| 186 // format is auto-detected. | 192 // format is auto-detected. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 // Create() should be used instead. | 241 // Create() should be used instead. |
| 236 CrosDisksClient(); | 242 CrosDisksClient(); |
| 237 | 243 |
| 238 private: | 244 private: |
| 239 DISALLOW_COPY_AND_ASSIGN(CrosDisksClient); | 245 DISALLOW_COPY_AND_ASSIGN(CrosDisksClient); |
| 240 }; | 246 }; |
| 241 | 247 |
| 242 } // namespace chromeos | 248 } // namespace chromeos |
| 243 | 249 |
| 244 #endif // CHROMEOS_DBUS_CROS_DISKS_CLIENT_H_ | 250 #endif // CHROMEOS_DBUS_CROS_DISKS_CLIENT_H_ |
| OLD | NEW |