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

Unified Diff: device/hid/hid_connection_linux.cc

Issue 225513005: chrome.hid : enrich device info with Top-Level collections usages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: HidUsageAndPage::Page 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_connection_linux.h ('k') | device/hid/hid_device_info.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/hid/hid_connection_linux.cc
diff --git a/device/hid/hid_connection_linux.cc b/device/hid/hid_connection_linux.cc
index 936c7b1bd23fe95a13c2fd29453fe2119ab59089..62370a1fc08a0dad9393a98af110deb6bf9f5336 100644
--- a/device/hid/hid_connection_linux.cc
+++ b/device/hid/hid_connection_linux.cc
@@ -42,22 +42,13 @@ scoped_refptr<net::IOBufferWithSize> CopyBufferWithReportId(
return new_buffer;
}
-const char kHidrawSubsystem[] = "hidraw";
-
} // namespace
HidConnectionLinux::HidConnectionLinux(HidDeviceInfo device_info,
- ScopedUdevDevicePtr udev_raw_device)
+ std::string dev_node)
: HidConnection(device_info) {
DCHECK(thread_checker_.CalledOnValidThread());
- udev_device* dev = udev_raw_device.get();
- std::string dev_node;
- if (!FindHidrawDevNode(dev, &dev_node)) {
- LOG(ERROR) << "Cannot open HID device as hidraw device.";
- return;
- }
-
int flags = base::File::FLAG_OPEN |
base::File::FLAG_READ |
base::File::FLAG_WRITE;
@@ -204,44 +195,4 @@ void HidConnectionLinux::ProcessReadQueue() {
}
}
-bool HidConnectionLinux::FindHidrawDevNode(udev_device* parent,
- std::string* result) {
- udev* udev = udev_device_get_udev(parent);
- if (!udev) {
- return false;
- }
- ScopedUdevEnumeratePtr enumerate(udev_enumerate_new(udev));
- if (!enumerate) {
- return false;
- }
- if (udev_enumerate_add_match_subsystem(enumerate.get(), kHidrawSubsystem)) {
- return false;
- }
- if (udev_enumerate_scan_devices(enumerate.get())) {
- return false;
- }
- std::string parent_path(udev_device_get_devpath(parent));
- if (parent_path.length() == 0 || *parent_path.rbegin() != '/')
- parent_path += '/';
- udev_list_entry* devices = udev_enumerate_get_list_entry(enumerate.get());
- for (udev_list_entry* i = devices; i != NULL;
- i = udev_list_entry_get_next(i)) {
- ScopedUdevDevicePtr hid_dev(
- udev_device_new_from_syspath(udev, udev_list_entry_get_name(i)));
- const char* raw_path = udev_device_get_devnode(hid_dev.get());
- std::string device_path = udev_device_get_devpath(hid_dev.get());
- if (raw_path &&
- !device_path.compare(0, parent_path.length(), parent_path)) {
- std::string sub_path = device_path.substr(parent_path.length());
- if (sub_path.substr(0, sizeof(kHidrawSubsystem)-1) == kHidrawSubsystem) {
- *result = raw_path;
- return true;
- }
- }
- }
-
- return false;
-}
-
} // namespace device
-
« no previous file with comments | « device/hid/hid_connection_linux.h ('k') | device/hid/hid_device_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698