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

Side by Side Diff: device/bluetooth/dbus/bluetooth_gatt_descriptor_client.cc

Issue 2016023002: bluetooth: Add option dict to ReadValue/WriteValue dbus call (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add empty dict instead 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 unified diff | Download patch
OLDNEW
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_descriptor_client.h" 5 #include "device/bluetooth/dbus/bluetooth_gatt_descriptor_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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 object_manager_->GetObjectProxy(object_path); 92 object_manager_->GetObjectProxy(object_path);
93 if (!object_proxy) { 93 if (!object_proxy) {
94 error_callback.Run(kUnknownDescriptorError, ""); 94 error_callback.Run(kUnknownDescriptorError, "");
95 return; 95 return;
96 } 96 }
97 97
98 dbus::MethodCall method_call( 98 dbus::MethodCall method_call(
99 bluetooth_gatt_descriptor::kBluetoothGattDescriptorInterface, 99 bluetooth_gatt_descriptor::kBluetoothGattDescriptorInterface,
100 bluetooth_gatt_descriptor::kReadValue); 100 bluetooth_gatt_descriptor::kReadValue);
101 101
102 // Append empty option dict
103 dbus::MessageWriter writer(&method_call);
104 dbus::MessageWriter array_writer(NULL);
105 writer.OpenArray("{sv}", &array_writer);
106 writer.CloseContainer(&array_writer);
107
102 object_proxy->CallMethodWithErrorCallback( 108 object_proxy->CallMethodWithErrorCallback(
103 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 109 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
104 base::Bind(&BluetoothGattDescriptorClientImpl::OnValueSuccess, 110 base::Bind(&BluetoothGattDescriptorClientImpl::OnValueSuccess,
105 weak_ptr_factory_.GetWeakPtr(), callback), 111 weak_ptr_factory_.GetWeakPtr(), callback),
106 base::Bind(&BluetoothGattDescriptorClientImpl::OnError, 112 base::Bind(&BluetoothGattDescriptorClientImpl::OnError,
107 weak_ptr_factory_.GetWeakPtr(), error_callback)); 113 weak_ptr_factory_.GetWeakPtr(), error_callback));
108 } 114 }
109 115
110 // BluetoothGattDescriptorClientImpl override. 116 // BluetoothGattDescriptorClientImpl override.
111 void WriteValue(const dbus::ObjectPath& object_path, 117 void WriteValue(const dbus::ObjectPath& object_path,
112 const std::vector<uint8_t>& value, 118 const std::vector<uint8_t>& value,
113 const base::Closure& callback, 119 const base::Closure& callback,
114 const ErrorCallback& error_callback) override { 120 const ErrorCallback& error_callback) override {
115 dbus::ObjectProxy* object_proxy = 121 dbus::ObjectProxy* object_proxy =
116 object_manager_->GetObjectProxy(object_path); 122 object_manager_->GetObjectProxy(object_path);
117 if (!object_proxy) { 123 if (!object_proxy) {
118 error_callback.Run(kUnknownDescriptorError, ""); 124 error_callback.Run(kUnknownDescriptorError, "");
119 return; 125 return;
120 } 126 }
121 127
122 dbus::MethodCall method_call( 128 dbus::MethodCall method_call(
123 bluetooth_gatt_descriptor::kBluetoothGattDescriptorInterface, 129 bluetooth_gatt_descriptor::kBluetoothGattDescriptorInterface,
124 bluetooth_gatt_descriptor::kWriteValue); 130 bluetooth_gatt_descriptor::kWriteValue);
125 dbus::MessageWriter writer(&method_call); 131 dbus::MessageWriter writer(&method_call);
126 writer.AppendArrayOfBytes(value.data(), value.size()); 132 writer.AppendArrayOfBytes(value.data(), value.size());
127 133
134 // Append empty option dict
135 dbus::MessageWriter array_writer(NULL);
136 writer.OpenArray("{sv}", &array_writer);
137 writer.CloseContainer(&array_writer);
138
128 object_proxy->CallMethodWithErrorCallback( 139 object_proxy->CallMethodWithErrorCallback(
129 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 140 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
130 base::Bind(&BluetoothGattDescriptorClientImpl::OnSuccess, 141 base::Bind(&BluetoothGattDescriptorClientImpl::OnSuccess,
131 weak_ptr_factory_.GetWeakPtr(), callback), 142 weak_ptr_factory_.GetWeakPtr(), callback),
132 base::Bind(&BluetoothGattDescriptorClientImpl::OnError, 143 base::Bind(&BluetoothGattDescriptorClientImpl::OnError,
133 weak_ptr_factory_.GetWeakPtr(), error_callback)); 144 weak_ptr_factory_.GetWeakPtr(), error_callback));
134 } 145 }
135 146
136 // dbus::ObjectManager::Interface override. 147 // dbus::ObjectManager::Interface override.
137 dbus::PropertySet* CreateProperties( 148 dbus::PropertySet* CreateProperties(
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 BluetoothGattDescriptorClient::BluetoothGattDescriptorClient() {} 256 BluetoothGattDescriptorClient::BluetoothGattDescriptorClient() {}
246 257
247 BluetoothGattDescriptorClient::~BluetoothGattDescriptorClient() {} 258 BluetoothGattDescriptorClient::~BluetoothGattDescriptorClient() {}
248 259
249 // static 260 // static
250 BluetoothGattDescriptorClient* BluetoothGattDescriptorClient::Create() { 261 BluetoothGattDescriptorClient* BluetoothGattDescriptorClient::Create() {
251 return new BluetoothGattDescriptorClientImpl(); 262 return new BluetoothGattDescriptorClientImpl();
252 } 263 }
253 264
254 } // namespace bluez 265 } // namespace bluez
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698