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

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

Issue 1216583003: Adding Hashed Address to BluetoothLowEnergyDeviceMac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@timeinfo
Patch Set: arman comments Created 5 years, 5 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 10 #else // !defined(OS_IOS)
11 #import <IOBluetooth/IOBluetooth.h> 11 #import <IOBluetooth/IOBluetooth.h>
12 #endif 12 #endif // defined(OS_IOS)
13 13
14 #include "base/mac/scoped_nsobject.h" 14 #include "base/mac/scoped_nsobject.h"
15 #include "base/mac/sdk_forward_declarations.h" 15 #include "base/mac/sdk_forward_declarations.h"
16 #include "crypto/sha2.h"
16 #include "device/bluetooth/bluetooth_device_mac.h" 17 #include "device/bluetooth/bluetooth_device_mac.h"
17 18
18 namespace device { 19 namespace device {
19 20
20 class BluetoothLowEnergyDiscoverManagerMac; 21 class BluetoothLowEnergyDiscoverManagerMac;
21 22
22 class BluetoothLowEnergyDeviceMac : public BluetoothDeviceMac { 23 class DEVICE_BLUETOOTH_EXPORT BluetoothLowEnergyDeviceMac
24 : public BluetoothDeviceMac {
23 public: 25 public:
24 BluetoothLowEnergyDeviceMac(CBPeripheral* peripheral, 26 BluetoothLowEnergyDeviceMac(CBPeripheral* peripheral,
25 NSDictionary* advertisementData, 27 NSDictionary* advertisementData,
26 int rssi); 28 int rssi);
27 ~BluetoothLowEnergyDeviceMac() override; 29 ~BluetoothLowEnergyDeviceMac() override;
28 30
29 int GetRSSI() const; 31 int GetRSSI() const;
30 32
31 // BluetoothDevice overrides. 33 // BluetoothDevice overrides.
32 std::string GetIdentifier() const override; 34 std::string GetIdentifier() const override;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // BluetoothDevice override. 79 // BluetoothDevice override.
78 std::string GetDeviceName() const override; 80 std::string GetDeviceName() const override;
79 81
80 // Updates information about the device. 82 // Updates information about the device.
81 virtual void Update(CBPeripheral* peripheral, 83 virtual void Update(CBPeripheral* peripheral,
82 NSDictionary* advertisementData, 84 NSDictionary* advertisementData,
83 int rssi); 85 int rssi);
84 86
85 static std::string GetPeripheralIdentifier(CBPeripheral* peripheral); 87 static std::string GetPeripheralIdentifier(CBPeripheral* peripheral);
86 88
89 // Hashes and truncates the peripheral identifier to deterministically
90 // construct an address. The use of fake addresses is a temporary fix before
armansito 2015/07/07 22:07:54 nit: Remove extra space character before the secon
krstnmnlsn 2015/07/07 22:43:10 Done.
91 // we switch to using bluetooth identifiers throughout Chrome.
92 // http://crbug.com/507824
93 static std::string GetPeripheralHashAddress(CBPeripheral* peripheral);
94
87 private: 95 private:
88 friend class BluetoothAdapterMac; 96 friend class BluetoothAdapterMac;
97 friend class BluetoothAdapterMacTest;
89 98
90 // CoreBluetooth data structure. 99 // CoreBluetooth data structure.
91 base::scoped_nsobject<CBPeripheral> peripheral_; 100 base::scoped_nsobject<CBPeripheral> peripheral_;
92 101
93 // RSSI value. 102 // RSSI value.
94 int rssi_; 103 int rssi_;
95 104
96 // Whether the device is connectable. 105 // Whether the device is connectable.
97 bool connectable_; 106 bool connectable_;
98 107
108 // The peripheral's identifier, as returned by [CBPeripheral identifier].
109 std::string identifier_;
110
111 // A local address for the device created by hashing the peripheral
112 // identifier.
113 std::string hash_address_;
114
99 // Stores the time of the most recent call to Update(). 115 // Stores the time of the most recent call to Update().
100 base::scoped_nsobject<NSDate> last_update_time_; 116 base::scoped_nsobject<NSDate> last_update_time_;
101 117
102 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyDeviceMac); 118 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyDeviceMac);
103 }; 119 };
104 120
105 } // namespace device 121 } // namespace device
106 122
107 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEVICE_MAC_H_ 123 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEVICE_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698