| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/bluez/bluetooth_adapter_bluez.h" | 5 #include "device/bluetooth/bluez/bluetooth_adapter_bluez.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 | 416 |
| 417 void BluetoothAdapterBlueZ::RegisterAdvertisement( | 417 void BluetoothAdapterBlueZ::RegisterAdvertisement( |
| 418 std::unique_ptr<device::BluetoothAdvertisement::Data> advertisement_data, | 418 std::unique_ptr<device::BluetoothAdvertisement::Data> advertisement_data, |
| 419 const CreateAdvertisementCallback& callback, | 419 const CreateAdvertisementCallback& callback, |
| 420 const CreateAdvertisementErrorCallback& error_callback) { | 420 const CreateAdvertisementErrorCallback& error_callback) { |
| 421 scoped_refptr<BluetoothAdvertisementBlueZ> advertisement( | 421 scoped_refptr<BluetoothAdvertisementBlueZ> advertisement( |
| 422 new BluetoothAdvertisementBlueZ(std::move(advertisement_data), this)); | 422 new BluetoothAdvertisementBlueZ(std::move(advertisement_data), this)); |
| 423 advertisement->Register(base::Bind(callback, advertisement), error_callback); | 423 advertisement->Register(base::Bind(callback, advertisement), error_callback); |
| 424 } | 424 } |
| 425 | 425 |
| 426 device::BluetoothLocalGattService* BluetoothAdapterBlueZ::GetGattService( |
| 427 const std::string& identifier) const { |
| 428 const auto& service = owned_gatt_services_.find(dbus::ObjectPath(identifier)); |
| 429 return service == owned_gatt_services_.end() ? nullptr |
| 430 : service->second.get(); |
| 431 } |
| 432 |
| 426 void BluetoothAdapterBlueZ::RemovePairingDelegateInternal( | 433 void BluetoothAdapterBlueZ::RemovePairingDelegateInternal( |
| 427 BluetoothDevice::PairingDelegate* pairing_delegate) { | 434 BluetoothDevice::PairingDelegate* pairing_delegate) { |
| 428 // Check if any device is using the pairing delegate. | 435 // Check if any device is using the pairing delegate. |
| 429 // If so, clear the pairing context which will make any responses no-ops. | 436 // If so, clear the pairing context which will make any responses no-ops. |
| 430 for (DevicesMap::const_iterator iter = devices_.begin(); | 437 for (DevicesMap::const_iterator iter = devices_.begin(); |
| 431 iter != devices_.end(); ++iter) { | 438 iter != devices_.end(); ++iter) { |
| 432 BluetoothDeviceBlueZ* device_bluez = | 439 BluetoothDeviceBlueZ* device_bluez = |
| 433 static_cast<BluetoothDeviceBlueZ*>(iter->second); | 440 static_cast<BluetoothDeviceBlueZ*>(iter->second); |
| 434 | 441 |
| 435 BluetoothPairingBlueZ* pairing = device_bluez->GetPairing(); | 442 BluetoothPairingBlueZ* pairing = device_bluez->GetPairing(); |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 if (iter == released_profiles_.end()) { | 1061 if (iter == released_profiles_.end()) { |
| 1055 LOG(ERROR) << "Released Profile not found: " << uuid.canonical_value(); | 1062 LOG(ERROR) << "Released Profile not found: " << uuid.canonical_value(); |
| 1056 return; | 1063 return; |
| 1057 } | 1064 } |
| 1058 delete iter->second; | 1065 delete iter->second; |
| 1059 released_profiles_.erase(iter); | 1066 released_profiles_.erase(iter); |
| 1060 } | 1067 } |
| 1061 | 1068 |
| 1062 void BluetoothAdapterBlueZ::AddLocalGattService( | 1069 void BluetoothAdapterBlueZ::AddLocalGattService( |
| 1063 std::unique_ptr<BluetoothLocalGattServiceBlueZ> service) { | 1070 std::unique_ptr<BluetoothLocalGattServiceBlueZ> service) { |
| 1064 owned_gatt_services_.push_back(std::move(service)); | 1071 owned_gatt_services_[service->object_path()] = std::move(service); |
| 1065 } | 1072 } |
| 1066 | 1073 |
| 1067 void BluetoothAdapterBlueZ::RegisterGattService( | 1074 void BluetoothAdapterBlueZ::RegisterGattService( |
| 1068 BluetoothLocalGattServiceBlueZ* service, | 1075 BluetoothLocalGattServiceBlueZ* service, |
| 1069 const base::Closure& callback, | 1076 const base::Closure& callback, |
| 1070 const device::BluetoothGattService::ErrorCallback& error_callback) { | 1077 const device::BluetoothGattService::ErrorCallback& error_callback) { |
| 1071 if (registered_gatt_services_.count(service->object_path()) > 0) { | 1078 if (registered_gatt_services_.count(service->object_path()) > 0) { |
| 1072 LOG(WARNING) << "Re-registering a service that is already registered!"; | 1079 LOG(WARNING) << "Re-registering a service that is already registered!"; |
| 1073 error_callback.Run(device::BluetoothGattService::GATT_ERROR_FAILED); | 1080 error_callback.Run(device::BluetoothGattService::GATT_ERROR_FAILED); |
| 1074 return; | 1081 return; |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1571 DCHECK(bluez::BluezDBusManager::Get()); | 1578 DCHECK(bluez::BluezDBusManager::Get()); |
| 1572 bluez::BluezDBusManager::Get() | 1579 bluez::BluezDBusManager::Get() |
| 1573 ->GetBluetoothGattManagerClient() | 1580 ->GetBluetoothGattManagerClient() |
| 1574 ->RegisterApplication( | 1581 ->RegisterApplication( |
| 1575 object_path_, GetApplicationObjectPath(), | 1582 object_path_, GetApplicationObjectPath(), |
| 1576 BluetoothGattManagerClient::Options(), callback, | 1583 BluetoothGattManagerClient::Options(), callback, |
| 1577 base::Bind(&OnRegisterationErrorCallback, error_callback)); | 1584 base::Bind(&OnRegisterationErrorCallback, error_callback)); |
| 1578 } | 1585 } |
| 1579 | 1586 |
| 1580 } // namespace bluez | 1587 } // namespace bluez |
| OLD | NEW |