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 #ifndef CONTENT_BROWSER_DEVICE_MONITOR_MAC_H_ | 5 #ifndef CONTENT_BROWSER_DEVICE_MONITOR_MAC_H_ |
6 #define CONTENT_BROWSER_DEVICE_MONITOR_MAC_H_ | 6 #define CONTENT_BROWSER_DEVICE_MONITOR_MAC_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/system_monitor/system_monitor.h" | 9 #include "base/system_monitor/system_monitor.h" |
| 10 #include "base/threading/thread_checker.h" |
10 | 11 |
11 namespace { | 12 namespace { |
12 class DeviceMonitorMacImpl; | 13 class DeviceMonitorMacImpl; |
13 } | 14 } |
14 | 15 |
15 namespace content { | 16 namespace content { |
16 | 17 |
17 // Class to track audio/video devices removal or addition via callback to | 18 // Class to track audio/video devices removal or addition via callback to |
18 // base::SystemMonitor ProcessDevicesChanged(). A single object of this class | 19 // base::SystemMonitor ProcessDevicesChanged(). A single object of this class |
19 // is created from the browser main process and lives as long as this one. | 20 // is created from the browser main process and lives as long as this one. |
20 class DeviceMonitorMac { | 21 class DeviceMonitorMac { |
21 public: | 22 public: |
22 DeviceMonitorMac(); | 23 DeviceMonitorMac(); |
23 ~DeviceMonitorMac(); | 24 ~DeviceMonitorMac(); |
24 | 25 |
| 26 // Registers the observers for the audio/video device removal, connection and |
| 27 // suspension. The AVFoundation library is also loaded and initialised if the |
| 28 // OS supports it. |
| 29 void StartMonitoring(); |
| 30 |
25 // Method called by the internal DeviceMonitorMacImpl object | 31 // Method called by the internal DeviceMonitorMacImpl object |
26 // |device_monitor_impl_| when a device of type |type| has been added to or | 32 // |device_monitor_impl_| when a device of type |type| has been added to or |
27 // removed from the system. This code executes in the notification thread | 33 // removed from the system. This code executes in the notification thread |
28 // (QTKit or AVFoundation). | 34 // (QTKit or AVFoundation). |
29 void NotifyDeviceChanged(base::SystemMonitor::DeviceType type); | 35 void NotifyDeviceChanged(base::SystemMonitor::DeviceType type); |
30 | 36 |
31 private: | 37 private: |
32 scoped_ptr<DeviceMonitorMacImpl> device_monitor_impl_; | 38 scoped_ptr<DeviceMonitorMacImpl> device_monitor_impl_; |
33 | 39 |
| 40 // |thread_checker_| is used to check that constructor and StartMonitoring() |
| 41 // are called in the correct thread, that also owns the object. |
| 42 base::ThreadChecker thread_checker_; |
| 43 |
34 DISALLOW_COPY_AND_ASSIGN(DeviceMonitorMac); | 44 DISALLOW_COPY_AND_ASSIGN(DeviceMonitorMac); |
35 }; | 45 }; |
36 | 46 |
37 } // namespace content | 47 } // namespace content |
38 | 48 |
39 #endif // CONTENT_BROWSER_DEVICE_MONITOR_MAC_H_ | 49 #endif // CONTENT_BROWSER_DEVICE_MONITOR_MAC_H_ |
OLD | NEW |