| OLD | NEW |
| 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 "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 "crypto/sha2.h" |
| 17 #include "device/bluetooth/bluetooth_device_mac.h" | 17 #include "device/bluetooth/bluetooth_device_mac.h" |
| 18 | 18 |
| 19 namespace device { | 19 namespace device { |
| 20 | 20 |
| 21 class BluetoothLowEnergyDiscoverManagerMac; | 21 class BluetoothLowEnergyDiscoverManagerMac; |
| 22 | 22 |
| 23 class DEVICE_BLUETOOTH_EXPORT BluetoothLowEnergyDeviceMac | 23 class DEVICE_BLUETOOTH_EXPORT BluetoothLowEnergyDeviceMac |
| 24 : public BluetoothDeviceMac { | 24 : public BluetoothDeviceMac { |
| 25 public: | 25 public: |
| 26 BluetoothLowEnergyDeviceMac(CBPeripheral* peripheral, | 26 BluetoothLowEnergyDeviceMac(CBPeripheral* peripheral, |
| 27 NSDictionary* advertisement_data, | 27 NSDictionary* advertisementData, |
| 28 int rssi); | 28 int rssi); |
| 29 ~BluetoothLowEnergyDeviceMac() override; | 29 ~BluetoothLowEnergyDeviceMac() override; |
| 30 | 30 |
| 31 int GetRSSI() const; | 31 int GetRSSI() const; |
| 32 | 32 |
| 33 // BluetoothDevice overrides. | 33 // BluetoothDevice overrides. |
| 34 std::string GetIdentifier() const override; | 34 std::string GetIdentifier() const override; |
| 35 uint32 GetBluetoothClass() const override; | 35 uint32 GetBluetoothClass() const override; |
| 36 std::string GetAddress() const override; | 36 std::string GetAddress() const override; |
| 37 BluetoothDevice::VendorIDSource GetVendorIDSource() const override; | 37 BluetoothDevice::VendorIDSource GetVendorIDSource() const override; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 // BluetoothDeviceMac override. | 75 // BluetoothDeviceMac override. |
| 76 NSDate* GetLastUpdateTime() const override; | 76 NSDate* GetLastUpdateTime() const override; |
| 77 | 77 |
| 78 protected: | 78 protected: |
| 79 // BluetoothDevice override. | 79 // BluetoothDevice override. |
| 80 std::string GetDeviceName() const override; | 80 std::string GetDeviceName() const override; |
| 81 | 81 |
| 82 // Updates information about the device. | 82 // Updates information about the device. |
| 83 virtual void Update(CBPeripheral* peripheral, | 83 virtual void Update(CBPeripheral* peripheral, |
| 84 NSDictionary* advertisement_data, | 84 NSDictionary* advertisementData, |
| 85 int rssi); | 85 int rssi); |
| 86 | 86 |
| 87 static std::string GetPeripheralIdentifier(CBPeripheral* peripheral); | 87 static std::string GetPeripheralIdentifier(CBPeripheral* peripheral); |
| 88 | 88 |
| 89 // Hashes and truncates the peripheral identifier to deterministically | 89 // Hashes and truncates the peripheral identifier to deterministically |
| 90 // construct an address. The use of fake addresses is a temporary fix before | 90 // construct an address. The use of fake addresses is a temporary fix before |
| 91 // we switch to using bluetooth identifiers throughout Chrome. | 91 // we switch to using bluetooth identifiers throughout Chrome. |
| 92 // http://crbug.com/507824 | 92 // http://crbug.com/507824 |
| 93 static std::string GetPeripheralHashAddress(CBPeripheral* peripheral); | 93 static std::string GetPeripheralHashAddress(CBPeripheral* peripheral); |
| 94 | 94 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 111 // The peripheral's identifier, as returned by [CBPeripheral identifier]. | 111 // The peripheral's identifier, as returned by [CBPeripheral identifier]. |
| 112 std::string identifier_; | 112 std::string identifier_; |
| 113 | 113 |
| 114 // A local address for the device created by hashing the peripheral | 114 // A local address for the device created by hashing the peripheral |
| 115 // identifier. | 115 // identifier. |
| 116 std::string hash_address_; | 116 std::string hash_address_; |
| 117 | 117 |
| 118 // Stores the time of the most recent call to Update(). | 118 // Stores the time of the most recent call to Update(). |
| 119 base::scoped_nsobject<NSDate> last_update_time_; | 119 base::scoped_nsobject<NSDate> last_update_time_; |
| 120 | 120 |
| 121 // The services (identified by UUIDs) that this device provides. | |
| 122 UUIDList advertised_uuids_; | |
| 123 | |
| 124 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyDeviceMac); | 121 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyDeviceMac); |
| 125 }; | 122 }; |
| 126 | 123 |
| 127 } // namespace device | 124 } // namespace device |
| 128 | 125 |
| 129 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEVICE_MAC_H_ | 126 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEVICE_MAC_H_ |
| OLD | NEW |