[email protected] | 1462544 | 2012-08-15 12:51:42 | [diff] [blame] | 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 | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #ifndef CONTENT_BROWSER_DEVICE_MONITOR_MAC_H_ | ||||
6 | #define CONTENT_BROWSER_DEVICE_MONITOR_MAC_H_ | ||||
7 | |||||
[email protected] | 1462544 | 2012-08-15 12:51:42 | [diff] [blame] | 8 | #include "base/basictypes.h" |
9 | #include "base/system_monitor/system_monitor.h" | ||||
[email protected] | 08f2c54c | 2014-03-12 09:27:25 | [diff] [blame] | 10 | #include "base/threading/thread_checker.h" |
[email protected] | 1462544 | 2012-08-15 12:51:42 | [diff] [blame] | 11 | |
[email protected] | 9396311a | 2013-11-07 11:49:42 | [diff] [blame] | 12 | namespace { |
13 | class DeviceMonitorMacImpl; | ||||
14 | } | ||||
15 | |||||
[email protected] | 1462544 | 2012-08-15 12:51:42 | [diff] [blame] | 16 | namespace content { |
17 | |||||
[email protected] | 9396311a | 2013-11-07 11:49:42 | [diff] [blame] | 18 | // Class to track audio/video devices removal or addition via callback to |
19 | // base::SystemMonitor ProcessDevicesChanged(). A single object of this class | ||||
20 | // is created from the browser main process and lives as long as this one. | ||||
[email protected] | 1462544 | 2012-08-15 12:51:42 | [diff] [blame] | 21 | class DeviceMonitorMac { |
22 | public: | ||||
23 | DeviceMonitorMac(); | ||||
24 | ~DeviceMonitorMac(); | ||||
25 | |||||
[email protected] | 08f2c54c | 2014-03-12 09:27:25 | [diff] [blame] | 26 | // Registers the observers for the audio/video device removal, connection and |
27 | // suspension. The AVFoundation library is also loaded and initialised if the | ||||
[email protected] | 01a891d | 2014-04-30 06:51:40 | [diff] [blame] | 28 | // OS supports it. The |device_task_runner| argument represents the thread on |
29 | // which device enumeration will occur. | ||||
30 | void StartMonitoring( | ||||
31 | const scoped_refptr<base::SingleThreadTaskRunner>& device_task_runner); | ||||
[email protected] | 08f2c54c | 2014-03-12 09:27:25 | [diff] [blame] | 32 | |
[email protected] | 9396311a | 2013-11-07 11:49:42 | [diff] [blame] | 33 | // Method called by the internal DeviceMonitorMacImpl object |
34 | // |device_monitor_impl_| when a device of type |type| has been added to or | ||||
35 | // removed from the system. This code executes in the notification thread | ||||
36 | // (QTKit or AVFoundation). | ||||
[email protected] | 1462544 | 2012-08-15 12:51:42 | [diff] [blame] | 37 | void NotifyDeviceChanged(base::SystemMonitor::DeviceType type); |
38 | |||||
[email protected] | 9396311a | 2013-11-07 11:49:42 | [diff] [blame] | 39 | private: |
40 | scoped_ptr<DeviceMonitorMacImpl> device_monitor_impl_; | ||||
41 | |||||
[email protected] | 08f2c54c | 2014-03-12 09:27:25 | [diff] [blame] | 42 | // |thread_checker_| is used to check that constructor and StartMonitoring() |
[email protected] | 01a891d | 2014-04-30 06:51:40 | [diff] [blame] | 43 | // are called in the correct thread, the UI thread, that also owns the object. |
[email protected] | 08f2c54c | 2014-03-12 09:27:25 | [diff] [blame] | 44 | base::ThreadChecker thread_checker_; |
45 | |||||
[email protected] | 1462544 | 2012-08-15 12:51:42 | [diff] [blame] | 46 | DISALLOW_COPY_AND_ASSIGN(DeviceMonitorMac); |
47 | }; | ||||
48 | |||||
49 | } // namespace content | ||||
50 | |||||
51 | #endif // CONTENT_BROWSER_DEVICE_MONITOR_MAC_H_ |