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