| 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 #include "device/bluetooth/bluetooth_low_energy_device_mac.h" | 5 #include "device/bluetooth/bluetooth_low_energy_device_mac.h" |
| 6 | 6 |
| 7 #import <CoreFoundation/CoreFoundation.h> | 7 #import <CoreFoundation/CoreFoundation.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 using device::BluetoothLowEnergyDeviceMac; | 24 using device::BluetoothLowEnergyDeviceMac; |
| 25 | 25 |
| 26 BluetoothLowEnergyDeviceMac::BluetoothLowEnergyDeviceMac( | 26 BluetoothLowEnergyDeviceMac::BluetoothLowEnergyDeviceMac( |
| 27 BluetoothAdapterMac* adapter, | 27 BluetoothAdapterMac* adapter, |
| 28 CBPeripheral* peripheral) | 28 CBPeripheral* peripheral) |
| 29 : BluetoothDeviceMac(adapter), | 29 : BluetoothDeviceMac(adapter), |
| 30 peripheral_(peripheral, base::scoped_policy::RETAIN), | 30 peripheral_(peripheral, base::scoped_policy::RETAIN), |
| 31 connected_(false), | 31 connected_(false), |
| 32 discovery_pending_count_(0) { | 32 discovery_pending_count_(0) { |
| 33 DCHECK(BluetoothAdapterMac::IsLowEnergyAvailable()); | 33 DCHECK(BluetoothAdapterMac::IsLowEnergyAvailable()); |
| 34 DCHECK(peripheral_.get()); | 34 DCHECK(peripheral_); |
| 35 peripheral_delegate_.reset([[BluetoothLowEnergyPeripheralDelegate alloc] | 35 peripheral_delegate_.reset([[BluetoothLowEnergyPeripheralDelegate alloc] |
| 36 initWithBluetoothLowEnergyDeviceMac:this]); | 36 initWithBluetoothLowEnergyDeviceMac:this]); |
| 37 [peripheral_ setDelegate:peripheral_delegate_]; | 37 [peripheral_ setDelegate:peripheral_delegate_]; |
| 38 identifier_ = GetPeripheralIdentifier(peripheral); | 38 identifier_ = GetPeripheralIdentifier(peripheral); |
| 39 hash_address_ = GetPeripheralHashAddress(peripheral); | 39 hash_address_ = GetPeripheralHashAddress(peripheral); |
| 40 UpdateTimestamp(); | 40 UpdateTimestamp(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 BluetoothLowEnergyDeviceMac::~BluetoothLowEnergyDeviceMac() { | 43 BluetoothLowEnergyDeviceMac::~BluetoothLowEnergyDeviceMac() { |
| 44 if (IsGattConnected()) { | 44 if (IsGattConnected()) { |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 // TODO(crbug.com/703878): Should use | 512 // TODO(crbug.com/703878): Should use |
| 513 // BluetoothLowEnergyDeviceMac::GetNameForDisplay() instead. | 513 // BluetoothLowEnergyDeviceMac::GetNameForDisplay() instead. |
| 514 base::Optional<std::string> name = device.GetName(); | 514 base::Optional<std::string> name = device.GetName(); |
| 515 const char* is_gatt_connected = | 515 const char* is_gatt_connected = |
| 516 device.IsGattConnected() ? "GATT connected" : "GATT disconnected"; | 516 device.IsGattConnected() ? "GATT connected" : "GATT disconnected"; |
| 517 return out << "<BluetoothLowEnergyDeviceMac " << device.GetAddress() << "/" | 517 return out << "<BluetoothLowEnergyDeviceMac " << device.GetAddress() << "/" |
| 518 << &device << ", " << is_gatt_connected << ", \"" | 518 << &device << ", " << is_gatt_connected << ", \"" |
| 519 << name.value_or("Unnamed device") << "\">"; | 519 << name.value_or("Unnamed device") << "\">"; |
| 520 } | 520 } |
| 521 } // namespace device | 521 } // namespace device |
| OLD | NEW |