Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Side by Side Diff: chromeos/dbus/cros_disks_client.h

Issue 281063002: Add EnumerateMountEntries method in CrosDisksClient. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chromeos/dbus/cros_disks_client.cc » ('j') | chromeos/dbus/cros_disks_client.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 class to represent information about a mount point sent from cros-disks.
189 class CHROMEOS_EXPORT MountEntry {
stevenjb 2014/05/14 17:45:11 This could actually just be a struct since it does
kinaba 2014/05/15 02:14:59 Done.
190 public:
191 MountEntry();
192 MountEntry(MountError error_code,
193 const std::string& source_path,
194 MountType mount_type,
195 const std::string& mount_path);
196 ~MountEntry();
197
198 static bool ReadFromDbus(dbus::MessageReader* reader, MountEntry* entry);
199
200 MountError error_code() const { return error_code_; }
201 const std::string& source_path() const { return source_path_; }
202 MountType mount_type() const { return mount_type_; }
203 const std::string& mount_path() const { return mount_path_; }
204
205 private:
206 MountError error_code_;
207 std::string source_path_;
208 MountType mount_type_;
209 std::string mount_path_;
210 };
211
187 // A class to make the actual DBus calls for cros-disks service. 212 // A class to make the actual DBus calls for cros-disks service.
188 // This class only makes calls, result/error handling should be done 213 // This class only makes calls, result/error handling should be done
189 // by callbacks. 214 // by callbacks.
190 class CHROMEOS_EXPORT CrosDisksClient : public DBusClient { 215 class CHROMEOS_EXPORT CrosDisksClient : public DBusClient {
191 public: 216 public:
192 // A callback to handle the result of EnumerateAutoMountableDevices. 217 // A callback to handle the result of EnumerateAutoMountableDevices.
193 // The argument is the enumerated device paths. 218 // The argument is the enumerated device paths.
194 typedef base::Callback<void(const std::vector<std::string>& device_paths)> 219 typedef base::Callback<void(const std::vector<std::string>& device_paths)>
195 EnumerateAutoMountableDevicesCallback; 220 EnumerateAutoMountableDevicesCallback;
196 221
222 // A callback to handle the result of EnumerateMountEntries.
223 // The argument is the enumerated mount entries.
224 typedef base::Callback<void(const std::vector<MountEntry>& entries)>
225 EnumerateMountEntriesCallback;
226
197 // A callback to handle the result of GetDeviceProperties. 227 // A callback to handle the result of GetDeviceProperties.
198 // The argument is the information about the specified device. 228 // The argument is the information about the specified device.
199 typedef base::Callback<void(const DiskInfo& disk_info)> 229 typedef base::Callback<void(const DiskInfo& disk_info)>
200 GetDevicePropertiesCallback; 230 GetDevicePropertiesCallback;
201 231
202 // A callback to handle MountCompleted signal. 232 // A callback to handle MountCompleted signal.
203 // The first argument is the error code. 233 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 234
213 // A callback to handle FormatCompleted signal. 235 // A callback to handle FormatCompleted signal.
214 // The first argument is the error code. 236 // The first argument is the error code.
215 // The second argument is the device path. 237 // The second argument is the device path.
216 typedef base::Callback<void(FormatError error_code, 238 typedef base::Callback<void(FormatError error_code,
217 const std::string& device_path)> 239 const std::string& device_path)>
218 FormatCompletedHandler; 240 FormatCompletedHandler;
219 241
220 // A callback to handle mount events. 242 // A callback to handle mount events.
221 // The first argument is the event type. 243 // The first argument is the event type.
(...skipping 25 matching lines...) Expand all
247 UnmountOptions options, 269 UnmountOptions options,
248 const base::Closure& callback, 270 const base::Closure& callback,
249 const base::Closure& error_callback) = 0; 271 const base::Closure& error_callback) = 0;
250 272
251 // Calls EnumerateAutoMountableDevices method. |callback| is called after the 273 // Calls EnumerateAutoMountableDevices method. |callback| is called after the
252 // method call succeeds, otherwise, |error_callback| is called. 274 // method call succeeds, otherwise, |error_callback| is called.
253 virtual void EnumerateAutoMountableDevices( 275 virtual void EnumerateAutoMountableDevices(
254 const EnumerateAutoMountableDevicesCallback& callback, 276 const EnumerateAutoMountableDevicesCallback& callback,
255 const base::Closure& error_callback) = 0; 277 const base::Closure& error_callback) = 0;
256 278
279 // Calls EnumerateMountEntries. |callback| is called after the
280 // method call succeeds, otherwise, |error_callback| is called.
281 virtual void EnumerateMountEntries(
282 const EnumerateMountEntriesCallback& callback,
283 const base::Closure& error_callback) = 0;
284
257 // Calls Format method. |callback| is called after the method call succeeds, 285 // Calls Format method. |callback| is called after the method call succeeds,
258 // otherwise, |error_callback| is called. 286 // otherwise, |error_callback| is called.
259 virtual void Format(const std::string& device_path, 287 virtual void Format(const std::string& device_path,
260 const std::string& filesystem, 288 const std::string& filesystem,
261 const base::Closure& callback, 289 const base::Closure& callback,
262 const base::Closure& error_callback) = 0; 290 const base::Closure& error_callback) = 0;
263 291
264 // Calls GetDeviceProperties method. |callback| is called after the method 292 // Calls GetDeviceProperties method. |callback| is called after the method
265 // call succeeds, otherwise, |error_callback| is called. 293 // call succeeds, otherwise, |error_callback| is called.
266 virtual void GetDeviceProperties(const std::string& device_path, 294 virtual void GetDeviceProperties(const std::string& device_path,
(...skipping 29 matching lines...) Expand all
296 // Create() should be used instead. 324 // Create() should be used instead.
297 CrosDisksClient(); 325 CrosDisksClient();
298 326
299 private: 327 private:
300 DISALLOW_COPY_AND_ASSIGN(CrosDisksClient); 328 DISALLOW_COPY_AND_ASSIGN(CrosDisksClient);
301 }; 329 };
302 330
303 } // namespace chromeos 331 } // namespace chromeos
304 332
305 #endif // CHROMEOS_DBUS_CROS_DISKS_CLIENT_H_ 333 #endif // CHROMEOS_DBUS_CROS_DISKS_CLIENT_H_
OLDNEW
« no previous file with comments | « no previous file | chromeos/dbus/cros_disks_client.cc » ('j') | chromeos/dbus/cros_disks_client.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698