| 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_STORAGE_MONITOR_UDEV_UTIL_LINUX_H_ | 5 #ifndef CHROME_BROWSER_STORAGE_MONITOR_UDEV_UTIL_LINUX_H_ |
| 6 #define CHROME_BROWSER_STORAGE_MONITOR_UDEV_UTIL_LINUX_H_ | 6 #define CHROME_BROWSER_STORAGE_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_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 | 13 |
| 14 namespace base { | 14 namespace base { |
| 15 class FilePath; | 15 class FilePath; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace chrome { | |
| 19 | |
| 20 // Deleter for ScopedUdevObject. | 18 // Deleter for ScopedUdevObject. |
| 21 struct UdevDeleter { | 19 struct UdevDeleter { |
| 22 void operator()(struct udev* udev); | 20 void operator()(struct udev* udev); |
| 23 }; | 21 }; |
| 24 typedef scoped_ptr<struct udev, UdevDeleter> ScopedUdevObject; | 22 typedef scoped_ptr<struct udev, UdevDeleter> ScopedUdevObject; |
| 25 | 23 |
| 26 // Deleter for ScopedUdevDeviceObject(). | 24 // Deleter for ScopedUdevDeviceObject(). |
| 27 struct UdevDeviceDeleter { | 25 struct UdevDeviceDeleter { |
| 28 void operator()(struct udev_device* device); | 26 void operator()(struct udev_device* device); |
| 29 }; | 27 }; |
| 30 typedef scoped_ptr<struct udev_device, UdevDeviceDeleter> | 28 typedef scoped_ptr<struct udev_device, UdevDeviceDeleter> |
| 31 ScopedUdevDeviceObject; | 29 ScopedUdevDeviceObject; |
| 32 | 30 |
| 33 // Wrapper function for udev_device_get_property_value() that also checks for | 31 // Wrapper function for udev_device_get_property_value() that also checks for |
| 34 // valid but empty values. | 32 // valid but empty values. |
| 35 std::string GetUdevDevicePropertyValue(struct udev_device* udev_device, | 33 std::string GetUdevDevicePropertyValue(struct udev_device* udev_device, |
| 36 const char* key); | 34 const char* key); |
| 37 | 35 |
| 38 // Helper for udev_device_new_from_syspath()/udev_device_get_property_value() | 36 // Helper for udev_device_new_from_syspath()/udev_device_get_property_value() |
| 39 // pair. |device_path| is the absolute path to the device, including /sys. | 37 // pair. |device_path| is the absolute path to the device, including /sys. |
| 40 bool GetUdevDevicePropertyValueByPath(const base::FilePath& device_path, | 38 bool GetUdevDevicePropertyValueByPath(const base::FilePath& device_path, |
| 41 const char* key, | 39 const char* key, |
| 42 std::string* result); | 40 std::string* result); |
| 43 | 41 |
| 44 } // namespace chrome | |
| 45 | |
| 46 #endif // CHROME_BROWSER_STORAGE_MONITOR_UDEV_UTIL_LINUX_H_ | 42 #endif // CHROME_BROWSER_STORAGE_MONITOR_UDEV_UTIL_LINUX_H_ |
| OLD | NEW |