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

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

Issue 1948763003: Adding support for service scan on OS X (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cleanup
Patch Set: Fixing comments Created 4 years, 7 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_LOW_ENERGY_DEVICE_MAC_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEVICE_MAC_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEVICE_MAC_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEVICE_MAC_H_
7 7
8 #if defined(OS_IOS) 8 #if defined(OS_IOS)
9 #import <CoreBluetooth/CoreBluetooth.h> 9 #import <CoreBluetooth/CoreBluetooth.h>
10 #else // !defined(OS_IOS) 10 #else // !defined(OS_IOS)
11 #import <IOBluetooth/IOBluetooth.h> 11 #import <IOBluetooth/IOBluetooth.h>
12 #endif // defined(OS_IOS) 12 #endif // defined(OS_IOS)
13 13
14 #include <stdint.h> 14 #include <stdint.h>
15 15
16 #include <set> 16 #include <set>
17 17
18 #include "base/mac/scoped_nsobject.h" 18 #include "base/mac/scoped_nsobject.h"
19 #include "base/mac/sdk_forward_declarations.h" 19 #include "base/mac/sdk_forward_declarations.h"
20 #include "base/macros.h" 20 #include "base/macros.h"
21 #include "build/build_config.h" 21 #include "build/build_config.h"
22 #include "crypto/sha2.h" 22 #include "crypto/sha2.h"
23 #include "device/bluetooth/bluetooth_device_mac.h" 23 #include "device/bluetooth/bluetooth_device_mac.h"
24 24
25 @class BluetoothLowEnergyPeripheralDelegate;
26
25 namespace device { 27 namespace device {
26 28
27 class BluetoothAdapterMac; 29 class BluetoothAdapterMac;
28 class BluetoothLowEnergyDiscoverManagerMac; 30 class BluetoothLowEnergyDiscoverManagerMac;
31 class BluetoothRemoteGattServiceMac;
29 32
30 class DEVICE_BLUETOOTH_EXPORT BluetoothLowEnergyDeviceMac 33 class DEVICE_BLUETOOTH_EXPORT BluetoothLowEnergyDeviceMac
31 : public BluetoothDeviceMac { 34 : public BluetoothDeviceMac {
32 public: 35 public:
33 BluetoothLowEnergyDeviceMac(BluetoothAdapterMac* adapter, 36 BluetoothLowEnergyDeviceMac(BluetoothAdapterMac* adapter,
34 CBPeripheral* peripheral, 37 CBPeripheral* peripheral,
35 NSDictionary* advertisement_data, 38 NSDictionary* advertisement_data,
36 int rssi); 39 int rssi);
37 ~BluetoothLowEnergyDeviceMac() override; 40 ~BluetoothLowEnergyDeviceMac() override;
38 41
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 85
83 // BluetoothDeviceMac override. 86 // BluetoothDeviceMac override.
84 NSDate* GetLastUpdateTime() const override; 87 NSDate* GetLastUpdateTime() const override;
85 88
86 protected: 89 protected:
87 // BluetoothDevice override. 90 // BluetoothDevice override.
88 std::string GetDeviceName() const override; 91 std::string GetDeviceName() const override;
89 void CreateGattConnectionImpl() override; 92 void CreateGattConnectionImpl() override;
90 void DisconnectGatt() override; 93 void DisconnectGatt() override;
91 94
95 // Methods used by BluetoothLowEnergyPeripheralBridge.
96 void DidDiscoverPrimaryServices(NSError* error);
97 void DidModifyServices(NSArray* invalidatedServices);
98
92 // Updates information about the device. 99 // Updates information about the device.
93 virtual void Update(NSDictionary* advertisement_data, int rssi); 100 virtual void Update(NSDictionary* advertisement_data, int rssi);
94 101
95 static std::string GetPeripheralIdentifier(CBPeripheral* peripheral); 102 static std::string GetPeripheralIdentifier(CBPeripheral* peripheral);
96 103
97 // Hashes and truncates the peripheral identifier to deterministically 104 // Hashes and truncates the peripheral identifier to deterministically
98 // construct an address. The use of fake addresses is a temporary fix before 105 // construct an address. The use of fake addresses is a temporary fix before
99 // we switch to using bluetooth identifiers throughout Chrome. 106 // we switch to using bluetooth identifiers throughout Chrome.
100 // http://crbug.com/507824 107 // http://crbug.com/507824
101 static std::string GetPeripheralHashAddress(CBPeripheral* peripheral); 108 static std::string GetPeripheralHashAddress(CBPeripheral* peripheral);
102 109
103 private: 110 private:
104 friend class BluetoothAdapterMac; 111 friend class BluetoothAdapterMac;
105 friend class BluetoothAdapterMacTest; 112 friend class BluetoothAdapterMacTest;
113 friend class BluetoothLowEnergyPeripheralBridge;
106 friend class BluetoothTestMac; 114 friend class BluetoothTestMac;
107 115
108 // Returns the Bluetooth adapter. 116 // Returns the Bluetooth adapter.
109 BluetoothAdapterMac* GetMacAdapter(); 117 BluetoothAdapterMac* GetMacAdapter();
110 118
111 // Returns the CoreBluetooth Peripheral. 119 // Returns the CoreBluetooth Peripheral.
112 CBPeripheral* GetPeripheral(); 120 CBPeripheral* GetPeripheral();
113 121
122 // Returns BluetoothRemoteGattServiceMac based on the CBService.
123 BluetoothRemoteGattServiceMac* GetBluetoothRemoteGattService(
124 CBService* service) const;
125
114 // Callback used when the CoreBluetooth Peripheral is disconnected. 126 // Callback used when the CoreBluetooth Peripheral is disconnected.
115 void DidDisconnectPeripheral(BluetoothDevice::ConnectErrorCode error_code); 127 void DidDisconnectPeripheral(BluetoothDevice::ConnectErrorCode error_code);
116 128
117 // CoreBluetooth data structure. 129 // CoreBluetooth data structure.
118 base::scoped_nsobject<CBPeripheral> peripheral_; 130 base::scoped_nsobject<CBPeripheral> peripheral_;
119 131
132 // Objective-C delegate for the CBPeripheral.
133 base::scoped_nsobject<BluetoothLowEnergyPeripheralDelegate>
134 peripheral_delegate_;
135
120 // RSSI value. 136 // RSSI value.
121 int rssi_; 137 int rssi_;
122 138
123 // Whether the device is connectable. 139 // Whether the device is connectable.
124 bool connectable_; 140 bool connectable_;
125 141
126 // The peripheral's identifier, as returned by [CBPeripheral identifier]. 142 // The peripheral's identifier, as returned by [CBPeripheral identifier].
127 std::string identifier_; 143 std::string identifier_;
128 144
129 // A local address for the device created by hashing the peripheral 145 // A local address for the device created by hashing the peripheral
130 // identifier. 146 // identifier.
131 std::string hash_address_; 147 std::string hash_address_;
132 148
133 // Stores the time of the most recent call to Update(). 149 // Stores the time of the most recent call to Update().
134 base::scoped_nsobject<NSDate> last_update_time_; 150 base::scoped_nsobject<NSDate> last_update_time_;
135 151
136 // The services (identified by UUIDs) that this device provides. 152 // The services (identified by UUIDs) that this device provides.
137 std::set<BluetoothUUID> advertised_uuids_; 153 std::set<BluetoothUUID> advertised_uuids_;
138 154
139 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyDeviceMac); 155 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyDeviceMac);
140 }; 156 };
141 157
142 } // namespace device 158 } // namespace device
143 159
144 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEVICE_MAC_H_ 160 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEVICE_MAC_H_
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_device_unittest.cc ('k') | device/bluetooth/bluetooth_low_energy_device_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698