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

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

Issue 2907033002: Bluetooth: macOS: Making code to get mac descriptors more coherent (Closed)
Patch Set: Merge Created 3 years, 6 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
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_remote_gatt_service_mac.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 if (!gatt_service_mac) { 483 if (!gatt_service_mac) {
484 return nullptr; 484 return nullptr;
485 } 485 }
486 return gatt_service_mac->GetBluetoothRemoteGattCharacteristicMac( 486 return gatt_service_mac->GetBluetoothRemoteGattCharacteristicMac(
487 cb_characteristic); 487 cb_characteristic);
488 } 488 }
489 489
490 BluetoothRemoteGattDescriptorMac* 490 BluetoothRemoteGattDescriptorMac*
491 BluetoothLowEnergyDeviceMac::GetBluetoothRemoteGattDescriptorMac( 491 BluetoothLowEnergyDeviceMac::GetBluetoothRemoteGattDescriptorMac(
492 CBDescriptor* cb_descriptor) const { 492 CBDescriptor* cb_descriptor) const {
493 CBCharacteristic* cb_characteristic = cb_descriptor.characteristic; 493 CBService* cb_service = [[cb_descriptor characteristic] service];
494 BluetoothRemoteGattServiceMac* gatt_service = 494 BluetoothRemoteGattServiceMac* gatt_service_mac =
495 GetBluetoothRemoteGattServiceMac(cb_characteristic.service); 495 GetBluetoothRemoteGattServiceMac(cb_service);
496 DCHECK(gatt_service); 496 if (!gatt_service_mac) {
497 BluetoothRemoteGattCharacteristicMac* gatt_characteristic = 497 return nullptr;
498 gatt_service->GetBluetoothRemoteGattCharacteristicMac(cb_characteristic); 498 }
499 DCHECK(gatt_characteristic); 499 return gatt_service_mac->GetBluetoothRemoteGattDescriptorMac(cb_descriptor);
500 return gatt_characteristic->GetBluetoothRemoteGattDescriptorMac(
501 cb_descriptor);
502 } 500 }
503 501
504 void BluetoothLowEnergyDeviceMac::DidDisconnectPeripheral(NSError* error) { 502 void BluetoothLowEnergyDeviceMac::DidDisconnectPeripheral(NSError* error) {
505 connected_ = false; 503 connected_ = false;
506 VLOG(1) << *this << ": Disconnected from peripheral."; 504 VLOG(1) << *this << ": Disconnected from peripheral.";
507 if (error) { 505 if (error) {
508 VLOG(1) << *this 506 VLOG(1) << *this
509 << ": Bluetooth error: " << BluetoothAdapterMac::String(error); 507 << ": Bluetooth error: " << BluetoothAdapterMac::String(error);
510 } 508 }
511 SetGattServicesDiscoveryComplete(false); 509 SetGattServicesDiscoveryComplete(false);
(...skipping 23 matching lines...) Expand all
535 // BluetoothLowEnergyDeviceMac::GetNameForDisplay() instead. 533 // BluetoothLowEnergyDeviceMac::GetNameForDisplay() instead.
536 base::Optional<std::string> name = device.GetName(); 534 base::Optional<std::string> name = device.GetName();
537 const char* is_gatt_connected = 535 const char* is_gatt_connected =
538 device.IsGattConnected() ? "GATT connected" : "GATT disconnected"; 536 device.IsGattConnected() ? "GATT connected" : "GATT disconnected";
539 return out << "<BluetoothLowEnergyDeviceMac " << device.GetAddress() << "/" 537 return out << "<BluetoothLowEnergyDeviceMac " << device.GetAddress() << "/"
540 << &device << ", " << is_gatt_connected << ", \"" 538 << &device << ", " << is_gatt_connected << ", \""
541 << name.value_or("Unnamed device") << "\">"; 539 << name.value_or("Unnamed device") << "\">";
542 } 540 }
543 541
544 } // namespace device 542 } // namespace device
OLDNEW
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_remote_gatt_service_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698