| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/dbus/bluetooth_gatt_descriptor_service_provider_impl.
h" | 5 #include "device/bluetooth/dbus/bluetooth_gatt_descriptor_service_provider_impl.
h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 method_call, kErrorInvalidArgs, | 147 method_call, kErrorInvalidArgs, |
| 148 "No such interface: '" + interface_name + "'."); | 148 "No such interface: '" + interface_name + "'."); |
| 149 response_sender.Run(std::move(error_response)); | 149 response_sender.Run(std::move(error_response)); |
| 150 return; | 150 return; |
| 151 } | 151 } |
| 152 | 152 |
| 153 // If getting the "Value" property, obtain the value from the delegate. | 153 // If getting the "Value" property, obtain the value from the delegate. |
| 154 if (property_name == bluetooth_gatt_descriptor::kValueProperty) { | 154 if (property_name == bluetooth_gatt_descriptor::kValueProperty) { |
| 155 DCHECK(delegate_); | 155 DCHECK(delegate_); |
| 156 delegate_->GetValue( | 156 delegate_->GetValue( |
| 157 dbus::ObjectPath(), |
| 157 base::Bind(&BluetoothGattDescriptorServiceProviderImpl::OnGet, | 158 base::Bind(&BluetoothGattDescriptorServiceProviderImpl::OnGet, |
| 158 weak_ptr_factory_.GetWeakPtr(), method_call, | 159 weak_ptr_factory_.GetWeakPtr(), method_call, |
| 159 response_sender), | 160 response_sender), |
| 160 base::Bind(&BluetoothGattDescriptorServiceProviderImpl::OnFailure, | 161 base::Bind(&BluetoothGattDescriptorServiceProviderImpl::OnFailure, |
| 161 weak_ptr_factory_.GetWeakPtr(), method_call, | 162 weak_ptr_factory_.GetWeakPtr(), method_call, |
| 162 response_sender)); | 163 response_sender)); |
| 163 return; | 164 return; |
| 164 } | 165 } |
| 165 | 166 |
| 166 std::unique_ptr<dbus::Response> response = | 167 std::unique_ptr<dbus::Response> response = |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 method_call, kErrorInvalidArgs, | 251 method_call, kErrorInvalidArgs, |
| 251 "Property '" + property_name + "' has type 'ay'."); | 252 "Property '" + property_name + "' has type 'ay'."); |
| 252 response_sender.Run(std::move(error_response)); | 253 response_sender.Run(std::move(error_response)); |
| 253 return; | 254 return; |
| 254 } | 255 } |
| 255 | 256 |
| 256 // Pass the set request onto the delegate. | 257 // Pass the set request onto the delegate. |
| 257 std::vector<uint8_t> value(bytes, bytes + length); | 258 std::vector<uint8_t> value(bytes, bytes + length); |
| 258 DCHECK(delegate_); | 259 DCHECK(delegate_); |
| 259 delegate_->SetValue( | 260 delegate_->SetValue( |
| 260 value, | 261 dbus::ObjectPath(), value, |
| 261 base::Bind(&BluetoothGattDescriptorServiceProviderImpl::OnSet, | 262 base::Bind(&BluetoothGattDescriptorServiceProviderImpl::OnSet, |
| 262 weak_ptr_factory_.GetWeakPtr(), method_call, response_sender), | 263 weak_ptr_factory_.GetWeakPtr(), method_call, response_sender), |
| 263 base::Bind(&BluetoothGattDescriptorServiceProviderImpl::OnFailure, | 264 base::Bind(&BluetoothGattDescriptorServiceProviderImpl::OnFailure, |
| 264 weak_ptr_factory_.GetWeakPtr(), method_call, response_sender)); | 265 weak_ptr_factory_.GetWeakPtr(), method_call, response_sender)); |
| 265 } | 266 } |
| 266 | 267 |
| 267 void BluetoothGattDescriptorServiceProviderImpl::GetAll( | 268 void BluetoothGattDescriptorServiceProviderImpl::GetAll( |
| 268 dbus::MethodCall* method_call, | 269 dbus::MethodCall* method_call, |
| 269 dbus::ExportedObject::ResponseSender response_sender) { | 270 dbus::ExportedObject::ResponseSender response_sender) { |
| 270 VLOG(2) << "BluetoothGattDescriptorServiceProvider::GetAll: " | 271 VLOG(2) << "BluetoothGattDescriptorServiceProvider::GetAll: " |
| (...skipping 19 matching lines...) Expand all Loading... |
| 290 method_call, kErrorInvalidArgs, | 291 method_call, kErrorInvalidArgs, |
| 291 "No such interface: '" + interface_name + "'."); | 292 "No such interface: '" + interface_name + "'."); |
| 292 response_sender.Run(std::move(error_response)); | 293 response_sender.Run(std::move(error_response)); |
| 293 return; | 294 return; |
| 294 } | 295 } |
| 295 | 296 |
| 296 // Try to obtain the value from the delegate. We will construct the | 297 // Try to obtain the value from the delegate. We will construct the |
| 297 // response in the success callback. | 298 // response in the success callback. |
| 298 DCHECK(delegate_); | 299 DCHECK(delegate_); |
| 299 delegate_->GetValue( | 300 delegate_->GetValue( |
| 301 dbus::ObjectPath(), |
| 300 base::Bind(&BluetoothGattDescriptorServiceProviderImpl::OnGetAll, | 302 base::Bind(&BluetoothGattDescriptorServiceProviderImpl::OnGetAll, |
| 301 weak_ptr_factory_.GetWeakPtr(), method_call, response_sender), | 303 weak_ptr_factory_.GetWeakPtr(), method_call, response_sender), |
| 302 base::Bind(&BluetoothGattDescriptorServiceProviderImpl::OnFailure, | 304 base::Bind(&BluetoothGattDescriptorServiceProviderImpl::OnFailure, |
| 303 weak_ptr_factory_.GetWeakPtr(), method_call, response_sender)); | 305 weak_ptr_factory_.GetWeakPtr(), method_call, response_sender)); |
| 304 } | 306 } |
| 305 | 307 |
| 306 void BluetoothGattDescriptorServiceProviderImpl::OnExported( | 308 void BluetoothGattDescriptorServiceProviderImpl::OnExported( |
| 307 const std::string& interface_name, | 309 const std::string& interface_name, |
| 308 const std::string& method_name, | 310 const std::string& method_name, |
| 309 bool success) { | 311 bool success) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 method_call, kErrorFailed, "Failed to get/set descriptor value."); | 405 method_call, kErrorFailed, "Failed to get/set descriptor value."); |
| 404 response_sender.Run(std::move(error_response)); | 406 response_sender.Run(std::move(error_response)); |
| 405 } | 407 } |
| 406 | 408 |
| 407 const dbus::ObjectPath& | 409 const dbus::ObjectPath& |
| 408 BluetoothGattDescriptorServiceProviderImpl::object_path() const { | 410 BluetoothGattDescriptorServiceProviderImpl::object_path() const { |
| 409 return object_path_; | 411 return object_path_; |
| 410 } | 412 } |
| 411 | 413 |
| 412 } // namespace bluez | 414 } // namespace bluez |
| OLD | NEW |