Commit a3a36a42 authored by Reilly Grant's avatar Reilly Grant Committed by Commit Bot

Revert "Use UdevWatcher to filter USB, HID and serial devices"

This reverts commit 35f83455.

Reason for revert: This appears to be tickling a udev bug which causes crbug/1121007.

Original change's description:
> Use UdevWatcher to filter USB, HID and serial devices
>
> UsbServiceLinux, HidServiceLinux and SerialDeviceEnumeratorLinux each
> only care about devices from a particular subsystem. This change avoids
> processing other devices which should decrease the time it takes to
> perform the initial enumeration.
>
> Change-Id: I3535b5e6ecbb8c013957197cff151011a19a6097
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2227094
> Commit-Queue: Reilly Grant <reillyg@chromium.org>
> Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
> Reviewed-by: Matt Reynolds <mattreynolds@chromium.org>
> Auto-Submit: Reilly Grant <reillyg@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#774416}

Bug: 1121007
Change-Id: Ic6a69eb2bf3825ecbc9cb310bc71eb37d647d1c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2429232Reviewed-by: default avatarKen Rockot <rockot@google.com>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Commit-Queue: Reilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810868}
parent 8e0c4c72
......@@ -205,8 +205,7 @@ class HidServiceLinux::BlockingTaskRunnerHelper : public UdevWatcher::Observer {
void Start() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
watcher_ = UdevWatcher::StartWatching(
this, {UdevWatcher::Filter(kSubsystemHidraw, "")});
watcher_ = UdevWatcher::StartWatching(this);
watcher_->EnumerateExistingDevices();
task_runner_->PostTask(
FROM_HERE,
......@@ -225,11 +224,9 @@ class HidServiceLinux::BlockingTaskRunnerHelper : public UdevWatcher::Observer {
return;
HidPlatformDeviceId platform_device_id = device_path;
#if DCHECK_IS_ON()
const char* subsystem = udev_device_get_subsystem(device.get());
DCHECK(subsystem);
DCHECK_EQ(base::StringPiece(subsystem), kSubsystemHidraw);
#endif
if (!subsystem || strcmp(subsystem, kSubsystemHidraw) != 0)
return;
const char* str_property = udev_device_get_devnode(device.get());
if (!str_property)
......
......@@ -23,8 +23,6 @@ namespace device {
namespace {
constexpr char kSubsystemTty[] = "tty";
// Holds information about a TTY driver for serial devices. Each driver creates
// device nodes with a given major number and in a range of minor numbers.
struct SerialDriverInfo {
......@@ -95,8 +93,7 @@ SerialDeviceEnumeratorLinux::SerialDeviceEnumeratorLinux(
: tty_driver_info_path_(tty_driver_info_path) {
DETACH_FROM_SEQUENCE(sequence_checker_);
watcher_ = UdevWatcher::StartWatching(
this, {UdevWatcher::Filter(kSubsystemTty, "")});
watcher_ = UdevWatcher::StartWatching(this);
if (watcher_)
watcher_->EnumerateExistingDevices();
}
......@@ -110,11 +107,9 @@ void SerialDeviceEnumeratorLinux::OnDeviceAdded(ScopedUdevDevicePtr device) {
base::ScopedBlockingCall scoped_blocking_call(FROM_HERE,
base::BlockingType::MAY_BLOCK);
#if DCHECK_IS_ON()
const char* subsystem = udev_device_get_subsystem(device.get());
DCHECK(subsystem);
DCHECK_EQ(base::StringPiece(subsystem), kSubsystemTty);
#endif
if (!subsystem || strcmp(subsystem, "tty") != 0)
return;
const char* syspath_str = udev_device_get_syspath(device.get());
if (!syspath_str)
......
......@@ -34,8 +34,6 @@ namespace device {
namespace {
constexpr char kSubsystemUsb[] = "usb";
// Standard USB requests and descriptor types:
const uint16_t kUsbVersion2_1 = 0x0210;
......@@ -111,8 +109,7 @@ void UsbServiceLinux::BlockingTaskRunnerHelper::Start() {
// Initializing udev for device enumeration and monitoring may fail. In that
// case this service will continue to exist but no devices will be found.
watcher_ = UdevWatcher::StartWatching(
this, {UdevWatcher::Filter(kSubsystemUsb, "")});
watcher_ = UdevWatcher::StartWatching(this);
if (watcher_)
watcher_->EnumerateExistingDevices();
......@@ -126,12 +123,9 @@ void UsbServiceLinux::BlockingTaskRunnerHelper::OnDeviceAdded(
base::ScopedBlockingCall scoped_blocking_call(FROM_HERE,
base::BlockingType::MAY_BLOCK);
#if DCHECK_IS_ON()
const char* subsystem = udev_device_get_subsystem(device.get());
DCHECK(subsystem);
DCHECK_EQ(base::StringPiece(subsystem), kSubsystemUsb);
#endif
if (!subsystem || strcmp(subsystem, "usb") != 0)
return;
const char* value = udev_device_get_devnode(device.get());
if (!value)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment