Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_characteristic_client.h" | 5 #include "device/bluetooth/dbus/bluetooth_gatt_characteristic_client.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 object_manager_->GetObjectProxy(object_path); | 88 object_manager_->GetObjectProxy(object_path); |
| 89 if (!object_proxy) { | 89 if (!object_proxy) { |
| 90 error_callback.Run(kUnknownCharacteristicError, ""); | 90 error_callback.Run(kUnknownCharacteristicError, ""); |
| 91 return; | 91 return; |
| 92 } | 92 } |
| 93 | 93 |
| 94 dbus::MethodCall method_call( | 94 dbus::MethodCall method_call( |
| 95 bluetooth_gatt_characteristic::kBluetoothGattCharacteristicInterface, | 95 bluetooth_gatt_characteristic::kBluetoothGattCharacteristicInterface, |
| 96 bluetooth_gatt_characteristic::kReadValue); | 96 bluetooth_gatt_characteristic::kReadValue); |
| 97 | 97 |
| 98 // Append empty option dict | |
|
ortuno
2016/05/27 20:16:53
Any reason why you do this manually instead of usi
| |
| 99 dbus::MessageWriter writer(&method_call); | |
| 100 dbus::MessageWriter array_writer(NULL); | |
| 101 writer.OpenArray("{sv}", &array_writer); | |
| 102 writer.CloseContainer(&array_writer); | |
| 103 | |
| 98 object_proxy->CallMethodWithErrorCallback( | 104 object_proxy->CallMethodWithErrorCallback( |
| 99 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 105 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 100 base::Bind(&BluetoothGattCharacteristicClientImpl::OnValueSuccess, | 106 base::Bind(&BluetoothGattCharacteristicClientImpl::OnValueSuccess, |
| 101 weak_ptr_factory_.GetWeakPtr(), callback), | 107 weak_ptr_factory_.GetWeakPtr(), callback), |
| 102 base::Bind(&BluetoothGattCharacteristicClientImpl::OnError, | 108 base::Bind(&BluetoothGattCharacteristicClientImpl::OnError, |
| 103 weak_ptr_factory_.GetWeakPtr(), error_callback)); | 109 weak_ptr_factory_.GetWeakPtr(), error_callback)); |
| 104 } | 110 } |
| 105 | 111 |
| 106 // BluetoothGattCharacteristicClient override. | 112 // BluetoothGattCharacteristicClient override. |
| 107 void WriteValue(const dbus::ObjectPath& object_path, | 113 void WriteValue(const dbus::ObjectPath& object_path, |
| 108 const std::vector<uint8_t>& value, | 114 const std::vector<uint8_t>& value, |
| 109 const base::Closure& callback, | 115 const base::Closure& callback, |
| 110 const ErrorCallback& error_callback) override { | 116 const ErrorCallback& error_callback) override { |
| 111 dbus::ObjectProxy* object_proxy = | 117 dbus::ObjectProxy* object_proxy = |
| 112 object_manager_->GetObjectProxy(object_path); | 118 object_manager_->GetObjectProxy(object_path); |
| 113 if (!object_proxy) { | 119 if (!object_proxy) { |
| 114 error_callback.Run(kUnknownCharacteristicError, ""); | 120 error_callback.Run(kUnknownCharacteristicError, ""); |
| 115 return; | 121 return; |
| 116 } | 122 } |
| 117 | 123 |
| 118 dbus::MethodCall method_call( | 124 dbus::MethodCall method_call( |
| 119 bluetooth_gatt_characteristic::kBluetoothGattCharacteristicInterface, | 125 bluetooth_gatt_characteristic::kBluetoothGattCharacteristicInterface, |
| 120 bluetooth_gatt_characteristic::kWriteValue); | 126 bluetooth_gatt_characteristic::kWriteValue); |
| 121 dbus::MessageWriter writer(&method_call); | 127 dbus::MessageWriter writer(&method_call); |
| 122 writer.AppendArrayOfBytes(value.data(), value.size()); | 128 writer.AppendArrayOfBytes(value.data(), value.size()); |
| 123 | 129 |
| 130 // Append empty option dict | |
| 131 dbus::MessageWriter array_writer(NULL); | |
| 132 writer.OpenArray("{sv}", &array_writer); | |
| 133 writer.CloseContainer(&array_writer); | |
| 134 | |
| 124 object_proxy->CallMethodWithErrorCallback( | 135 object_proxy->CallMethodWithErrorCallback( |
| 125 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 136 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 126 base::Bind(&BluetoothGattCharacteristicClientImpl::OnSuccess, | 137 base::Bind(&BluetoothGattCharacteristicClientImpl::OnSuccess, |
| 127 weak_ptr_factory_.GetWeakPtr(), callback), | 138 weak_ptr_factory_.GetWeakPtr(), callback), |
| 128 base::Bind(&BluetoothGattCharacteristicClientImpl::OnError, | 139 base::Bind(&BluetoothGattCharacteristicClientImpl::OnError, |
| 129 weak_ptr_factory_.GetWeakPtr(), error_callback)); | 140 weak_ptr_factory_.GetWeakPtr(), error_callback)); |
| 130 } | 141 } |
| 131 | 142 |
| 132 // BluetoothGattCharacteristicClient override. | 143 // BluetoothGattCharacteristicClient override. |
| 133 void StartNotify(const dbus::ObjectPath& object_path, | 144 void StartNotify(const dbus::ObjectPath& object_path, |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 288 BluetoothGattCharacteristicClient::BluetoothGattCharacteristicClient() {} | 299 BluetoothGattCharacteristicClient::BluetoothGattCharacteristicClient() {} |
| 289 | 300 |
| 290 BluetoothGattCharacteristicClient::~BluetoothGattCharacteristicClient() {} | 301 BluetoothGattCharacteristicClient::~BluetoothGattCharacteristicClient() {} |
| 291 | 302 |
| 292 // static | 303 // static |
| 293 BluetoothGattCharacteristicClient* BluetoothGattCharacteristicClient::Create() { | 304 BluetoothGattCharacteristicClient* BluetoothGattCharacteristicClient::Create() { |
| 294 return new BluetoothGattCharacteristicClientImpl(); | 305 return new BluetoothGattCharacteristicClientImpl(); |
| 295 } | 306 } |
| 296 | 307 |
| 297 } // namespace bluez | 308 } // namespace bluez |
| OLD | NEW |