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

Unified Diff: device/bluetooth/bluez/bluetooth_adapter_bluez.cc

Issue 2084463002: BlueZ + DBus implementations of create/remove service record functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes + moar tests Created 4 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 side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/bluez/bluetooth_adapter_bluez.cc
diff --git a/device/bluetooth/bluez/bluetooth_adapter_bluez.cc b/device/bluetooth/bluez/bluetooth_adapter_bluez.cc
index 4f32eae3ca15524c53137c5804a0a3cd05bdfc3a..5f2a17bbeed638b1dbf8c77809694cf0a47e6039 100644
--- a/device/bluetooth/bluez/bluetooth_adapter_bluez.cc
+++ b/device/bluetooth/bluez/bluetooth_adapter_bluez.cc
@@ -813,18 +813,26 @@ void BluetoothAdapterBlueZ::OnRegisterAudioSink(
void BluetoothAdapterBlueZ::CreateServiceRecord(
const BluetoothServiceRecordBlueZ& record,
- const base::Closure& callback,
+ const ServiceRecordCallback& callback,
const ServiceRecordErrorCallback& error_callback) {
- // TODO(rkc): Implement this.
- callback.Run();
+ bluez::BluezDBusManager::Get()
+ ->GetBluetoothAdapterClient()
+ ->CreateServiceRecord(
+ object_path_, record, callback,
+ base::Bind(&BluetoothAdapterBlueZ::ServiceRecordErrorConnector,
+ weak_ptr_factory_.GetWeakPtr(), error_callback));
}
void BluetoothAdapterBlueZ::RemoveServiceRecord(
- const device::BluetoothUUID& uuid,
+ uint32_t handle,
const base::Closure& callback,
const ServiceRecordErrorCallback& error_callback) {
- // TODO(rkc): Implement this.
- callback.Run();
+ bluez::BluezDBusManager::Get()
+ ->GetBluetoothAdapterClient()
+ ->RemoveServiceRecord(
+ object_path_, handle, callback,
+ base::Bind(&BluetoothAdapterBlueZ::ServiceRecordErrorConnector,
+ weak_ptr_factory_.GetWeakPtr(), error_callback));
}
BluetoothDeviceBlueZ* BluetoothAdapterBlueZ::GetDeviceWithPath(
@@ -1649,4 +1657,26 @@ void BluetoothAdapterBlueZ::RegisterApplicationOnError(
RegisterApplication(callback, error_callback);
}
+void BluetoothAdapterBlueZ::ServiceRecordErrorConnector(
+ const ServiceRecordErrorCallback& error_callback,
+ const std::string& error_name,
+ const std::string& error_message) {
+ VLOG(1) << "Creating service record failed: error: " << error_name << " - "
+ << error_message;
+
+ BluetoothServiceRecordBlueZ::ErrorCode code =
+ BluetoothServiceRecordBlueZ::ErrorCode::UNKNOWN;
+ if (error_name == bluetooth_adapter::kErrorInvalidArguments) {
+ code = BluetoothServiceRecordBlueZ::ErrorCode::ERROR_INVALID_ARGUMENTS;
+ } else if (error_name == bluetooth_adapter::kErrorDoesNotExist) {
+ code = BluetoothServiceRecordBlueZ::ErrorCode::ERROR_RECORD_DOES_NOT_EXIST;
+ } else if (error_name == bluetooth_adapter::kErrorAlreadyExists) {
+ code = BluetoothServiceRecordBlueZ::ErrorCode::ERROR_RECORD_ALREADY_EXISTS;
+ } else if (error_name == bluetooth_adapter::kErrorNotReady) {
+ code = BluetoothServiceRecordBlueZ::ErrorCode::ERROR_ADAPTER_NOT_READY;
+ }
+
+ error_callback.Run(code);
+}
+
} // namespace bluez

Powered by Google App Engine
This is Rietveld 408576698