OLD | NEW |
| (Empty) |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // This class is used to detect device change and notify base::SystemMonitor | |
6 // on Linux. | |
7 | |
8 #ifndef MEDIA_CAPTURE_DEVICE_MONITOR_UDEV_H_ | |
9 #define MEDIA_CAPTURE_DEVICE_MONITOR_UDEV_H_ | |
10 | |
11 #include <memory> | |
12 | |
13 #include "base/macros.h" | |
14 #include "base/memory/ref_counted.h" | |
15 #include "base/message_loop/message_loop.h" | |
16 #include "base/single_thread_task_runner.h" | |
17 #include "media/capture/capture_export.h" | |
18 | |
19 extern "C" { | |
20 struct udev_device; | |
21 } | |
22 | |
23 namespace device { | |
24 class UdevLinux; | |
25 } | |
26 | |
27 namespace media { | |
28 | |
29 class CAPTURE_EXPORT DeviceMonitorLinux | |
30 : public base::MessageLoop::DestructionObserver { | |
31 public: | |
32 explicit DeviceMonitorLinux( | |
33 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); | |
34 ~DeviceMonitorLinux() override; | |
35 | |
36 // TODO(mcasas): Consider adding a StartMonitoring() method like | |
37 // DeviceMonitorMac to reduce startup impact time. | |
38 | |
39 private: | |
40 // This object is deleted on the constructor thread after |io_task_runner_| | |
41 // has been destroyed. Need to know when the latter is being destroyed so that | |
42 // we can delete |udev_|. | |
43 void WillDestroyCurrentMessageLoop() override; | |
44 | |
45 void Initialize(); | |
46 void OnDevicesChanged(udev_device* device); | |
47 | |
48 const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | |
49 | |
50 std::unique_ptr<device::UdevLinux> udev_; | |
51 | |
52 DISALLOW_COPY_AND_ASSIGN(DeviceMonitorLinux); | |
53 }; | |
54 | |
55 } // namespace media | |
56 | |
57 #endif // MEDIA_CAPTURE_DEVICE_MONITOR_UDEV_H_ | |
OLD | NEW |