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

Unified Diff: device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_client.cc

Issue 1915803002: Bluetooth class changes for implementing local GATT attributes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/dbus/fake_bluetooth_gatt_characteristic_client.cc
diff --git a/device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_client.cc b/device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_client.cc
index 15a219043067ca53f06577b746904812de3c943e..40f68fad1d7ac57dbef8f4100b736f36fccc089f 100644
--- a/device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_client.cc
+++ b/device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_client.cc
@@ -134,23 +134,24 @@ void FakeBluetoothGattCharacteristicClient::ReadValue(
const ValueCallback& callback,
const ErrorCallback& error_callback) {
if (!authenticated_) {
- error_callback.Run("org.bluez.Error.NotPaired", "Please login");
+ error_callback.Run(bluetooth_gatt_service::kErrorNotPaired, "Please login");
return;
}
if (!authorized_) {
- error_callback.Run("org.bluez.Error.NotAuthorized", "Authorize first");
+ error_callback.Run(bluetooth_gatt_service::kErrorNotAuthorized,
+ "Authorize first");
return;
}
if (object_path.value() == heart_rate_control_point_path_) {
- error_callback.Run("org.bluez.Error.NotPermitted",
+ error_callback.Run(bluetooth_gatt_service::kErrorReadNotPermitted,
"Reads of this value are not allowed");
return;
}
if (object_path.value() == heart_rate_measurement_path_) {
- error_callback.Run("org.bluez.Error.NotSupported",
+ error_callback.Run(bluetooth_gatt_service::kErrorNotSupported,
"Action not supported on this characteristic");
return;
}
@@ -164,7 +165,7 @@ void FakeBluetoothGattCharacteristicClient::ReadValue(
action_extra_requests_.end()) {
DelayedCallback* delayed = action_extra_requests_["ReadValue"];
delayed->delay_--;
- error_callback.Run("org.bluez.Error.InProgress",
+ error_callback.Run(bluetooth_gatt_service::kErrorInProgress,
"Another read is currenty in progress");
if (delayed->delay_ == 0) {
delayed->callback_.Run();
@@ -200,12 +201,13 @@ void FakeBluetoothGattCharacteristicClient::WriteValue(
const base::Closure& callback,
const ErrorCallback& error_callback) {
if (!authenticated_) {
- error_callback.Run("org.bluez.Error.NotPaired", "Please login");
+ error_callback.Run(bluetooth_gatt_service::kErrorNotPaired, "Please login");
return;
}
if (!authorized_) {
- error_callback.Run("org.bluez.Error.NotAuthorized", "Authorize first");
+ error_callback.Run(bluetooth_gatt_service::kErrorNotAuthorized,
+ "Authorize first");
return;
}
@@ -215,13 +217,13 @@ void FakeBluetoothGattCharacteristicClient::WriteValue(
}
if (object_path.value() == heart_rate_measurement_path_) {
- error_callback.Run("org.bluez.Error.NotSupported",
+ error_callback.Run(bluetooth_gatt_service::kErrorNotSupported,
"Action not supported on this characteristic");
return;
}
if (object_path.value() != heart_rate_control_point_path_) {
- error_callback.Run("org.bluez.Error.NotPermitted",
+ error_callback.Run(bluetooth_gatt_service::kErrorWriteNotPermitted,
"Writes of this value are not allowed");
return;
}
@@ -231,7 +233,7 @@ void FakeBluetoothGattCharacteristicClient::WriteValue(
action_extra_requests_.end()) {
DelayedCallback* delayed = action_extra_requests_["WriteValue"];
delayed->delay_--;
- error_callback.Run("org.bluez.Error.InProgress",
+ error_callback.Run(bluetooth_gatt_service::kErrorInProgress,
"Another write is in progress");
if (delayed->delay_ == 0) {
delayed->callback_.Run();
@@ -242,12 +244,13 @@ void FakeBluetoothGattCharacteristicClient::WriteValue(
}
base::Closure completed_callback;
if (value.size() != 1) {
- completed_callback =
- base::Bind(error_callback, "org.bluez.Error.InvalidValueLength",
- "Invalid length for write");
+ completed_callback = base::Bind(
+ error_callback, bluetooth_gatt_service::kErrorInvalidValueLength,
+ "Invalid length for write");
} else if (value[0] > 1) {
- completed_callback = base::Bind(error_callback, "org.bluez.Error.Failed",
- "Invalid value given for write");
+ completed_callback =
+ base::Bind(error_callback, bluetooth_gatt_service::kErrorFailed,
+ "Invalid value given for write");
} else if (value[0] == 1) {
// TODO(jamuraa): make this happen when the callback happens
calories_burned_ = 0;
@@ -272,13 +275,13 @@ void FakeBluetoothGattCharacteristicClient::StartNotify(
}
if (object_path.value() != heart_rate_measurement_path_) {
- error_callback.Run("org.bluez.Error.NotSupported",
+ error_callback.Run(bluetooth_gatt_service::kErrorNotSupported,
"This characteristic does not support notifications");
return;
}
if (heart_rate_measurement_properties_->notifying.value()) {
- error_callback.Run("org.bluez.Error.InProgress",
+ error_callback.Run(bluetooth_gatt_service::kErrorInProgress,
"Characteristic already notifying");
return;
}
@@ -302,13 +305,13 @@ void FakeBluetoothGattCharacteristicClient::StopNotify(
}
if (object_path.value() != heart_rate_measurement_path_) {
- error_callback.Run("org.bluez.Error.NotSupported",
+ error_callback.Run(bluetooth_gatt_service::kErrorNotSupported,
"This characteristic does not support notifications");
return;
}
if (!heart_rate_measurement_properties_->notifying.value()) {
- error_callback.Run("org.bluez.Error.Failed", "Not notifying");
+ error_callback.Run(bluetooth_gatt_service::kErrorFailed, "Not notifying");
return;
}

Powered by Google App Engine
This is Rietveld 408576698