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

Unified Diff: disk-manager.h

Issue 6824032: First batch of cros-disk changes (Closed) Base URL: ssh://gitrw.chromium.org:9222/cros-disks.git@master
Patch Set: adds set_ and removes j's 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.cc ('k') | disk-manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: disk-manager.h
diff --git a/disk-manager.h b/disk-manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..171455854c5e74ac6666b560133b146424797ff7
--- /dev/null
+++ b/disk-manager.h
@@ -0,0 +1,56 @@
+// 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 DISK_MANAGER_H__
+#define DISK_MANAGER_H__
+
+#include <libudev.h>
+#include <vector>
+
+namespace cros_disks {
+
+class Disk;
+
+// The DiskManager is responsible for reading device state from udev.
+// Said changes could be the result of a udev notification or a synchronous
+// call to enumerate the relevant storage devices attached to the system.
+//
+// Sample Usage:
+//
+// DiskManager manager;
+// manager.EnumerateDisks();
+// select(manager.udev_monitor_fd())...
+//
+// This class is designed to run within a single-threaded GMainLoop application
+// and should not be considered thread safe.
+class DiskManager {
+ public:
+ DiskManager();
+ virtual ~DiskManager();
+
+ // Lists the current block devices attached to the system.
+ virtual std::vector<Disk> EnumerateDisks();
+
+ // Reads the changes from udev. Must be called to clear the
+ // fd.
+ bool ProcessUdevChanges();
+
+ // A file descriptor that can be select()ed or poll()ed for system changes.
+ int udev_monitor_fd() const { return udev_monitor_fd_; }
+
+ private:
+
+ // The root udev object.
+ struct udev* udev_;
+
+ // Provides access to udev changes as they occur.
+ struct udev_monitor* udev_monitor_;
+
+ // A file descriptor that indicates changes to the system.
+ int udev_monitor_fd_;
+};
+
+} // namespace cros_disks
+
+#endif // DISK_MANAGER_H__
« no previous file with comments | « disk.cc ('k') | disk-manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698