Chromium Code Reviews| 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 | |
| 37 // TODO(jracle): Following line is a patch to avoid being considered | |
| 38 // as a timed-out device in BluetoothAdapter::RemoveTimedOutDevices(). | |
| 39 // Consider removing it and review BluetoothAdapter's logic. | |
| 40 UpdateTimestamp(); | |
|
jracle (use Gerrit)
2016/09/02 14:23:10
I did this hack here, but I think we could instead
| |
| 36 } | 41 } |
| 37 | 42 |
| 38 BluetoothLowEnergyDeviceMac::~BluetoothLowEnergyDeviceMac() { | 43 BluetoothLowEnergyDeviceMac::~BluetoothLowEnergyDeviceMac() { |
| 39 if (IsGattConnected()) { | 44 if (IsGattConnected()) { |
| 40 GetMacAdapter()->DisconnectGatt(this); | 45 GetMacAdapter()->DisconnectGatt(this); |
| 41 } | 46 } |
| 42 } | 47 } |
| 43 | 48 |
| 44 std::string BluetoothLowEnergyDeviceMac::GetIdentifier() const { | 49 std::string BluetoothLowEnergyDeviceMac::GetIdentifier() const { |
| 45 return identifier_; | 50 return identifier_; |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 357 // 2. When we cancel a pending connection request. | 362 // 2. When we cancel a pending connection request. |
| 358 if (create_gatt_connection_error_callbacks_.empty()) { | 363 if (create_gatt_connection_error_callbacks_.empty()) { |
| 359 // If there are no pending callbacks then the connection broke (#1). | 364 // If there are no pending callbacks then the connection broke (#1). |
| 360 DidDisconnectGatt(); | 365 DidDisconnectGatt(); |
| 361 return; | 366 return; |
| 362 } | 367 } |
| 363 // Else we canceled the connection request (#2). | 368 // Else we canceled the connection request (#2). |
| 364 // TODO(http://crbug.com/585897): Need to pass the error. | 369 // TODO(http://crbug.com/585897): Need to pass the error. |
| 365 DidFailToConnectGatt(BluetoothDevice::ConnectErrorCode::ERROR_FAILED); | 370 DidFailToConnectGatt(BluetoothDevice::ConnectErrorCode::ERROR_FAILED); |
| 366 } | 371 } |
| OLD | NEW |