OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef DEVICE_BASE_DEVICE_MONITOR_LINUX_H_ | 5 #ifndef DEVICE_BASE_DEVICE_MONITOR_LINUX_H_ |
6 #define DEVICE_BASE_DEVICE_MONITOR_LINUX_H_ | 6 #define DEVICE_BASE_DEVICE_MONITOR_LINUX_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | |
10 | 9 |
11 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
12 #include "base/files/file_descriptor_watcher_posix.h" | 11 #include "base/files/file_descriptor_watcher_posix.h" |
13 #include "base/macros.h" | 12 #include "base/macros.h" |
14 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
15 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
16 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
17 #include "device/base/device_base_export.h" | 16 #include "device/base/device_base_export.h" |
18 #include "device/udev_linux/scoped_udev.h" | 17 #include "device/udev_linux/scoped_udev.h" |
19 | 18 |
(...skipping 16 matching lines...) Expand all Loading... |
36 virtual void WillDestroyMonitorMessageLoop() = 0; | 35 virtual void WillDestroyMonitorMessageLoop() = 0; |
37 }; | 36 }; |
38 | 37 |
39 DeviceMonitorLinux(); | 38 DeviceMonitorLinux(); |
40 | 39 |
41 static DeviceMonitorLinux* GetInstance(); | 40 static DeviceMonitorLinux* GetInstance(); |
42 | 41 |
43 void AddObserver(Observer* observer); | 42 void AddObserver(Observer* observer); |
44 void RemoveObserver(Observer* observer); | 43 void RemoveObserver(Observer* observer); |
45 | 44 |
46 ScopedUdevDevicePtr GetDeviceFromPath(const std::string& path); | |
47 void Enumerate(const EnumerateCallback& callback); | 45 void Enumerate(const EnumerateCallback& callback); |
48 | 46 |
49 // Implements base::MessageLoop::DestructionObserver | 47 // Implements base::MessageLoop::DestructionObserver |
50 void WillDestroyCurrentMessageLoop() override; | 48 void WillDestroyCurrentMessageLoop() override; |
51 | 49 |
52 private: | 50 private: |
53 friend std::default_delete<DeviceMonitorLinux>; | 51 friend std::default_delete<DeviceMonitorLinux>; |
54 | 52 |
55 ~DeviceMonitorLinux() override; | 53 ~DeviceMonitorLinux() override; |
56 | 54 |
57 void OnMonitorCanReadWithoutBlocking(); | 55 void OnMonitorCanReadWithoutBlocking(); |
58 | 56 |
59 ScopedUdevPtr udev_; | 57 ScopedUdevPtr udev_; |
60 ScopedUdevMonitorPtr monitor_; | 58 ScopedUdevMonitorPtr monitor_; |
61 int monitor_fd_; | 59 int monitor_fd_; |
62 std::unique_ptr<base::FileDescriptorWatcher::Controller> | 60 std::unique_ptr<base::FileDescriptorWatcher::Controller> |
63 monitor_watch_controller_; | 61 monitor_watch_controller_; |
64 | 62 |
65 base::ObserverList<Observer, true> observers_; | 63 base::ObserverList<Observer, true> observers_; |
66 | 64 |
67 base::ThreadChecker thread_checker_; | 65 base::ThreadChecker thread_checker_; |
68 | 66 |
69 DISALLOW_COPY_AND_ASSIGN(DeviceMonitorLinux); | 67 DISALLOW_COPY_AND_ASSIGN(DeviceMonitorLinux); |
70 }; | 68 }; |
71 | 69 |
72 } // namespace device | 70 } // namespace device |
73 | 71 |
74 #endif // DEVICE_BASE_DEVICE_MONITOR_LINUX_H_ | 72 #endif // DEVICE_BASE_DEVICE_MONITOR_LINUX_H_ |
OLD | NEW |