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

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: . 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 73e3f90dd010a1c65142863a16c0f52dc5c31516..6e304ad42ac1545cd19750f9e796cf9560f5fe1c 100644
--- a/device/bluetooth/bluez/bluetooth_adapter_bluez.cc
+++ b/device/bluetooth/bluez/bluetooth_adapter_bluez.cc
@@ -814,18 +814,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(
@@ -1648,4 +1656,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
« no previous file with comments | « device/bluetooth/bluez/bluetooth_adapter_bluez.h ('k') | device/bluetooth/bluez/bluetooth_service_attribute_value_bluez.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698