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

Unified Diff: device/hid/udev_common.h

Issue 230503003: Udev-related methods are extracted from HidServiceLinux into individual service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup. Created 6 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 | « device/hid/hid_service_linux.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/hid/udev_common.h
diff --git a/device/hid/udev_common.h b/device/hid/udev_common.h
new file mode 100644
index 0000000000000000000000000000000000000000..6b9d5f8291b45d58090278f677a11a548c3eaa40
--- /dev/null
+++ b/device/hid/udev_common.h
@@ -0,0 +1,49 @@
+// Copyright 2014 The Chromium 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 DEVICE_HID_UDEV_COMMON_H_
+#define DEVICE_HID_UDEV_COMMON_H_
+
+#include <libudev.h>
+
+#include "base/memory/scoped_ptr.h"
+
+namespace device {
+
+template <typename T, void func(T*)>
+void DiscardReturnType(T* arg) {
+ func(arg);
+}
+
+template <typename T, T* func(T*)>
+void DiscardReturnType(T* arg) {
+ func(arg);
+}
+
+template <typename T, void func(T*)>
+struct Deleter {
+ void operator()(T* enumerate) const {
+ if (enumerate != NULL)
+ func(enumerate);
+ }
+};
+
+typedef Deleter<udev, DiscardReturnType<udev, udev_unref> > UdevDeleter;
+typedef Deleter<udev_enumerate,
+ DiscardReturnType<udev_enumerate, udev_enumerate_unref> >
+ UdevEnumerateDeleter;
+typedef Deleter<udev_device, DiscardReturnType<udev_device, udev_device_unref> >
+ UdevDeviceDeleter;
+typedef Deleter<udev_monitor,
+ DiscardReturnType<udev_monitor, udev_monitor_unref> >
+ UdevMonitorDeleter;
+
+typedef scoped_ptr<udev, UdevDeleter> ScopedUdevPtr;
+typedef scoped_ptr<udev_enumerate, UdevEnumerateDeleter> ScopedUdevEnumeratePtr;
+typedef scoped_ptr<udev_device, UdevDeviceDeleter> ScopedUdevDevicePtr;
+typedef scoped_ptr<udev_monitor, UdevMonitorDeleter> ScopedUdevMonitorPtr;
+
+} // namespace device
+
+#endif // DEVICE_HID_UDEV_COMMON_H_
« no previous file with comments | « device/hid/hid_service_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698