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

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: Created 4 years, 4 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 17 matching lines...) Expand all
28 int rssi) 28 int rssi)
29 : BluetoothDeviceMac(adapter), 29 : BluetoothDeviceMac(adapter),
30 peripheral_(peripheral, base::scoped_policy::RETAIN) { 30 peripheral_(peripheral, base::scoped_policy::RETAIN) {
31 DCHECK(BluetoothAdapterMac::IsLowEnergyAvailable()); 31 DCHECK(BluetoothAdapterMac::IsLowEnergyAvailable());
32 DCHECK(peripheral_.get()); 32 DCHECK(peripheral_.get());
33 peripheral_delegate_.reset([[BluetoothLowEnergyPeripheralDelegate alloc] 33 peripheral_delegate_.reset([[BluetoothLowEnergyPeripheralDelegate alloc]
34 initWithBluetoothLowEnergyDeviceMac:this]); 34 initWithBluetoothLowEnergyDeviceMac:this]);
35 [peripheral_ setDelegate:peripheral_delegate_]; 35 [peripheral_ setDelegate:peripheral_delegate_];
36 identifier_ = GetPeripheralIdentifier(peripheral); 36 identifier_ = GetPeripheralIdentifier(peripheral);
37 hash_address_ = GetPeripheralHashAddress(peripheral); 37 hash_address_ = GetPeripheralHashAddress(peripheral);
38 Update(advertisement_data, rssi); 38
39 if (advertisement_data)
40 Update(advertisement_data, rssi);
41 else
42 UpdateTimestamp();
39 } 43 }
40 44
41 BluetoothLowEnergyDeviceMac::~BluetoothLowEnergyDeviceMac() { 45 BluetoothLowEnergyDeviceMac::~BluetoothLowEnergyDeviceMac() {
42 if (IsGattConnected()) { 46 if (IsGattConnected()) {
43 GetMacAdapter()->DisconnectGatt(this); 47 GetMacAdapter()->DisconnectGatt(this);
44 } 48 }
45 } 49 }
46 50
47 void BluetoothLowEnergyDeviceMac::Update(NSDictionary* advertisement_data, 51 void BluetoothLowEnergyDeviceMac::Update(NSDictionary* advertisement_data,
48 int rssi) { 52 int rssi) {
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 GattServiceMap gatt_services_swapped; 389 GattServiceMap gatt_services_swapped;
386 gatt_services_swapped.swap(gatt_services_); 390 gatt_services_swapped.swap(gatt_services_);
387 gatt_services_swapped.clear(); 391 gatt_services_swapped.clear();
388 if (create_gatt_connection_error_callbacks_.empty()) { 392 if (create_gatt_connection_error_callbacks_.empty()) {
389 // TODO(http://crbug.com/585897): Need to pass the error. 393 // TODO(http://crbug.com/585897): Need to pass the error.
390 DidDisconnectGatt(); 394 DidDisconnectGatt();
391 } else { 395 } else {
392 DidFailToConnectGatt(error_code); 396 DidFailToConnectGatt(error_code);
393 } 397 }
394 } 398 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698