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

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

Issue 99903003: nfc: Various fixes to the NFC D-Bus client in chromeos/dbus. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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
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_property_set.h" 5 #include "chromeos/dbus/nfc_property_set.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "third_party/cros_system_api/dbus/service_constants.h" 8 #include "third_party/cros_system_api/dbus/service_constants.h"
9 9
10 namespace chromeos { 10 namespace chromeos {
11 11
12 NfcPropertySet::NfcPropertySet(dbus::ObjectProxy* object_proxy, 12 NfcPropertySet::NfcPropertySet(dbus::ObjectProxy* object_proxy,
13 const std::string& interface, 13 const std::string& interface,
14 const PropertyChangedCallback& callback) 14 const PropertyChangedCallback& callback)
15 : dbus::PropertySet(object_proxy, interface, callback) { 15 : dbus::PropertySet(object_proxy, interface, callback) {
16 } 16 }
17 17
18 void NfcPropertySet::ConnectSignals() { 18 void NfcPropertySet::ConnectSignals() {
19 object_proxy()->ConnectToSignal( 19 object_proxy()->ConnectToSignal(
20 interface(), 20 interface(),
21 nfc_common::kPropertyChangedSignal, 21 nfc_common::kPropertyChangedSignal,
22 base::Bind(&dbus::PropertySet::ChangedReceived, GetWeakPtr()), 22 base::Bind(&dbus::PropertySet::ChangedReceived, GetWeakPtr()),
23 base::Bind(&dbus::PropertySet::ChangedConnected, GetWeakPtr())); 23 base::Bind(&dbus::PropertySet::ChangedConnected, GetWeakPtr()));
24 } 24 }
25 25
26 void NfcPropertySet::SetAllPropertiesReceivedCallback(
27 const base::Closure& callback) {
28 on_get_all_callback_ = callback;
29 }
30
26 void NfcPropertySet::Get(dbus::PropertyBase* property, 31 void NfcPropertySet::Get(dbus::PropertyBase* property,
27 GetCallback callback) { 32 GetCallback callback) {
28 NOTREACHED() << "neard does not implement Get for properties."; 33 NOTREACHED() << "neard does not implement Get for properties.";
29 } 34 }
30 35
31 void NfcPropertySet::GetAll() { 36 void NfcPropertySet::GetAll() {
32 dbus::MethodCall method_call( 37 dbus::MethodCall method_call(
33 interface(), nfc_common::kGetProperties); 38 interface(), nfc_common::kGetProperties);
34 object_proxy()->CallMethod(&method_call, 39 object_proxy()->CallMethod(&method_call,
35 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 40 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
36 base::Bind(&dbus::PropertySet::OnGetAll, 41 base::Bind(&dbus::PropertySet::OnGetAll,
37 GetWeakPtr())); 42 GetWeakPtr()));
38 } 43 }
39 44
45 void NfcPropertySet::OnGetAll(dbus::Response* response) {
46 // First invoke the superclass implementation. If the call to GetAll was
47 // successful, this will invoke the PropertyChangedCallback passed to the
48 // constructor for each individual property received through the call and
49 // make sure that the values of the properties have been cached. This way,
50 // all received properties will be available when |on_get_all_callback_| is
51 // run.
52 dbus::PropertySet::OnGetAll(response);
53 if (response) {
54 VLOG(2) << "NfcPropertySet::GetAll returned successfully.";
55 if (!on_get_all_callback_.is_null())
56 on_get_all_callback_.Run();
57 }
58 }
59
40 void NfcPropertySet::Set(dbus::PropertyBase* property, 60 void NfcPropertySet::Set(dbus::PropertyBase* property,
41 SetCallback callback) { 61 SetCallback callback) {
42 dbus::MethodCall method_call( 62 dbus::MethodCall method_call(
43 interface(), nfc_common::kSetProperty); 63 interface(), nfc_common::kSetProperty);
64 dbus::MessageWriter writer(&method_call);
65 writer.AppendString(property->name());
66 property->AppendSetValueToWriter(&writer);
44 object_proxy()->CallMethod(&method_call, 67 object_proxy()->CallMethod(&method_call,
45 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 68 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
46 base::Bind(&dbus::PropertySet::OnSet, 69 base::Bind(&dbus::PropertySet::OnSet,
47 GetWeakPtr(), 70 GetWeakPtr(),
48 property, 71 property,
49 callback)); 72 callback));
50 } 73 }
51 74
52 void NfcPropertySet::ChangedReceived(dbus::Signal* signal) { 75 void NfcPropertySet::ChangedReceived(dbus::Signal* signal) {
53 DCHECK(signal); 76 DCHECK(signal);
54 dbus::MessageReader reader(signal); 77 dbus::MessageReader reader(signal);
55 UpdatePropertyFromReader(&reader); 78 UpdatePropertyFromReader(&reader);
56 } 79 }
57 80
58 } // namespace chromeos 81 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698