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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « disk.cc ('k') | disk-manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 DISK_MANAGER_H__
6 #define DISK_MANAGER_H__
7
8 #include <libudev.h>
9 #include <vector>
10
11 namespace cros_disks {
12
13 class Disk;
14
15 // The DiskManager is responsible for reading device state from udev.
16 // Said changes could be the result of a udev notification or a synchronous
17 // call to enumerate the relevant storage devices attached to the system.
18 //
19 // Sample Usage:
20 //
21 // DiskManager manager;
22 // manager.EnumerateDisks();
23 // select(manager.udev_monitor_fd())...
24 //
25 // This class is designed to run within a single-threaded GMainLoop application
26 // and should not be considered thread safe.
27 class DiskManager {
28 public:
29 DiskManager();
30 virtual ~DiskManager();
31
32 // Lists the current block devices attached to the system.
33 virtual std::vector<Disk> EnumerateDisks();
34
35 // Reads the changes from udev. Must be called to clear the
36 // fd.
37 bool ProcessUdevChanges();
38
39 // A file descriptor that can be select()ed or poll()ed for system changes.
40 int udev_monitor_fd() const { return udev_monitor_fd_; }
41
42 private:
43
44 // The root udev object.
45 struct udev* udev_;
46
47 // Provides access to udev changes as they occur.
48 struct udev_monitor* udev_monitor_;
49
50 // A file descriptor that indicates changes to the system.
51 int udev_monitor_fd_;
52 };
53
54 } // namespace cros_disks
55
56 #endif // DISK_MANAGER_H__
OLDNEW
« 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