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

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

Issue 2242833002: Bluetooth: mac: add connected BLE devices at startup Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased - work in progress / no tests Created 4 years, 3 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 #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
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
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 }
OLDNEW
« device/bluetooth/bluetooth_adapter_mac.mm ('K') | « device/bluetooth/bluetooth_adapter_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698