| OLD | NEW | 
|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "device/bluetooth/bluetooth_discovery_manager_mac.h" | 5 #include "device/bluetooth/bluetooth_discovery_manager_mac.h" | 
| 6 | 6 | 
| 7 #import <IOBluetooth/objc/IOBluetoothDevice.h> | 7 #import <IOBluetooth/objc/IOBluetoothDevice.h> | 
| 8 #import <IOBluetooth/objc/IOBluetoothDeviceInquiry.h> | 8 #import <IOBluetooth/objc/IOBluetoothDeviceInquiry.h> | 
| 9 | 9 | 
| 10 #include "base/logging.h" | 10 #include "base/logging.h" | 
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 117       [inquiry stop]; | 117       [inquiry stop]; | 
| 118       return; | 118       return; | 
| 119     } | 119     } | 
| 120 | 120 | 
| 121     inquiry_running_ = true; | 121     inquiry_running_ = true; | 
| 122   } | 122   } | 
| 123 | 123 | 
| 124   void DeviceFound(IOBluetoothDeviceInquiry* inquiry, | 124   void DeviceFound(IOBluetoothDeviceInquiry* inquiry, | 
| 125                    IOBluetoothDevice* device) { | 125                    IOBluetoothDevice* device) { | 
| 126     DCHECK(observer_); | 126     DCHECK(observer_); | 
| 127     observer_->DeviceFound(device); | 127     observer_->ClassicDeviceFound(device); | 
| 128   } | 128   } | 
| 129 | 129 | 
| 130   void DeviceInquiryComplete(IOBluetoothDeviceInquiry* inquiry, | 130   void DeviceInquiryComplete(IOBluetoothDeviceInquiry* inquiry, | 
| 131                              IOReturn error, | 131                              IOReturn error, | 
| 132                              bool aborted) { | 132                              bool aborted) { | 
| 133     DCHECK_EQ(inquiry_, inquiry); | 133     DCHECK_EQ(inquiry_, inquiry); | 
| 134     DCHECK(observer_); | 134     DCHECK(observer_); | 
| 135     DVLOG(1) << "Device inquiry complete"; | 135     DVLOG(1) << "Device inquiry complete"; | 
| 136     inquiry_running_ = false; | 136     inquiry_running_ = false; | 
| 137 | 137 | 
| 138     // If discovery is no longer desired, notify observers that discovery | 138     // If discovery is no longer desired, notify observers that discovery | 
| 139     // has stopped and return. | 139     // has stopped and return. | 
| 140     if (!should_do_discovery_) { | 140     if (!should_do_discovery_) { | 
| 141       observer_->DiscoveryStopped(false /* unexpected */); | 141       observer_->ClassicDiscoveryStopped(false /* unexpected */); | 
| 142       return; | 142       return; | 
| 143     } | 143     } | 
| 144 | 144 | 
| 145     // If discovery has stopped due to an unexpected reason, notify the | 145     // If discovery has stopped due to an unexpected reason, notify the | 
| 146     // observers and return. | 146     // observers and return. | 
| 147     if (error != kIOReturnSuccess) { | 147     if (error != kIOReturnSuccess) { | 
| 148       DVLOG(1) << "Inquiry has stopped with an error: " << error; | 148       DVLOG(1) << "Inquiry has stopped with an error: " << error; | 
| 149       should_do_discovery_ = false; | 149       should_do_discovery_ = false; | 
| 150       observer_->DiscoveryStopped(true /* unexpected */); | 150       observer_->ClassicDiscoveryStopped(true /* unexpected */); | 
| 151       return; | 151       return; | 
| 152     } | 152     } | 
| 153 | 153 | 
| 154     DVLOG(1) << "Restarting device inquiry"; | 154     DVLOG(1) << "Restarting device inquiry"; | 
| 155 | 155 | 
| 156     if ([inquiry_ start] == kIOReturnSuccess) { | 156     if ([inquiry_ start] == kIOReturnSuccess) { | 
| 157       DVLOG(1) << "Device inquiry restart was successful"; | 157       DVLOG(1) << "Device inquiry restart was successful"; | 
| 158       return; | 158       return; | 
| 159     } | 159     } | 
| 160 | 160 | 
| 161     DVLOG(1) << "Failed to restart discovery"; | 161     DVLOG(1) << "Failed to restart discovery"; | 
| 162     should_do_discovery_ = false; | 162     should_do_discovery_ = false; | 
| 163     DCHECK(observer_); | 163     DCHECK(observer_); | 
| 164     observer_->DiscoveryStopped(true /* unexpected */); | 164     observer_->ClassicDiscoveryStopped(true /* unexpected */); | 
| 165   } | 165   } | 
| 166 | 166 | 
| 167  private: | 167  private: | 
| 168   // The requested discovery state. | 168   // The requested discovery state. | 
| 169   bool should_do_discovery_; | 169   bool should_do_discovery_; | 
| 170 | 170 | 
| 171   // The current inquiry state. | 171   // The current inquiry state. | 
| 172   bool inquiry_running_; | 172   bool inquiry_running_; | 
| 173 | 173 | 
| 174   // Objective-C objects for running and tracking device inquiry. | 174   // Objective-C objects for running and tracking device inquiry. | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 213   manager_->DeviceFound(sender, device); | 213   manager_->DeviceFound(sender, device); | 
| 214 } | 214 } | 
| 215 | 215 | 
| 216 - (void)deviceInquiryComplete:(IOBluetoothDeviceInquiry*)sender | 216 - (void)deviceInquiryComplete:(IOBluetoothDeviceInquiry*)sender | 
| 217                         error:(IOReturn)error | 217                         error:(IOReturn)error | 
| 218                       aborted:(BOOL)aborted { | 218                       aborted:(BOOL)aborted { | 
| 219   manager_->DeviceInquiryComplete(sender, error, aborted); | 219   manager_->DeviceInquiryComplete(sender, error, aborted); | 
| 220 } | 220 } | 
| 221 | 221 | 
| 222 @end | 222 @end | 
| OLD | NEW | 
|---|