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

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

Issue 2904363002: bluetooth: macOS: Removing intermediate methods in BluetoothRemoteServiceMac (Closed)
Patch Set: 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
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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 } 302 }
303 device_uuids_.ClearServiceUUIDs(); 303 device_uuids_.ClearServiceUUIDs();
304 SetGattServicesDiscoveryComplete(false); 304 SetGattServicesDiscoveryComplete(false);
305 adapter_->NotifyDeviceChanged(this); 305 adapter_->NotifyDeviceChanged(this);
306 DiscoverPrimaryServices(); 306 DiscoverPrimaryServices();
307 } 307 }
308 308
309 void BluetoothLowEnergyDeviceMac::DidUpdateValue( 309 void BluetoothLowEnergyDeviceMac::DidUpdateValue(
310 CBCharacteristic* characteristic, 310 CBCharacteristic* characteristic,
311 NSError* error) { 311 NSError* error) {
312 BluetoothRemoteGattServiceMac* gatt_service = 312 BluetoothRemoteGattCharacteristicMac* gatt_characteristic_mac =
313 GetBluetoothRemoteGattServiceMac(characteristic.service); 313 GetBluetoothRemoteGattCharacteristicMac(characteristic);
314 DCHECK(gatt_service); 314 DCHECK(gatt_characteristic_mac);
315 gatt_service->DidUpdateValue(characteristic, error); 315 gatt_characteristic_mac->DidUpdateValue(error);
316 } 316 }
317 317
318 void BluetoothLowEnergyDeviceMac::DidWriteValue( 318 void BluetoothLowEnergyDeviceMac::DidWriteValue(
319 CBCharacteristic* characteristic, 319 CBCharacteristic* characteristic,
320 NSError* error) { 320 NSError* error) {
321 BluetoothRemoteGattServiceMac* gatt_service = 321 BluetoothRemoteGattCharacteristicMac* gatt_characteristic_mac =
322 GetBluetoothRemoteGattServiceMac(characteristic.service); 322 GetBluetoothRemoteGattCharacteristicMac(characteristic);
323 DCHECK(gatt_service); 323 DCHECK(gatt_characteristic_mac);
324 gatt_service->DidWriteValue(characteristic, error); 324 gatt_characteristic_mac->DidWriteValue(error);
325 } 325 }
326 326
327 void BluetoothLowEnergyDeviceMac::DidUpdateNotificationState( 327 void BluetoothLowEnergyDeviceMac::DidUpdateNotificationState(
328 CBCharacteristic* characteristic, 328 CBCharacteristic* characteristic,
329 NSError* error) { 329 NSError* error) {
330 BluetoothRemoteGattServiceMac* gatt_service = 330 BluetoothRemoteGattCharacteristicMac* gatt_characteristic_mac =
331 GetBluetoothRemoteGattServiceMac(characteristic.service); 331 GetBluetoothRemoteGattCharacteristicMac(characteristic);
332 DCHECK(gatt_service); 332 DCHECK(gatt_characteristic_mac);
333 gatt_service->DidUpdateNotificationState(characteristic, error); 333 gatt_characteristic_mac->DidUpdateNotificationState(error);
334 } 334 }
335 335
336 void BluetoothLowEnergyDeviceMac::DidDiscoverDescriptors( 336 void BluetoothLowEnergyDeviceMac::DidDiscoverDescriptors(
337 CBCharacteristic* cb_characteristic, 337 CBCharacteristic* cb_characteristic,
338 NSError* error) { 338 NSError* error) {
339 if (error) { 339 if (error) {
340 // TODO(http://crbug.com/609320): Need to pass the error. 340 // TODO(http://crbug.com/609320): Need to pass the error.
341 // TODO(http://crbug.com/609844): Decide what to do if discover failed 341 // TODO(http://crbug.com/609844): Decide what to do if discover failed
342 VLOG(1) << *this << ": Can't discover descriptors: " 342 VLOG(1) << *this << ": Can't discover descriptors: "
343 << BluetoothAdapterMac::String(error); 343 << BluetoothAdapterMac::String(error);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 for (auto it = gatt_services_.begin(); it != gatt_services_.end(); ++it) { 456 for (auto it = gatt_services_.begin(); it != gatt_services_.end(); ++it) {
457 device::BluetoothRemoteGattService* gatt_service = it->second.get(); 457 device::BluetoothRemoteGattService* gatt_service = it->second.get();
458 device::BluetoothRemoteGattServiceMac* gatt_service_mac = 458 device::BluetoothRemoteGattServiceMac* gatt_service_mac =
459 static_cast<BluetoothRemoteGattServiceMac*>(gatt_service); 459 static_cast<BluetoothRemoteGattServiceMac*>(gatt_service);
460 if (gatt_service_mac->GetService() == cb_service) 460 if (gatt_service_mac->GetService() == cb_service)
461 return gatt_service_mac; 461 return gatt_service_mac;
462 } 462 }
463 return nullptr; 463 return nullptr;
464 } 464 }
465 465
466 device::BluetoothRemoteGattCharacteristicMac*
467 BluetoothLowEnergyDeviceMac::GetBluetoothRemoteGattCharacteristicMac(
468 CBCharacteristic* cb_characteristic) const {
469 CBService* cb_service = [cb_characteristic service];
470 device::BluetoothRemoteGattServiceMac* gatt_service_mac =
471 GetBluetoothRemoteGattServiceMac(cb_service);
472 if (!gatt_service_mac) {
473 return nullptr;
474 }
475 return gatt_service_mac->GetBluetoothRemoteGattCharacteristicMac(
476 cb_characteristic);
477 }
478
466 device::BluetoothRemoteGattDescriptorMac* 479 device::BluetoothRemoteGattDescriptorMac*
467 BluetoothLowEnergyDeviceMac::GetBluetoothRemoteGattDescriptorMac( 480 BluetoothLowEnergyDeviceMac::GetBluetoothRemoteGattDescriptorMac(
468 CBDescriptor* cb_descriptor) const { 481 CBDescriptor* cb_descriptor) const {
469 CBCharacteristic* cb_characteristic = cb_descriptor.characteristic; 482 CBCharacteristic* cb_characteristic = cb_descriptor.characteristic;
470 device::BluetoothRemoteGattServiceMac* gatt_service = 483 device::BluetoothRemoteGattServiceMac* gatt_service =
471 GetBluetoothRemoteGattServiceMac(cb_characteristic.service); 484 GetBluetoothRemoteGattServiceMac(cb_characteristic.service);
472 DCHECK(gatt_service); 485 DCHECK(gatt_service);
473 device::BluetoothRemoteGattCharacteristicMac* gatt_characteristic = 486 device::BluetoothRemoteGattCharacteristicMac* gatt_characteristic =
474 gatt_service->GetBluetoothRemoteGattCharacteristicMac(cb_characteristic); 487 gatt_service->GetBluetoothRemoteGattCharacteristicMac(cb_characteristic);
475 DCHECK(gatt_characteristic); 488 DCHECK(gatt_characteristic);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 // TODO(crbug.com/703878): Should use 525 // TODO(crbug.com/703878): Should use
513 // BluetoothLowEnergyDeviceMac::GetNameForDisplay() instead. 526 // BluetoothLowEnergyDeviceMac::GetNameForDisplay() instead.
514 base::Optional<std::string> name = device.GetName(); 527 base::Optional<std::string> name = device.GetName();
515 const char* is_gatt_connected = 528 const char* is_gatt_connected =
516 device.IsGattConnected() ? "GATT connected" : "GATT disconnected"; 529 device.IsGattConnected() ? "GATT connected" : "GATT disconnected";
517 return out << "<BluetoothLowEnergyDeviceMac " << device.GetAddress() << "/" 530 return out << "<BluetoothLowEnergyDeviceMac " << device.GetAddress() << "/"
518 << &device << ", " << is_gatt_connected << ", \"" 531 << &device << ", " << is_gatt_connected << ", \""
519 << name.value_or("Unnamed device") << "\">"; 532 << name.value_or("Unnamed device") << "\">";
520 } 533 }
521 } // namespace device 534 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_low_energy_device_mac.h ('k') | device/bluetooth/bluetooth_remote_gatt_service_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698