| 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 15 matching lines...) Expand all Loading... |
| 26 CBPeripheral* peripheral) | 26 CBPeripheral* peripheral) |
| 27 : BluetoothDeviceMac(adapter), | 27 : BluetoothDeviceMac(adapter), |
| 28 peripheral_(peripheral, base::scoped_policy::RETAIN) { | 28 peripheral_(peripheral, base::scoped_policy::RETAIN) { |
| 29 DCHECK(BluetoothAdapterMac::IsLowEnergyAvailable()); | 29 DCHECK(BluetoothAdapterMac::IsLowEnergyAvailable()); |
| 30 DCHECK(peripheral_.get()); | 30 DCHECK(peripheral_.get()); |
| 31 peripheral_delegate_.reset([[BluetoothLowEnergyPeripheralDelegate alloc] | 31 peripheral_delegate_.reset([[BluetoothLowEnergyPeripheralDelegate alloc] |
| 32 initWithBluetoothLowEnergyDeviceMac:this]); | 32 initWithBluetoothLowEnergyDeviceMac:this]); |
| 33 [peripheral_ setDelegate:peripheral_delegate_]; | 33 [peripheral_ setDelegate:peripheral_delegate_]; |
| 34 identifier_ = GetPeripheralIdentifier(peripheral); | 34 identifier_ = GetPeripheralIdentifier(peripheral); |
| 35 hash_address_ = GetPeripheralHashAddress(peripheral); | 35 hash_address_ = GetPeripheralHashAddress(peripheral); |
| 36 UpdateTimestamp(); |
| 36 } | 37 } |
| 37 | 38 |
| 38 BluetoothLowEnergyDeviceMac::~BluetoothLowEnergyDeviceMac() { | 39 BluetoothLowEnergyDeviceMac::~BluetoothLowEnergyDeviceMac() { |
| 39 if (IsGattConnected()) { | 40 if (IsGattConnected()) { |
| 40 GetMacAdapter()->DisconnectGatt(this); | 41 GetMacAdapter()->DisconnectGatt(this); |
| 41 } | 42 } |
| 42 } | 43 } |
| 43 | 44 |
| 44 std::string BluetoothLowEnergyDeviceMac::GetIdentifier() const { | 45 std::string BluetoothLowEnergyDeviceMac::GetIdentifier() const { |
| 45 return identifier_; | 46 return identifier_; |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 // 2. When we cancel a pending connection request. | 358 // 2. When we cancel a pending connection request. |
| 358 if (create_gatt_connection_error_callbacks_.empty()) { | 359 if (create_gatt_connection_error_callbacks_.empty()) { |
| 359 // If there are no pending callbacks then the connection broke (#1). | 360 // If there are no pending callbacks then the connection broke (#1). |
| 360 DidDisconnectGatt(); | 361 DidDisconnectGatt(); |
| 361 return; | 362 return; |
| 362 } | 363 } |
| 363 // Else we canceled the connection request (#2). | 364 // Else we canceled the connection request (#2). |
| 364 // TODO(http://crbug.com/585897): Need to pass the error. | 365 // TODO(http://crbug.com/585897): Need to pass the error. |
| 365 DidFailToConnectGatt(BluetoothDevice::ConnectErrorCode::ERROR_FAILED); | 366 DidFailToConnectGatt(BluetoothDevice::ConnectErrorCode::ERROR_FAILED); |
| 366 } | 367 } |
| OLD | NEW |