| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_low_energy_peripheral_delegate.h" | 5 #include "device/bluetooth/bluetooth_low_energy_peripheral_delegate.h" |
| 6 | 6 |
| 7 #include "device/bluetooth/bluetooth_adapter_mac.h" | 7 #include "device/bluetooth/bluetooth_adapter_mac.h" |
| 8 #include "device/bluetooth/bluetooth_low_energy_discovery_manager_mac.h" | 8 #include "device/bluetooth/bluetooth_low_energy_discovery_manager_mac.h" |
| 9 | 9 |
| 10 namespace device { | 10 namespace device { |
| 11 | 11 |
| 12 // This class exists to bridge between the Objective-C CBPeripheralDelegate | 12 // This class exists to bridge between the Objective-C CBPeripheralDelegate |
| 13 // class and our BluetoothLowEnergyDiscoveryManagerMac and BluetoothAdapterMac | 13 // class and our BluetoothLowEnergyDiscoveryManagerMac and BluetoothAdapterMac |
| 14 // classes. | 14 // classes. |
| 15 class BluetoothLowEnergyPeripheralBridge { | 15 class BluetoothLowEnergyPeripheralBridge { |
| 16 public: | 16 public: |
| 17 BluetoothLowEnergyPeripheralBridge(BluetoothLowEnergyDeviceMac* device_mac) | 17 BluetoothLowEnergyPeripheralBridge(BluetoothLowEnergyDeviceMac* device_mac) |
| 18 : device_mac_(device_mac) {} | 18 : device_mac_(device_mac) {} |
| 19 | 19 |
| 20 ~BluetoothLowEnergyPeripheralBridge() {} | 20 ~BluetoothLowEnergyPeripheralBridge() {} |
| 21 | 21 |
| 22 void DidModifyServices(NSArray* invalidatedServices) { | 22 void DidModifyServices(NSArray* invalidatedServices) { |
| 23 device_mac_->DidModifyServices(invalidatedServices); | 23 device_mac_->DidModifyServices(invalidatedServices); |
| 24 } | 24 } |
| 25 | 25 |
| 26 void DidDiscoverPrimaryServices(NSError* error) { | 26 void DidDiscoverPrimaryServices(NSError* error) { |
| 27 device_mac_->DidDiscoverPrimaryServices(error); | 27 device_mac_->DidDiscoverPrimaryServices(error); |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 void DidDiscoverCharacteristics(CBService* service, NSError* error) { |
| 31 device_mac_->DidDiscoverCharacteristics(service, error); |
| 32 }; |
| 33 |
| 30 CBPeripheral* GetPeripheral() { return device_mac_->GetPeripheral(); } | 34 CBPeripheral* GetPeripheral() { return device_mac_->GetPeripheral(); } |
| 31 | 35 |
| 32 private: | 36 private: |
| 33 BluetoothLowEnergyDeviceMac* device_mac_; | 37 BluetoothLowEnergyDeviceMac* device_mac_; |
| 34 }; | 38 }; |
| 35 | 39 |
| 36 } // namespace device | 40 } // namespace device |
| 37 | 41 |
| 38 @implementation BluetoothLowEnergyPeripheralDelegate | 42 @implementation BluetoothLowEnergyPeripheralDelegate |
| 39 | 43 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 53 - (void)peripheral:(CBPeripheral*)peripheral | 57 - (void)peripheral:(CBPeripheral*)peripheral |
| 54 didModifyServices:(NSArray*)invalidatedServices { | 58 didModifyServices:(NSArray*)invalidatedServices { |
| 55 bridge_->DidModifyServices(invalidatedServices); | 59 bridge_->DidModifyServices(invalidatedServices); |
| 56 } | 60 } |
| 57 | 61 |
| 58 - (void)peripheral:(CBPeripheral*)peripheral | 62 - (void)peripheral:(CBPeripheral*)peripheral |
| 59 didDiscoverServices:(NSError*)error { | 63 didDiscoverServices:(NSError*)error { |
| 60 bridge_->DidDiscoverPrimaryServices(error); | 64 bridge_->DidDiscoverPrimaryServices(error); |
| 61 } | 65 } |
| 62 | 66 |
| 67 - (void)peripheral:(CBPeripheral*)peripheral |
| 68 didDiscoverCharacteristicsForService:(CBService*)service |
| 69 error:(NSError*)error { |
| 70 bridge_->DidDiscoverCharacteristics(service, error); |
| 71 } |
| 72 |
| 63 @end | 73 @end |
| OLD | NEW |