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

Unified Diff: device/udev_linux/udev_loader.h

Issue 674703002: Linux: Dynamically load libudev. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scoped_udev
Patch Set: rebase to head, which includes third_party/libudev already Created 6 years, 1 month 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/udev_linux/udev1_loader.cc ('k') | device/udev_linux/udev_loader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/udev_linux/udev_loader.h
diff --git a/device/udev_linux/udev_loader.h b/device/udev_linux/udev_loader.h
new file mode 100644
index 0000000000000000000000000000000000000000..9160a89d34fef0e5661c9e14832be16973bf7789
--- /dev/null
+++ b/device/udev_linux/udev_loader.h
@@ -0,0 +1,91 @@
+// 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_UDEV_LINUX_UDEV_LOADER_H_
+#define DEVICE_UDEV_LINUX_UDEV_LOADER_H_
+
+#include <stdarg.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#if !defined(USE_UDEV)
+#error "USE_UDEV not defined"
+#endif
+
+struct udev;
+struct udev_device;
+struct udev_enumerate;
+struct udev_list_entry;
+struct udev_monitor;
+
+namespace device {
+
+// Interface to libudev. Accessed through the static Get() function, which
+// will try to load libudev1 first and then libudev0 on first use. If neither
+// libraries load successfully, the program will fail with a crash.
+//
+// All the methods have the same signatures as libudev's functions. e.g.
+// udev_monitor_get_fd(mon) simply becomes device::udev_monitor_get_fd(mon).
+class UdevLoader {
+ public:
+ static UdevLoader* Get();
+
+ virtual ~UdevLoader();
+
+ virtual bool Init() = 0;
+
+ virtual const char* udev_device_get_action(udev_device* udev_device) = 0;
+ virtual const char* udev_device_get_devnode(udev_device* udev_device) = 0;
+ virtual udev_device* udev_device_get_parent(udev_device* udev_device) = 0;
+ virtual udev_device* udev_device_get_parent_with_subsystem_devtype(
+ udev_device* udev_device,
+ const char* subsystem,
+ const char* devtype) = 0;
+ virtual const char* udev_device_get_property_value(udev_device* udev_device,
+ const char* key) = 0;
+ virtual const char* udev_device_get_subsystem(udev_device* udev_device) = 0;
+ virtual const char* udev_device_get_sysattr_value(udev_device* udev_device,
+ const char* sysattr) = 0;
+ virtual const char* udev_device_get_sysname(udev_device* udev_device) = 0;
+ virtual const char* udev_device_get_syspath(udev_device* udev_device) = 0;
+ virtual udev_device* udev_device_new_from_devnum(udev* udev,
+ char type,
+ dev_t devnum) = 0;
+ virtual udev_device* udev_device_new_from_syspath(udev* udev,
+ const char* syspath) = 0;
+ virtual void udev_device_unref(udev_device* udev_device) = 0;
+ virtual int udev_enumerate_add_match_subsystem(udev_enumerate* udev_enumerate,
+ const char* subsystem) = 0;
+ virtual udev_list_entry* udev_enumerate_get_list_entry(
+ udev_enumerate* udev_enumerate) = 0;
+ virtual udev_enumerate* udev_enumerate_new(udev* udev) = 0;
+ virtual int udev_enumerate_scan_devices(udev_enumerate* udev_enumerate) = 0;
+ virtual void udev_enumerate_unref(udev_enumerate* udev_enumerate) = 0;
+ virtual udev_list_entry* udev_list_entry_get_next(
+ udev_list_entry* list_entry) = 0;
+ virtual const char* udev_list_entry_get_name(udev_list_entry* list_entry) = 0;
+ virtual int udev_monitor_enable_receiving(udev_monitor* udev_monitor) = 0;
+ virtual int udev_monitor_filter_add_match_subsystem_devtype(
+ udev_monitor* udev_monitor,
+ const char* subsystem,
+ const char* devtype) = 0;
+ virtual int udev_monitor_get_fd(udev_monitor* udev_monitor) = 0;
+ virtual udev_monitor* udev_monitor_new_from_netlink(udev* udev,
+ const char* name) = 0;
+ virtual udev_device* udev_monitor_receive_device(
+ udev_monitor* udev_monitor) = 0;
+ virtual void udev_monitor_unref(udev_monitor* udev_monitor) = 0;
+ virtual udev* udev_new() = 0;
+ virtual void udev_set_log_fn(
+ struct udev* udev,
+ void (*log_fn)(struct udev* udev, int priority,
+ const char* file, int line,
+ const char* fn, const char* format, va_list args)) = 0;
+ virtual void udev_set_log_priority(struct udev* udev, int priority) = 0;
+ virtual void udev_unref(udev* udev) = 0;
+};
+
+} // namespace device
+
+#endif // DEVICE_UDEV_LINUX_UDEV_LOADER_H_
« no previous file with comments | « device/udev_linux/udev1_loader.cc ('k') | device/udev_linux/udev_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698