| 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 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1095 return; | 1095 return; |
| 1096 } | 1096 } |
| 1097 | 1097 |
| 1098 registered_gatt_services_.erase(service->object_path()); | 1098 registered_gatt_services_.erase(service->object_path()); |
| 1099 | 1099 |
| 1100 // If we have no GATT services left, unregister our application. | 1100 // If we have no GATT services left, unregister our application. |
| 1101 if (registered_gatt_services_.size() == 0) { | 1101 if (registered_gatt_services_.size() == 0) { |
| 1102 bluez::BluezDBusManager::Get() | 1102 bluez::BluezDBusManager::Get() |
| 1103 ->GetBluetoothGattManagerClient() | 1103 ->GetBluetoothGattManagerClient() |
| 1104 ->UnregisterApplication( | 1104 ->UnregisterApplication( |
| 1105 GetApplicationObjectPath(), callback, | 1105 object_path_, GetApplicationObjectPath(), callback, |
| 1106 base::Bind(&OnRegisterationErrorCallback, error_callback)); | 1106 base::Bind(&OnRegisterationErrorCallback, error_callback)); |
| 1107 return; | 1107 return; |
| 1108 } | 1108 } |
| 1109 | 1109 |
| 1110 // Otherwise, this is tricky (since at the moment, BlueZ does not support | 1110 // Otherwise, this is tricky (since at the moment, BlueZ does not support |
| 1111 // adding/removing services individually). We need to update our list of | 1111 // adding/removing services individually). We need to update our list of |
| 1112 // services, then unregister our application, then re-register it with the | 1112 // services, then unregister our application, then re-register it with the |
| 1113 // updated services. TODO(rkc): Fix this once BlueZ is fixed. | 1113 // updated services. TODO(rkc): Fix this once BlueZ is fixed. |
| 1114 gatt_application_provider_ = BluetoothGattApplicationServiceProvider::Create( | 1114 gatt_application_provider_ = BluetoothGattApplicationServiceProvider::Create( |
| 1115 bluez::BluezDBusManager::Get()->GetSystemBus(), object_path_, | 1115 bluez::BluezDBusManager::Get()->GetSystemBus(), object_path_, |
| 1116 registered_gatt_services_); | 1116 registered_gatt_services_); |
| 1117 | 1117 |
| 1118 // Unregister our current application. If we are successful, make a call to | 1118 // Unregister our current application. If we are successful, make a call to |
| 1119 // register the application again with the current set of services. | 1119 // register the application again with the current set of services. |
| 1120 bluez::BluezDBusManager::Get() | 1120 bluez::BluezDBusManager::Get() |
| 1121 ->GetBluetoothGattManagerClient() | 1121 ->GetBluetoothGattManagerClient() |
| 1122 ->UnregisterApplication( | 1122 ->UnregisterApplication( |
| 1123 GetApplicationObjectPath(), | 1123 object_path_, GetApplicationObjectPath(), |
| 1124 base::Bind(&BluetoothAdapterBlueZ::RegisterApplication, | 1124 base::Bind(&BluetoothAdapterBlueZ::RegisterApplication, |
| 1125 weak_ptr_factory_.GetWeakPtr(), callback, error_callback), | 1125 weak_ptr_factory_.GetWeakPtr(), callback, error_callback), |
| 1126 base::Bind(&OnRegisterationErrorCallback, error_callback)); | 1126 base::Bind(&OnRegisterationErrorCallback, error_callback)); |
| 1127 } | 1127 } |
| 1128 | 1128 |
| 1129 // Returns the object path of the adapter. | 1129 // Returns the object path of the adapter. |
| 1130 dbus::ObjectPath BluetoothAdapterBlueZ::GetApplicationObjectPath() const { | 1130 dbus::ObjectPath BluetoothAdapterBlueZ::GetApplicationObjectPath() const { |
| 1131 return dbus::ObjectPath(object_path_.value() + kGattApplicationObjectPath); | 1131 return dbus::ObjectPath(object_path_.value() + kGattApplicationObjectPath); |
| 1132 } | 1132 } |
| 1133 | 1133 |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 } | 1565 } |
| 1566 } | 1566 } |
| 1567 | 1567 |
| 1568 void BluetoothAdapterBlueZ::RegisterApplication( | 1568 void BluetoothAdapterBlueZ::RegisterApplication( |
| 1569 const base::Closure& callback, | 1569 const base::Closure& callback, |
| 1570 const device::BluetoothGattService::ErrorCallback& error_callback) { | 1570 const device::BluetoothGattService::ErrorCallback& error_callback) { |
| 1571 DCHECK(bluez::BluezDBusManager::Get()); | 1571 DCHECK(bluez::BluezDBusManager::Get()); |
| 1572 bluez::BluezDBusManager::Get() | 1572 bluez::BluezDBusManager::Get() |
| 1573 ->GetBluetoothGattManagerClient() | 1573 ->GetBluetoothGattManagerClient() |
| 1574 ->RegisterApplication( | 1574 ->RegisterApplication( |
| 1575 GetApplicationObjectPath(), BluetoothGattManagerClient::Options(), | 1575 object_path_, GetApplicationObjectPath(), |
| 1576 callback, base::Bind(&OnRegisterationErrorCallback, error_callback)); | 1576 BluetoothGattManagerClient::Options(), callback, |
| 1577 base::Bind(&OnRegisterationErrorCallback, error_callback)); |
| 1577 } | 1578 } |
| 1578 | 1579 |
| 1579 } // namespace bluez | 1580 } // namespace bluez |
| OLD | NEW |