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

Side by Side Diff: chromeos/dbus/nfc_tag_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_device_client.cc ('k') | dbus/values_util.h » ('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_tag_client.h" 5 #include "chromeos/dbus/nfc_tag_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 NfcTagClient::Properties::Properties( 22 NfcTagClient::Properties::Properties(
22 dbus::ObjectProxy* object_proxy, 23 dbus::ObjectProxy* object_proxy,
23 const PropertyChangedCallback& callback) 24 const PropertyChangedCallback& callback)
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 std::string error_message = 103 std::string error_message =
103 "Cannot write data to tag with empty arguments."; 104 "Cannot write data to tag with empty arguments.";
104 LOG(ERROR) << error_message; 105 LOG(ERROR) << error_message;
105 error_callback.Run(nfc_error::kInvalidArguments, error_message); 106 error_callback.Run(nfc_error::kInvalidArguments, error_message);
106 return; 107 return;
107 } 108 }
108 109
109 // Create the arguments. 110 // Create the arguments.
110 dbus::MethodCall method_call(nfc_tag::kNfcTagInterface, nfc_tag::kWrite); 111 dbus::MethodCall method_call(nfc_tag::kNfcTagInterface, nfc_tag::kWrite);
111 dbus::MessageWriter writer(&method_call); 112 dbus::MessageWriter writer(&method_call);
112 dbus::MessageWriter array_writer(NULL); 113 dbus::AppendValueData(&writer, attributes);
113 dbus::MessageWriter dict_entry_writer(NULL);
114 writer.OpenArray("{sv}", &array_writer);
115 for (base::DictionaryValue::Iterator iter(attributes);
116 !iter.IsAtEnd(); iter.Advance()) {
117 array_writer.OpenDictEntry(&dict_entry_writer);
118 dict_entry_writer.AppendString(iter.key());
119 nfc_client_helpers::AppendValueDataAsVariant(&dict_entry_writer,
120 iter.value());
121 array_writer.CloseContainer(&dict_entry_writer);
122 }
123 writer.CloseContainer(&array_writer);
124 114
125 object_proxy->CallMethodWithErrorCallback( 115 object_proxy->CallMethodWithErrorCallback(
126 &method_call, 116 &method_call,
127 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 117 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
128 base::Bind(&nfc_client_helpers::OnSuccess, callback), 118 base::Bind(&nfc_client_helpers::OnSuccess, callback),
129 base::Bind(&nfc_client_helpers::OnError, error_callback)); 119 base::Bind(&nfc_client_helpers::OnError, error_callback));
130 } 120 }
131 121
132 protected: 122 protected:
133 // DBusClient override. 123 // DBusClient override.
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 } 251 }
262 252
263 NfcTagClient::~NfcTagClient() { 253 NfcTagClient::~NfcTagClient() {
264 } 254 }
265 255
266 NfcTagClient* NfcTagClient::Create(NfcAdapterClient* adapter_client) { 256 NfcTagClient* NfcTagClient::Create(NfcAdapterClient* adapter_client) {
267 return new NfcTagClientImpl(adapter_client); 257 return new NfcTagClientImpl(adapter_client);
268 } 258 }
269 259
270 } // namespace chromeos 260 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/nfc_device_client.cc ('k') | dbus/values_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698