| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // UdevLinux listens for device change notifications from udev and runs | 5 // UdevLinux listens for device change notifications from udev and runs |
| 6 // callbacks when notifications occur. | 6 // callbacks when notifications occur. |
| 7 // | 7 // |
| 8 // UdevLinux must be created on a MessageLoop of TYPE_IO. | 8 // UdevLinux must be created on a MessageLoop of TYPE_IO. |
| 9 // UdevLinux is not thread-safe. | 9 // UdevLinux is not thread-safe. |
| 10 // | 10 // |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 devtype(devtype_in) { | 64 devtype(devtype_in) { |
| 65 } | 65 } |
| 66 const char* subsystem; | 66 const char* subsystem; |
| 67 const char* devtype; | 67 const char* devtype; |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 // Filter incoming devices based on |filters|. | 70 // Filter incoming devices based on |filters|. |
| 71 // Calls |callback| upon device change events. | 71 // Calls |callback| upon device change events. |
| 72 UdevLinux(const std::vector<UdevMonitorFilter>& filters, | 72 UdevLinux(const std::vector<UdevMonitorFilter>& filters, |
| 73 const UdevNotificationCallback& callback); | 73 const UdevNotificationCallback& callback); |
| 74 virtual ~UdevLinux(); | 74 ~UdevLinux() override; |
| 75 | |
| 76 | 75 |
| 77 // Returns the udev handle to be passed into other udev_*() functions. | 76 // Returns the udev handle to be passed into other udev_*() functions. |
| 78 udev* udev_handle(); | 77 udev* udev_handle(); |
| 79 | 78 |
| 80 private: | 79 private: |
| 81 // base::MessagePump:Libevent::Watcher implementation. | 80 // base::MessagePump:Libevent::Watcher implementation. |
| 82 virtual void OnFileCanReadWithoutBlocking(int fd) override; | 81 void OnFileCanReadWithoutBlocking(int fd) override; |
| 83 virtual void OnFileCanWriteWithoutBlocking(int fd) override; | 82 void OnFileCanWriteWithoutBlocking(int fd) override; |
| 84 | 83 |
| 85 // libudev-related items, the main context, and the monitoring context to be | 84 // libudev-related items, the main context, and the monitoring context to be |
| 86 // notified about changes to device states. | 85 // notified about changes to device states. |
| 87 device::ScopedUdevPtr udev_; | 86 device::ScopedUdevPtr udev_; |
| 88 device::ScopedUdevMonitorPtr monitor_; | 87 device::ScopedUdevMonitorPtr monitor_; |
| 89 int monitor_fd_; | 88 int monitor_fd_; |
| 90 base::MessagePumpLibevent::FileDescriptorWatcher monitor_watcher_; | 89 base::MessagePumpLibevent::FileDescriptorWatcher monitor_watcher_; |
| 91 UdevNotificationCallback callback_; | 90 UdevNotificationCallback callback_; |
| 92 | 91 |
| 93 DISALLOW_COPY_AND_ASSIGN(UdevLinux); | 92 DISALLOW_COPY_AND_ASSIGN(UdevLinux); |
| 94 }; | 93 }; |
| 95 | 94 |
| 96 } // namespace content | 95 } // namespace content |
| 97 | 96 |
| 98 #endif // CONTENT_BROWSER_UDEV_LINUX_H_ | 97 #endif // CONTENT_BROWSER_UDEV_LINUX_H_ |
| OLD | NEW |