1 // Copyright 2014 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef SERVICES_DEVICE_SERIAL_SERIAL_DEVICE_ENUMERATOR_LINUX_H_
6 #define SERVICES_DEVICE_SERIAL_SERIAL_DEVICE_ENUMERATOR_LINUX_H_
12 #include "device/udev_linux/udev_watcher.h"
13 #include "services/device/serial/serial_device_enumerator.h"
17 // Discovers and enumerates serial devices available to the host.
18 class SerialDeviceEnumeratorLinux : public SerialDeviceEnumerator,
19 public UdevWatcher::Observer {
21 static std::unique_ptr<SerialDeviceEnumeratorLinux> Create();
23 explicit SerialDeviceEnumeratorLinux(
24 const base::FilePath& tty_driver_info_path);
26 SerialDeviceEnumeratorLinux(const SerialDeviceEnumeratorLinux&) = delete;
27 SerialDeviceEnumeratorLinux& operator=(const SerialDeviceEnumeratorLinux&) =
30 ~SerialDeviceEnumeratorLinux() override;
32 // UdevWatcher::Observer
33 void OnDeviceAdded(ScopedUdevDevicePtr device) override;
34 void OnDeviceChanged(ScopedUdevDevicePtr device) override;
35 void OnDeviceRemoved(ScopedUdevDevicePtr device) override;
38 void CreatePort(ScopedUdevDevicePtr device, const std::string& syspath);
40 std::unique_ptr<UdevWatcher> watcher_;
41 const base::FilePath tty_driver_info_path_;
42 std::map<std::string, base::UnguessableToken> paths_;
47 #endif // SERVICES_DEVICE_SERIAL_SERIAL_DEVICE_ENUMERATOR_LINUX_H_