Chromium Code Reviews| Index: content/browser/device_monitor_mac.mm |
| diff --git a/content/browser/device_monitor_mac.mm b/content/browser/device_monitor_mac.mm |
| index 34d1916008d3011391c44b976dabcf1c1ce1430b..62890285548ac6c1f193ab5976cbcb7000070e28 100644 |
| --- a/content/browser/device_monitor_mac.mm |
| +++ b/content/browser/device_monitor_mac.mm |
| @@ -204,14 +204,14 @@ void QTKitMonitorImpl::OnDeviceChanged() { |
| ConsolidateDevicesListAndNotify(snapshot_devices); |
| } |
| -// Forward declaration for use by CrAVFoundationSuspendObserver. |
| +// Forward declaration for use by CrAVFoundationDeviceObserver. |
| class AVFoundationMonitorImpl; |
| } // namespace |
| // This class is a Key-Value Observer (KVO) shim. It is needed because C++ |
| // classes cannot observe Key-Values directly. |
| -@interface CrAVFoundationSuspendObserver : NSObject { |
| +@interface CrAVFoundationDeviceObserver : NSObject { |
| @private |
| AVFoundationMonitorImpl* receiver_; |
| } |
| @@ -232,7 +232,7 @@ class AVFoundationMonitorImpl : public DeviceMonitorMacImpl { |
| virtual void OnDeviceChanged() OVERRIDE; |
| private: |
| - base::scoped_nsobject<CrAVFoundationSuspendObserver> suspend_observer_; |
| + base::scoped_nsobject<CrAVFoundationDeviceObserver> suspend_observer_; |
| DISALLOW_COPY_AND_ASSIGN(AVFoundationMonitorImpl); |
| }; |
| @@ -255,7 +255,7 @@ AVFoundationMonitorImpl::AVFoundationMonitorImpl( |
| usingBlock:^(NSNotification* notification) { |
| OnDeviceChanged();}]; |
| suspend_observer_.reset( |
| - [[CrAVFoundationSuspendObserver alloc] initWithChangeReceiver:this]); |
| + [[CrAVFoundationDeviceObserver alloc] initWithChangeReceiver:this]); |
| for (CrAVCaptureDevice* device in [AVCaptureDeviceGlue devices]) |
| [suspend_observer_ startObserving:device]; |
| } |
| @@ -292,7 +292,7 @@ void AVFoundationMonitorImpl::OnDeviceChanged() { |
| } // namespace |
| -@implementation CrAVFoundationSuspendObserver |
| +@implementation CrAVFoundationDeviceObserver |
| - (id)initWithChangeReceiver:(AVFoundationMonitorImpl*)receiver { |
| if ((self = [super init])) { |
| @@ -307,13 +307,19 @@ void AVFoundationMonitorImpl::OnDeviceChanged() { |
| [device addObserver:self |
| forKeyPath:@"suspended" |
| options:0 |
| - context:nil]; |
| + context:device]; |
| + [device addObserver:self |
| + forKeyPath:@"connected" |
| + options:0 |
| + context:device]; |
| } |
| - (void)stopObserving:(CrAVCaptureDevice*)device { |
| DCHECK(device != nil); |
| [device removeObserver:self |
| forKeyPath:@"suspended"]; |
| + [device removeObserver:self |
| + forKeyPath:@"connected"]; |
| } |
| - (void)observeValueForKeyPath:(NSString*)keyPath |
| @@ -322,9 +328,12 @@ void AVFoundationMonitorImpl::OnDeviceChanged() { |
| context:(void*)context { |
| if ([keyPath isEqual:@"suspended"]) |
| receiver_->OnDeviceChanged(); |
| + if ([keyPath isEqual:@"connected"]) { |
|
Robert Sesek
2014/03/06 17:08:20
nit: you don't have braces around the other if, so
mcasas
2014/03/06 17:21:58
Done.
Apologies, forgot them after removing debug
|
| + [self stopObserving:(CrAVCaptureDevice*)context]; |
|
Robert Sesek
2014/03/06 17:08:20
static_cast
mcasas
2014/03/06 17:21:58
Done.
|
| + } |
| } |
| -@end // @implementation CrAVFoundationSuspendObserver |
| +@end // @implementation CrAVFoundationDeviceObserver |
| namespace content { |