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

Side by Side Diff: udev-device.h

Issue 6824082: Populate disk information from udev to disk manager. (Closed) Base URL: ssh://gitrw.chromium.org:9222/cros-disks.git@master
Patch Set: Created 9 years, 8 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
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHOS_DISKS_UDEV_DEVICE_H_
6 #define CROS_DISKS_UDEV_DEVICE_H_
7
8 #include <base/basictypes.h>
9 #include <string>
10 #include <vector>
11
12 #include "disk.h"
13
14 struct udev_device;
15
16 namespace cros_disks {
17
18 // A utility class that helps query information about a udev device.
19 class UdevDevice {
20 public:
21
22 UdevDevice(struct udev_device *dev);
23 ~UdevDevice();
24
25 // Gets the string value of a device attribute.
26 std::string GetAttribute(const char *key) const;
27
28 // Checks if the value of a device attribute represents a Boolean true.
29 bool IsAttributeTrue(const char *key) const;
30
31 // Checks if a device attribute exists.
32 bool HasAttribute(const char *key) const;
33
34 // Gets the string value of a device property.
35 std::string GetProperty(const char *key) const;
36
37 // Checks if the value of a device property represents a Boolean true.
38 bool IsPropertyTrue(const char *key) const;
39
40 // Checks if a device property exists.
41 bool HasProperty(const char *key) const;
42
43 // Gets the total and remaining capacity of the device.
44 void GetSizeInfo(uint64 *total_size, uint64 *remaining_size) const;
45
46 // Checks if any media is available in the device.
47 bool IsMediaAvailable() const;
48
49 // Gets the mounted paths for the device.
50 std::vector<std::string> GetMountedPaths() const;
51
52 // Returns a Disk object based on the device information.
53 Disk ToDisk() const;
54
55 private:
56
57 bool IsValueBooleanTrue(const char *value) const;
58
59 mutable struct udev_device *dev_;
rtc 2011/04/12 21:12:01 Can this be const?
Ben Chan 2011/04/12 21:18:46 Unfortunately, all udev_device_* function takes a
60 };
61
62 } // namespace cros_disks
63
64 #endif // CROS_DISKS_UDEV_DEVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698