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

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

Issue 2036483002: bluetooth: Add option dict to ReadValue/WriteValue dbus call (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
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 unified diff | Download patch
« no previous file with comments | « device/bluetooth/dbus/bluetooth_gatt_characteristic_client.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/observer_list.h" 12 #include "base/observer_list.h"
13 #include "base/values.h"
13 #include "dbus/bus.h" 14 #include "dbus/bus.h"
14 #include "dbus/object_manager.h" 15 #include "dbus/object_manager.h"
16 #include "dbus/values_util.h"
15 #include "third_party/cros_system_api/dbus/service_constants.h" 17 #include "third_party/cros_system_api/dbus/service_constants.h"
16 18
17 namespace bluez { 19 namespace bluez {
18 20
19 namespace { 21 namespace {
20 22
21 // TODO(armansito): Move this constant to cros_system_api. 23 // TODO(armansito): Move this constant to cros_system_api.
22 const char kValueProperty[] = "Value"; 24 const char kValueProperty[] = "Value";
23 25
24 } // namespace 26 } // namespace
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 object_manager_->GetObjectProxy(object_path); 94 object_manager_->GetObjectProxy(object_path);
93 if (!object_proxy) { 95 if (!object_proxy) {
94 error_callback.Run(kUnknownDescriptorError, ""); 96 error_callback.Run(kUnknownDescriptorError, "");
95 return; 97 return;
96 } 98 }
97 99
98 dbus::MethodCall method_call( 100 dbus::MethodCall method_call(
99 bluetooth_gatt_descriptor::kBluetoothGattDescriptorInterface, 101 bluetooth_gatt_descriptor::kBluetoothGattDescriptorInterface,
100 bluetooth_gatt_descriptor::kReadValue); 102 bluetooth_gatt_descriptor::kReadValue);
101 103
104 // Append empty option dict
105 dbus::MessageWriter writer(&method_call);
106 base::DictionaryValue dict;
107 dbus::AppendValueData(&writer, dict);
108
102 object_proxy->CallMethodWithErrorCallback( 109 object_proxy->CallMethodWithErrorCallback(
103 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 110 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
104 base::Bind(&BluetoothGattDescriptorClientImpl::OnValueSuccess, 111 base::Bind(&BluetoothGattDescriptorClientImpl::OnValueSuccess,
105 weak_ptr_factory_.GetWeakPtr(), callback), 112 weak_ptr_factory_.GetWeakPtr(), callback),
106 base::Bind(&BluetoothGattDescriptorClientImpl::OnError, 113 base::Bind(&BluetoothGattDescriptorClientImpl::OnError,
107 weak_ptr_factory_.GetWeakPtr(), error_callback)); 114 weak_ptr_factory_.GetWeakPtr(), error_callback));
108 } 115 }
109 116
110 // BluetoothGattDescriptorClientImpl override. 117 // BluetoothGattDescriptorClientImpl override.
111 void WriteValue(const dbus::ObjectPath& object_path, 118 void WriteValue(const dbus::ObjectPath& object_path,
112 const std::vector<uint8_t>& value, 119 const std::vector<uint8_t>& value,
113 const base::Closure& callback, 120 const base::Closure& callback,
114 const ErrorCallback& error_callback) override { 121 const ErrorCallback& error_callback) override {
115 dbus::ObjectProxy* object_proxy = 122 dbus::ObjectProxy* object_proxy =
116 object_manager_->GetObjectProxy(object_path); 123 object_manager_->GetObjectProxy(object_path);
117 if (!object_proxy) { 124 if (!object_proxy) {
118 error_callback.Run(kUnknownDescriptorError, ""); 125 error_callback.Run(kUnknownDescriptorError, "");
119 return; 126 return;
120 } 127 }
121 128
122 dbus::MethodCall method_call( 129 dbus::MethodCall method_call(
123 bluetooth_gatt_descriptor::kBluetoothGattDescriptorInterface, 130 bluetooth_gatt_descriptor::kBluetoothGattDescriptorInterface,
124 bluetooth_gatt_descriptor::kWriteValue); 131 bluetooth_gatt_descriptor::kWriteValue);
125 dbus::MessageWriter writer(&method_call); 132 dbus::MessageWriter writer(&method_call);
126 writer.AppendArrayOfBytes(value.data(), value.size()); 133 writer.AppendArrayOfBytes(value.data(), value.size());
127 134
135 // Append empty option dict
136 base::DictionaryValue dict;
137 dbus::AppendValueData(&writer, dict);
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
« no previous file with comments | « device/bluetooth/dbus/bluetooth_gatt_characteristic_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698