Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(794)

Side by Side Diff: device/bluetooth/bluetooth_remote_gatt_service_mac.h

Issue 1950033002: bluetooth: mac: Initial BluetoothRemoteGattCharacteristicMac implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@servicescan_cleanup
Patch Set: Addressing comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
16 @class CBPeripheral;
15 @class CBService; 17 @class CBService;
16 18
17 namespace device { 19 namespace device {
18 20
19 class BluetoothDevice; 21 class BluetoothDevice;
20 class BluetoothGattCharacteristic; 22 class BluetoothRemoteGattCharacteristicMac;
21 class BluetoothLowEnergyDeviceMac; 23 class BluetoothLowEnergyDeviceMac;
22 class BluetoothTestMac; 24 class BluetoothTestMac;
23 25
24 class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattServiceMac 26 class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattServiceMac
25 : public BluetoothRemoteGattService { 27 : public BluetoothRemoteGattService {
26 public: 28 public:
27 BluetoothRemoteGattServiceMac( 29 BluetoothRemoteGattServiceMac(
28 BluetoothLowEnergyDeviceMac* bluetooth_device_mac, 30 BluetoothLowEnergyDeviceMac* bluetooth_device_mac,
29 CBService* service, 31 CBService* service,
30 bool is_primary); 32 bool is_primary);
31 ~BluetoothRemoteGattServiceMac() override; 33 ~BluetoothRemoteGattServiceMac() override;
32 34
33 // BluetoothRemoteGattService override. 35 // BluetoothRemoteGattService override.
34 std::string GetIdentifier() const override; 36 std::string GetIdentifier() const override;
35 BluetoothUUID GetUUID() const override; 37 BluetoothUUID GetUUID() const override;
36 bool IsPrimary() const override; 38 bool IsPrimary() const override;
37 BluetoothDevice* GetDevice() const override; 39 BluetoothDevice* GetDevice() const override;
38 std::vector<BluetoothRemoteGattCharacteristic*> GetCharacteristics() 40 std::vector<BluetoothRemoteGattCharacteristic*> GetCharacteristics()
39 const override; 41 const override;
40 std::vector<BluetoothRemoteGattService*> GetIncludedServices() const override; 42 std::vector<BluetoothRemoteGattService*> GetIncludedServices() const override;
41 BluetoothRemoteGattCharacteristic* GetCharacteristic( 43 BluetoothRemoteGattCharacteristic* GetCharacteristic(
42 const std::string& identifier) const override; 44 const std::string& identifier) const override;
43 45
44 private: 46 private:
45 friend BluetoothLowEnergyDeviceMac; 47 friend BluetoothLowEnergyDeviceMac;
46 friend BluetoothTestMac; 48 friend BluetoothTestMac;
47 49
50 // Starts discovering characteristics by calling CoreBluetooth.
51 void DiscoverCharacteristics();
52
53 // Called by the BluetoothLowEnergyDeviceMac instance when the characteristics
54 // has been discovered.
55 void DidDiscoverCharacteristics();
56
57 // Returns true if the characteristics has been discovered.
58 bool IsDiscoveryComplete();
59
60 // Returns CBPeripheral.
61 CBPeripheral* GetPeripheral() const;
48 // Returns CBService. 62 // Returns CBService.
49 CBService* GetService() const; 63 CBService* GetService() const;
50 64
51 // bluetooth_device_mac_ owns instances of this class. 65 // bluetooth_device_mac_ owns instances of this class.
52 BluetoothLowEnergyDeviceMac* bluetooth_device_mac_; 66 BluetoothLowEnergyDeviceMac* bluetooth_device_mac_;
53 // A service from CBPeripheral.services. 67 // A service from CBPeripheral.services.
54 base::scoped_nsobject<CBService> service_; 68 base::scoped_nsobject<CBService> service_;
69 // Map of characteristics, keyed by characteristic identifier.
70 base::ScopedPtrHashMap<std::string,
71 std::unique_ptr<BluetoothRemoteGattCharacteristicMac>>
72 gatt_characteristic_macs_;
55 bool is_primary_; 73 bool is_primary_;
56 // Service identifier. 74 // Service identifier.
57 std::string identifier_; 75 std::string identifier_;
58 // Service UUID. 76 // Service UUID.
59 BluetoothUUID uuid_; 77 BluetoothUUID uuid_;
78 // Is true if the characteristics has been discovered.
79 bool is_discovery_complete_;
60 80
61 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattServiceMac); 81 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattServiceMac);
62 }; 82 };
63 83
64 } // namespace device 84 } // namespace device
65 85
66 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_MAC_H_ 86 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698