| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_SYSTEM_MONITOR_UDEV_UTIL_LINUX_H_ | 5 #ifndef CHROME_BROWSER_SYSTEM_MONITOR_UDEV_UTIL_LINUX_H_ |
| 6 #define CHROME_BROWSER_SYSTEM_MONITOR_UDEV_UTIL_LINUX_H_ | 6 #define CHROME_BROWSER_SYSTEM_MONITOR_UDEV_UTIL_LINUX_H_ |
| 7 | 7 |
| 8 #include <libudev.h> | 8 #include <libudev.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/memory/scoped_generic_obj.h" | 12 #include "base/memory/scoped_generic_obj.h" |
| 13 | 13 |
| 14 namespace base { |
| 14 class FilePath; | 15 class FilePath; |
| 16 } |
| 15 | 17 |
| 16 namespace chrome { | 18 namespace chrome { |
| 17 | 19 |
| 18 // ScopedGenericObj functor for UdevObjectRelease(). | 20 // ScopedGenericObj functor for UdevObjectRelease(). |
| 19 class ScopedReleaseUdevObject { | 21 class ScopedReleaseUdevObject { |
| 20 public: | 22 public: |
| 21 void operator()(struct udev* udev) const { | 23 void operator()(struct udev* udev) const { |
| 22 udev_unref(udev); | 24 udev_unref(udev); |
| 23 } | 25 } |
| 24 }; | 26 }; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 35 typedef ScopedGenericObj<struct udev_device*, | 37 typedef ScopedGenericObj<struct udev_device*, |
| 36 ScopedReleaseUdevDeviceObject> ScopedUdevDeviceObject; | 38 ScopedReleaseUdevDeviceObject> ScopedUdevDeviceObject; |
| 37 | 39 |
| 38 // Wrapper function for udev_device_get_property_value() that also checks for | 40 // Wrapper function for udev_device_get_property_value() that also checks for |
| 39 // valid but empty values. | 41 // valid but empty values. |
| 40 std::string GetUdevDevicePropertyValue(struct udev_device* udev_device, | 42 std::string GetUdevDevicePropertyValue(struct udev_device* udev_device, |
| 41 const char* key); | 43 const char* key); |
| 42 | 44 |
| 43 // Helper for udev_device_new_from_syspath()/udev_device_get_property_value() | 45 // Helper for udev_device_new_from_syspath()/udev_device_get_property_value() |
| 44 // pair. |device_path| is the absolute path to the device, including /sys. | 46 // pair. |device_path| is the absolute path to the device, including /sys. |
| 45 bool GetUdevDevicePropertyValueByPath(const FilePath& device_path, | 47 bool GetUdevDevicePropertyValueByPath(const base::FilePath& device_path, |
| 46 const char* key, | 48 const char* key, |
| 47 std::string* result); | 49 std::string* result); |
| 48 | 50 |
| 49 } // namespace chrome | 51 } // namespace chrome |
| 50 | 52 |
| 51 #endif // CHROME_BROWSER_SYSTEM_MONITOR_UDEV_UTIL_LINUX_H_ | 53 #endif // CHROME_BROWSER_SYSTEM_MONITOR_UDEV_UTIL_LINUX_H_ |
| OLD | NEW |