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

Side by Side Diff: chromeos/dbus/nfc_device_client.cc

Issue 221393004: dbus/values_util.h: Add functions to append collection type values to message. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed keybuk@'s comment, unmarked old functions as deprecated as they are useful. Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chromeos/dbus/nfc_client_helpers.cc ('k') | chromeos/dbus/nfc_tag_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chromeos/dbus/nfc_device_client.h" 5 #include "chromeos/dbus/nfc_device_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "base/observer_list.h" 9 #include "base/observer_list.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "chromeos/dbus/nfc_adapter_client.h" 11 #include "chromeos/dbus/nfc_adapter_client.h"
12 #include "dbus/bus.h" 12 #include "dbus/bus.h"
13 #include "dbus/message.h" 13 #include "dbus/message.h"
14 #include "dbus/values_util.h"
14 #include "third_party/cros_system_api/dbus/service_constants.h" 15 #include "third_party/cros_system_api/dbus/service_constants.h"
15 16
16 using chromeos::nfc_client_helpers::DBusObjectMap; 17 using chromeos::nfc_client_helpers::DBusObjectMap;
17 using chromeos::nfc_client_helpers::ObjectProxyTree; 18 using chromeos::nfc_client_helpers::ObjectProxyTree;
18 19
19 namespace chromeos { 20 namespace chromeos {
20 21
21 NfcDeviceClient::Properties::Properties( 22 NfcDeviceClient::Properties::Properties(
22 dbus::ObjectProxy* object_proxy, 23 dbus::ObjectProxy* object_proxy,
23 const PropertyChangedCallback& callback) 24 const PropertyChangedCallback& callback)
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 "Cannot push data to device with empty arguments."; 102 "Cannot push data to device with empty arguments.";
102 LOG(ERROR) << error_message; 103 LOG(ERROR) << error_message;
103 error_callback.Run(nfc_error::kInvalidArguments, error_message); 104 error_callback.Run(nfc_error::kInvalidArguments, error_message);
104 return; 105 return;
105 } 106 }
106 107
107 // Create the arguments. 108 // Create the arguments.
108 dbus::MethodCall method_call(nfc_device::kNfcDeviceInterface, 109 dbus::MethodCall method_call(nfc_device::kNfcDeviceInterface,
109 nfc_device::kPush); 110 nfc_device::kPush);
110 dbus::MessageWriter writer(&method_call); 111 dbus::MessageWriter writer(&method_call);
111 dbus::MessageWriter array_writer(NULL); 112 dbus::AppendValueData(&writer, attributes);
112 dbus::MessageWriter dict_entry_writer(NULL);
113 writer.OpenArray("{sv}", &array_writer);
114 for (base::DictionaryValue::Iterator iter(attributes);
115 !iter.IsAtEnd(); iter.Advance()) {
116 array_writer.OpenDictEntry(&dict_entry_writer);
117 dict_entry_writer.AppendString(iter.key());
118 nfc_client_helpers::AppendValueDataAsVariant(&dict_entry_writer,
119 iter.value());
120 array_writer.CloseContainer(&dict_entry_writer);
121 }
122 writer.CloseContainer(&array_writer);
123 113
124 object_proxy->CallMethodWithErrorCallback( 114 object_proxy->CallMethodWithErrorCallback(
125 &method_call, 115 &method_call,
126 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 116 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
127 base::Bind(&nfc_client_helpers::OnSuccess, callback), 117 base::Bind(&nfc_client_helpers::OnSuccess, callback),
128 base::Bind(&nfc_client_helpers::OnError, error_callback)); 118 base::Bind(&nfc_client_helpers::OnError, error_callback));
129 } 119 }
130 120
131 protected: 121 protected:
132 // DBusClient override. 122 // DBusClient override.
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 } 231 }
242 232
243 NfcDeviceClient::~NfcDeviceClient() { 233 NfcDeviceClient::~NfcDeviceClient() {
244 } 234 }
245 235
246 NfcDeviceClient* NfcDeviceClient::Create(NfcAdapterClient* adapter_client) { 236 NfcDeviceClient* NfcDeviceClient::Create(NfcAdapterClient* adapter_client) {
247 return new NfcDeviceClientImpl(adapter_client); 237 return new NfcDeviceClientImpl(adapter_client);
248 } 238 }
249 239
250 } // namespace chromeos 240 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/nfc_client_helpers.cc ('k') | chromeos/dbus/nfc_tag_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698