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

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

Issue 2292703002: chromeos: Remove unused NFC D-Bus client library (Closed)
Patch Set: rebase Created 4 years, 3 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 | « chromeos/dbus/nfc_property_set.h ('k') | chromeos/dbus/nfc_record_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chromeos/dbus/nfc_property_set.h"
6
7 #include "base/bind.h"
8 #include "third_party/cros_system_api/dbus/service_constants.h"
9
10 namespace chromeos {
11
12 NfcPropertySet::NfcPropertySet(dbus::ObjectProxy* object_proxy,
13 const std::string& interface,
14 const PropertyChangedCallback& callback)
15 : dbus::PropertySet(object_proxy, interface, callback),
16 weak_ptr_factory_(this) {}
17
18 NfcPropertySet::~NfcPropertySet() {
19 }
20
21 void NfcPropertySet::ConnectSignals() {
22 object_proxy()->ConnectToSignal(
23 interface(), nfc_common::kPropertyChangedSignal,
24 base::Bind(&dbus::PropertySet::ChangedReceived,
25 weak_ptr_factory_.GetWeakPtr()),
26 base::Bind(&dbus::PropertySet::ChangedConnected,
27 weak_ptr_factory_.GetWeakPtr()));
28 }
29
30 void NfcPropertySet::SetAllPropertiesReceivedCallback(
31 const base::Closure& callback) {
32 on_get_all_callback_ = callback;
33 }
34
35 void NfcPropertySet::Get(dbus::PropertyBase* property,
36 GetCallback callback) {
37 NOTREACHED() << "neard does not implement Get for properties.";
38 }
39
40 void NfcPropertySet::GetAll() {
41 dbus::MethodCall method_call(
42 interface(), nfc_common::kGetProperties);
43 object_proxy()->CallMethodWithErrorCallback(
44 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
45 base::Bind(&dbus::PropertySet::OnGetAll, weak_ptr_factory_.GetWeakPtr()),
46 base::Bind(&NfcPropertySet::OnGetAllError,
47 weak_ptr_factory_.GetWeakPtr()));
48 }
49
50 void NfcPropertySet::OnGetAll(dbus::Response* response) {
51 // First invoke the superclass implementation. If the call to GetAll was
52 // successful, this will invoke the PropertyChangedCallback passed to the
53 // constructor for each individual property received through the call and
54 // make sure that the values of the properties have been cached. This way,
55 // all received properties will be available when |on_get_all_callback_| is
56 // run.
57 dbus::PropertySet::OnGetAll(response);
58 if (response) {
59 VLOG(2) << "NfcPropertySet::GetAll returned successfully.";
60 if (!on_get_all_callback_.is_null())
61 on_get_all_callback_.Run();
62 }
63 }
64
65 void NfcPropertySet::Set(dbus::PropertyBase* property,
66 SetCallback callback) {
67 dbus::MethodCall method_call(
68 interface(), nfc_common::kSetProperty);
69 dbus::MessageWriter writer(&method_call);
70 writer.AppendString(property->name());
71 property->AppendSetValueToWriter(&writer);
72 object_proxy()->CallMethod(
73 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
74 base::Bind(&dbus::PropertySet::OnSet, weak_ptr_factory_.GetWeakPtr(),
75 property, callback));
76 }
77
78 void NfcPropertySet::ChangedReceived(dbus::Signal* signal) {
79 DCHECK(signal);
80 dbus::MessageReader reader(signal);
81 UpdatePropertyFromReader(&reader);
82 }
83
84 void NfcPropertySet::OnGetAllError(dbus::ErrorResponse* response) {
85 if (response) {
86 dbus::MessageReader reader(response);
87 std::string error_message;
88 reader.PopString(&error_message);
89
90 if (response->GetErrorName() == DBUS_ERROR_SERVICE_UNKNOWN) {
91 // Do not LOG(ERROR) if service is unknown. crbug.com/393311.
92 VLOG(2) << "NfcPropertySet::GetAll failed because the service is unknown."
93 << " NFC not enabled on this device? : " << error_message;
94 } else {
95 LOG(ERROR) << "NfcPropertySet::GetAll failed: " << error_message;
96 }
97 }
98 OnGetAll(nullptr);
99 }
100
101 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/nfc_property_set.h ('k') | chromeos/dbus/nfc_record_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698