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 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_MAC_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_MAC_H_ |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_MAC_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_MAC_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
| 12 #include "base/containers/scoped_ptr_hash_map.h" |
12 #include "base/mac/scoped_nsobject.h" | 13 #include "base/mac/scoped_nsobject.h" |
13 #include "device/bluetooth/bluetooth_remote_gatt_service.h" | 14 #include "device/bluetooth/bluetooth_remote_gatt_service.h" |
14 | 15 |
15 @class CBService; | 16 @class CBService; |
16 | 17 |
17 namespace device { | 18 namespace device { |
18 | 19 |
19 class BluetoothDevice; | 20 class BluetoothDevice; |
20 class BluetoothGattCharacteristic; | 21 class BluetoothRemoteGattCharacteristicMac; |
21 class BluetoothLowEnergyDeviceMac; | 22 class BluetoothLowEnergyDeviceMac; |
22 class BluetoothTestMac; | 23 class BluetoothTestMac; |
23 | 24 |
24 class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattServiceMac | 25 class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattServiceMac |
25 : public BluetoothRemoteGattService { | 26 : public BluetoothRemoteGattService { |
26 public: | 27 public: |
27 BluetoothRemoteGattServiceMac( | 28 BluetoothRemoteGattServiceMac( |
28 BluetoothLowEnergyDeviceMac* bluetooth_device_mac, | 29 BluetoothLowEnergyDeviceMac* bluetooth_device_mac, |
29 CBService* service, | 30 CBService* service, |
30 bool is_primary); | 31 bool is_primary); |
31 ~BluetoothRemoteGattServiceMac() override; | 32 ~BluetoothRemoteGattServiceMac() override; |
32 | 33 |
33 // BluetoothRemoteGattService override. | 34 // BluetoothRemoteGattService override. |
34 std::string GetIdentifier() const override; | 35 std::string GetIdentifier() const override; |
35 BluetoothUUID GetUUID() const override; | 36 BluetoothUUID GetUUID() const override; |
36 bool IsPrimary() const override; | 37 bool IsPrimary() const override; |
37 BluetoothDevice* GetDevice() const override; | 38 BluetoothDevice* GetDevice() const override; |
38 std::vector<BluetoothRemoteGattCharacteristic*> GetCharacteristics() | 39 std::vector<BluetoothRemoteGattCharacteristic*> GetCharacteristics() |
39 const override; | 40 const override; |
40 std::vector<BluetoothRemoteGattService*> GetIncludedServices() const override; | 41 std::vector<BluetoothRemoteGattService*> GetIncludedServices() const override; |
41 BluetoothRemoteGattCharacteristic* GetCharacteristic( | 42 BluetoothRemoteGattCharacteristic* GetCharacteristic( |
42 const std::string& identifier) const override; | 43 const std::string& identifier) const override; |
43 | 44 |
44 private: | 45 private: |
45 friend BluetoothLowEnergyDeviceMac; | 46 friend BluetoothLowEnergyDeviceMac; |
46 friend BluetoothTestMac; | 47 friend BluetoothTestMac; |
47 | 48 |
| 49 // Called by the BluetoothLowEnergyDeviceMac instance when the characteristics |
| 50 // has been discovered. |
| 51 void DidDiscoverCharacteristics(); |
| 52 |
| 53 // Returns true if the characteristics has been discovered. |
| 54 bool IsDiscoveryComplete(); |
| 55 |
48 // Returns CBService. | 56 // Returns CBService. |
49 CBService* GetService() const; | 57 CBService* GetService() const; |
50 | 58 |
51 // bluetooth_device_mac_ owns instances of this class. | 59 // bluetooth_device_mac_ owns instances of this class. |
52 BluetoothLowEnergyDeviceMac* bluetooth_device_mac_; | 60 BluetoothLowEnergyDeviceMac* bluetooth_device_mac_; |
53 // A service from CBPeripheral.services. | 61 // A service from CBPeripheral.services. |
54 base::scoped_nsobject<CBService> service_; | 62 base::scoped_nsobject<CBService> service_; |
| 63 // Map of characteristics, keyed by characteristic identifier. |
| 64 base::ScopedPtrHashMap<std::string, |
| 65 std::unique_ptr<BluetoothRemoteGattCharacteristicMac>> |
| 66 gatt_characteristic_macs_; |
55 bool is_primary_; | 67 bool is_primary_; |
56 // Service identifier. | 68 // Service identifier. |
57 std::string identifier_; | 69 std::string identifier_; |
58 // Service UUID. | 70 // Service UUID. |
59 BluetoothUUID uuid_; | 71 BluetoothUUID uuid_; |
| 72 // Is true if the characteristics has been discovered. |
| 73 bool is_discovery_complete_; |
60 | 74 |
61 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattServiceMac); | 75 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattServiceMac); |
62 }; | 76 }; |
63 | 77 |
64 } // namespace device | 78 } // namespace device |
65 | 79 |
66 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_MAC_H_ | 80 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_MAC_H_ |
OLD | NEW |