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

Unified 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: Fixed issues after code review 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « disk-manager.cc ('k') | udev-device.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: udev-device.h
diff --git a/udev-device.h b/udev-device.h
new file mode 100644
index 0000000000000000000000000000000000000000..ef5c6c17d467d1acf11c83114d7bfda74907a65a
--- /dev/null
+++ b/udev-device.h
@@ -0,0 +1,70 @@
+// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHOS_DISKS_UDEV_DEVICE_H_
+#define CROS_DISKS_UDEV_DEVICE_H_
+
+#include <base/basictypes.h>
+#include <iostream>
+#include <string>
+#include <vector>
+
+#include "disk.h"
+
+struct udev_device;
+
+namespace cros_disks {
+
+// A utility class that helps query information about a udev device.
+class UdevDevice {
+ public:
+
+ explicit UdevDevice(struct udev_device *dev);
+ ~UdevDevice();
+
+ // Gets the string value of a device attribute.
+ std::string GetAttribute(const char *key) const;
+
+ // Checks if the value of a device attribute represents a Boolean true.
+ bool IsAttributeTrue(const char *key) const;
+
+ // Checks if a device attribute exists.
+ bool HasAttribute(const char *key) const;
+
+ // Gets the string value of a device property.
+ std::string GetProperty(const char *key) const;
+
+ // Checks if the value of a device property represents a Boolean true.
+ bool IsPropertyTrue(const char *key) const;
+
+ // Checks if a device property exists.
+ bool HasProperty(const char *key) const;
+
+ // Gets the total and remaining capacity of the device.
+ void GetSizeInfo(uint64 *total_size, uint64 *remaining_size) const;
+
+ // Checks if any media is available in the device.
+ bool IsMediaAvailable() const;
+
+ // Gets the mounted paths for the device.
+ std::vector<std::string> GetMountedPaths() const;
+
+ // Gets the mounted paths for an input stream that has the
+ // same format as /proc/mounts
+ static std::vector<std::string> ParseMountedPaths(
+ const std::string& device_path, std::istream& stream);
+
+ // Returns a Disk object based on the device information.
+ Disk ToDisk() const;
+
+ private:
+
+ bool IsValueBooleanTrue(const char *value) const;
+
+ mutable struct udev_device *dev_;
+};
+
+} // namespace cros_disks
+
+#endif // CROS_DISKS_UDEV_DEVICE_H_
« no previous file with comments | « disk-manager.cc ('k') | udev-device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698