| 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 | |
| 34 CBPeripheral* GetPeripheral() { return device_mac_->GetPeripheral(); } | 30 CBPeripheral* GetPeripheral() { return device_mac_->GetPeripheral(); } |
| 35 | 31 |
| 36 private: | 32 private: |
| 37 BluetoothLowEnergyDeviceMac* device_mac_; | 33 BluetoothLowEnergyDeviceMac* device_mac_; |
| 38 }; | 34 }; |
| 39 | 35 |
| 40 } // namespace device | 36 } // namespace device |
| 41 | 37 |
| 42 @implementation BluetoothLowEnergyPeripheralDelegate | 38 @implementation BluetoothLowEnergyPeripheralDelegate |
| 43 | 39 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 57 - (void)peripheral:(CBPeripheral*)peripheral | 53 - (void)peripheral:(CBPeripheral*)peripheral |
| 58 didModifyServices:(NSArray*)invalidatedServices { | 54 didModifyServices:(NSArray*)invalidatedServices { |
| 59 bridge_->DidModifyServices(invalidatedServices); | 55 bridge_->DidModifyServices(invalidatedServices); |
| 60 } | 56 } |
| 61 | 57 |
| 62 - (void)peripheral:(CBPeripheral*)peripheral | 58 - (void)peripheral:(CBPeripheral*)peripheral |
| 63 didDiscoverServices:(NSError*)error { | 59 didDiscoverServices:(NSError*)error { |
| 64 bridge_->DidDiscoverPrimaryServices(error); | 60 bridge_->DidDiscoverPrimaryServices(error); |
| 65 } | 61 } |
| 66 | 62 |
| 67 - (void)peripheral:(CBPeripheral*)peripheral | |
| 68 didDiscoverCharacteristicsForService:(CBService*)service | |
| 69 error:(NSError*)error { | |
| 70 bridge_->DidDiscoverCharacteristics(service, error); | |
| 71 } | |
| 72 | |
| 73 @end | 63 @end |
| OLD | NEW |