| 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 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 #ifndef CONTENT_BROWSER_UDEV_LINUX_H_ | 36 #ifndef CONTENT_BROWSER_UDEV_LINUX_H_ |
| 37 #define CONTENT_BROWSER_UDEV_LINUX_H_ | 37 #define CONTENT_BROWSER_UDEV_LINUX_H_ |
| 38 | 38 |
| 39 #include <vector> | 39 #include <vector> |
| 40 | 40 |
| 41 #include "base/basictypes.h" | 41 #include "base/basictypes.h" |
| 42 #include "base/callback.h" | 42 #include "base/callback.h" |
| 43 #include "base/compiler_specific.h" | 43 #include "base/compiler_specific.h" |
| 44 #include "base/message_loop/message_pump_libevent.h" | 44 #include "base/message_loop/message_pump_libevent.h" |
| 45 #include "device/udev_linux/scoped_udev.h" |
| 45 | 46 |
| 46 extern "C" { | 47 extern "C" { |
| 47 struct udev; | 48 struct udev; |
| 48 struct udev_device; | 49 struct udev_device; |
| 49 struct udev_monitor; | 50 struct udev_monitor; |
| 50 } | 51 } |
| 51 | 52 |
| 52 namespace content { | 53 namespace content { |
| 53 | 54 |
| 54 class UdevLinux : public base::MessagePumpLibevent::Watcher { | 55 class UdevLinux : public base::MessagePumpLibevent::Watcher { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 76 // Returns the udev handle to be passed into other udev_*() functions. | 77 // Returns the udev handle to be passed into other udev_*() functions. |
| 77 udev* udev_handle(); | 78 udev* udev_handle(); |
| 78 | 79 |
| 79 private: | 80 private: |
| 80 // base::MessagePump:Libevent::Watcher implementation. | 81 // base::MessagePump:Libevent::Watcher implementation. |
| 81 virtual void OnFileCanReadWithoutBlocking(int fd) override; | 82 virtual void OnFileCanReadWithoutBlocking(int fd) override; |
| 82 virtual void OnFileCanWriteWithoutBlocking(int fd) override; | 83 virtual void OnFileCanWriteWithoutBlocking(int fd) override; |
| 83 | 84 |
| 84 // libudev-related items, the main context, and the monitoring context to be | 85 // libudev-related items, the main context, and the monitoring context to be |
| 85 // notified about changes to device states. | 86 // notified about changes to device states. |
| 86 udev* udev_; | 87 device::ScopedUdevPtr udev_; |
| 87 udev_monitor* monitor_; | 88 device::ScopedUdevMonitorPtr monitor_; |
| 88 int monitor_fd_; | 89 int monitor_fd_; |
| 89 base::MessagePumpLibevent::FileDescriptorWatcher monitor_watcher_; | 90 base::MessagePumpLibevent::FileDescriptorWatcher monitor_watcher_; |
| 90 UdevNotificationCallback callback_; | 91 UdevNotificationCallback callback_; |
| 91 | 92 |
| 92 DISALLOW_COPY_AND_ASSIGN(UdevLinux); | 93 DISALLOW_COPY_AND_ASSIGN(UdevLinux); |
| 93 }; | 94 }; |
| 94 | 95 |
| 95 } // namespace content | 96 } // namespace content |
| 96 | 97 |
| 97 #endif // CONTENT_BROWSER_UDEV_LINUX_H_ | 98 #endif // CONTENT_BROWSER_UDEV_LINUX_H_ |
| OLD | NEW |