Chromium Code Reviews| 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 #include "device/bluetooth/bluetooth_adapter_mac.h" | 5 #include "device/bluetooth/bluetooth_adapter_mac.h" |
| 6 | 6 |
| 7 #import <IOBluetooth/objc/IOBluetoothDevice.h> | 7 #import <IOBluetooth/objc/IOBluetoothDevice.h> |
| 8 #import <IOBluetooth/objc/IOBluetoothHostController.h> | 8 #import <IOBluetooth/objc/IOBluetoothHostController.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 | 10 |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 634 } | 634 } |
| 635 } | 635 } |
| 636 connected_devices.push_back(device_mac); | 636 connected_devices.push_back(device_mac); |
| 637 VLOG(1) << *device_mac << ": New connected device."; | 637 VLOG(1) << *device_mac << ": New connected device."; |
| 638 } | 638 } |
| 639 return connected_devices; | 639 return connected_devices; |
| 640 } | 640 } |
| 641 | 641 |
| 642 void BluetoothAdapterMac::CreateGattConnection( | 642 void BluetoothAdapterMac::CreateGattConnection( |
| 643 BluetoothLowEnergyDeviceMac* device_mac) { | 643 BluetoothLowEnergyDeviceMac* device_mac) { |
| 644 DCHECK(device_mac); | |
|
scheib
2017/03/30 22:48:41
This DCHECK is redundant with the "*device_mac" is
jlebel
2017/03/30 23:16:08
It will crash, but somewhere in operator<< related
jlebel
2017/03/31 07:39:12
Done.
| |
| 645 VLOG(1) << *device_mac << ": Create gatt connection."; | |
| 644 [low_energy_central_manager_ connectPeripheral:device_mac->peripheral_ | 646 [low_energy_central_manager_ connectPeripheral:device_mac->peripheral_ |
| 645 options:nil]; | 647 options:nil]; |
| 646 } | 648 } |
| 647 | 649 |
| 648 void BluetoothAdapterMac::DisconnectGatt( | 650 void BluetoothAdapterMac::DisconnectGatt( |
| 649 BluetoothLowEnergyDeviceMac* device_mac) { | 651 BluetoothLowEnergyDeviceMac* device_mac) { |
| 652 DCHECK(device_mac); | |
| 653 VLOG(1) << *device_mac << ": Disconnect gatt."; | |
| 650 [low_energy_central_manager_ | 654 [low_energy_central_manager_ |
| 651 cancelPeripheralConnection:device_mac->peripheral_]; | 655 cancelPeripheralConnection:device_mac->peripheral_]; |
| 652 } | 656 } |
| 653 | 657 |
| 654 void BluetoothAdapterMac::DidConnectPeripheral(CBPeripheral* peripheral) { | 658 void BluetoothAdapterMac::DidConnectPeripheral(CBPeripheral* peripheral) { |
| 655 BluetoothLowEnergyDeviceMac* device_mac = | 659 BluetoothLowEnergyDeviceMac* device_mac = |
| 656 GetBluetoothLowEnergyDeviceMac(peripheral); | 660 GetBluetoothLowEnergyDeviceMac(peripheral); |
| 657 if (!device_mac) { | 661 if (!device_mac) { |
| 658 [low_energy_central_manager_ cancelPeripheralConnection:peripheral]; | 662 [low_energy_central_manager_ cancelPeripheralConnection:peripheral]; |
| 659 return; | 663 return; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 720 // hash the probability of this occuring with 10,000 devices | 724 // hash the probability of this occuring with 10,000 devices |
| 721 // simultaneously present is 1e-6 (see | 725 // simultaneously present is 1e-6 (see |
| 722 // https://en.wikipedia.org/wiki/Birthday_problem#Probability_table). We | 726 // https://en.wikipedia.org/wiki/Birthday_problem#Probability_table). We |
| 723 // ignore the second device by returning. | 727 // ignore the second device by returning. |
| 724 return true; | 728 return true; |
| 725 } | 729 } |
| 726 return false; | 730 return false; |
| 727 } | 731 } |
| 728 | 732 |
| 729 } // namespace device | 733 } // namespace device |
| OLD | NEW |