OLD | NEW |
(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 POWER_MANAGER_UDEV_CONTROLLER_H_ |
| 6 #define POWER_MANAGER_UDEV_CONTROLLER_H_ |
| 7 |
| 8 #include <glib.h> |
| 9 #include <libudev.h> |
| 10 |
| 11 #include <string> |
| 12 |
| 13 #include "base/basictypes.h" |
| 14 |
| 15 namespace power_manager { |
| 16 |
| 17 class UdevDelegate { |
| 18 public: |
| 19 virtual ~UdevDelegate() {} |
| 20 virtual void Run(GIOChannel* source, GIOCondition condition) = 0; |
| 21 }; |
| 22 |
| 23 class UdevController { |
| 24 public: |
| 25 UdevController(UdevDelegate* delegate, const std::string& subsystem); |
| 26 ~UdevController(); |
| 27 |
| 28 bool Init(); |
| 29 |
| 30 private: |
| 31 static gboolean EventHandler(GIOChannel* source, |
| 32 GIOCondition condition, |
| 33 gpointer data); |
| 34 |
| 35 // The name of the DRM subsystem we are listening to. |
| 36 std::string subsystem_; |
| 37 |
| 38 // Delegate for udev event; not owned. |
| 39 UdevDelegate* delegate_; |
| 40 |
| 41 struct udev_monitor* monitor_; |
| 42 struct udev* udev_; |
| 43 DISALLOW_COPY_AND_ASSIGN(UdevController); |
| 44 }; |
| 45 |
| 46 } // namespace power_manager |
| 47 |
| 48 #endif // POWER_MANAGER_UDEV_CONTROLLER_H_ |
OLD | NEW |