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

Side by Side Diff: chromeos/dbus/nfc_record_client.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_record_client.h" 5 #include "chromeos/dbus/nfc_record_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 "chromeos/dbus/fake_nfc_record_client.h" 10 #include "chromeos/dbus/fake_nfc_record_client.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 // signal for the tags "Records" property, without creating a new object 180 // signal for the tags "Records" property, without creating a new object
181 // path. Sync the properties of all records here, in case Update objects 181 // path. Sync the properties of all records here, in case Update objects
182 // doesn't do it. 182 // doesn't do it.
183 VLOG(1) << "Fetch properties for all records."; 183 VLOG(1) << "Fetch properties for all records.";
184 object_map->RefreshAllProperties(); 184 object_map->RefreshAllProperties();
185 } 185 }
186 186
187 // nfc_client_helpers::DBusObjectMap::Delegate override. 187 // nfc_client_helpers::DBusObjectMap::Delegate override.
188 virtual NfcPropertySet* CreateProperties( 188 virtual NfcPropertySet* CreateProperties(
189 dbus::ObjectProxy* object_proxy) OVERRIDE { 189 dbus::ObjectProxy* object_proxy) OVERRIDE {
190 return new Properties( 190 Properties* properties = new Properties(
191 object_proxy, 191 object_proxy,
192 base::Bind(&NfcRecordClientImpl::OnPropertyChanged, 192 base::Bind(&NfcRecordClientImpl::OnPropertyChanged,
193 weak_ptr_factory_.GetWeakPtr(), 193 weak_ptr_factory_.GetWeakPtr(),
194 object_proxy->object_path())); 194 object_proxy->object_path()));
195 properties->SetAllPropertiesReceivedCallback(
196 base::Bind(&NfcRecordClientImpl::OnPropertiesReceived,
197 weak_ptr_factory_.GetWeakPtr(),
198 object_proxy->object_path()));
199 return properties;
195 } 200 }
196 201
197 // nfc_client_helpers::DBusObjectMap::Delegate override. 202 // nfc_client_helpers::DBusObjectMap::Delegate override.
198 virtual void ObjectAdded(const dbus::ObjectPath& object_path) OVERRIDE { 203 virtual void ObjectAdded(const dbus::ObjectPath& object_path) OVERRIDE {
199 FOR_EACH_OBSERVER(NfcRecordClient::Observer, observers_, 204 FOR_EACH_OBSERVER(NfcRecordClient::Observer, observers_,
200 RecordAdded(object_path)); 205 RecordAdded(object_path));
201 } 206 }
202 207
203 // nfc_client_helpers::DBusObjectMap::Delegate override. 208 // nfc_client_helpers::DBusObjectMap::Delegate override.
204 virtual void ObjectRemoved(const dbus::ObjectPath& object_path) OVERRIDE { 209 virtual void ObjectRemoved(const dbus::ObjectPath& object_path) OVERRIDE {
205 FOR_EACH_OBSERVER(NfcRecordClient::Observer, observers_, 210 FOR_EACH_OBSERVER(NfcRecordClient::Observer, observers_,
206 RecordRemoved(object_path)); 211 RecordRemoved(object_path));
207 } 212 }
208 213
209 // Called by NfcPropertySet when a property value is changed, either by 214 // Called by NfcPropertySet when a property value is changed, either by
210 // result of a signal or response to a GetAll() or Get() call. 215 // result of a signal or response to a GetAll() or Get() call.
211 void OnPropertyChanged(const dbus::ObjectPath& object_path, 216 void OnPropertyChanged(const dbus::ObjectPath& object_path,
212 const std::string& property_name) { 217 const std::string& property_name) {
213 VLOG(1) << "Record property changed; Path: " << object_path.value() 218 VLOG(1) << "Record property changed; Path: " << object_path.value()
214 << " Property: " << property_name; 219 << " Property: " << property_name;
215 FOR_EACH_OBSERVER(NfcRecordClient::Observer, observers_, 220 FOR_EACH_OBSERVER(NfcRecordClient::Observer, observers_,
216 RecordPropertyChanged(object_path, property_name)); 221 RecordPropertyChanged(object_path, property_name));
217 } 222 }
218 223
224 // Called by NfcPropertySet when all properties have been processed as a
225 // result of a call to GetAll.
226 void OnPropertiesReceived(const dbus::ObjectPath& object_path) {
227 VLOG(1) << "All record properties received; Path: " << object_path.value();
228 FOR_EACH_OBSERVER(NfcRecordClient::Observer, observers_,
229 RecordPropertiesReceived(object_path));
230 }
231
219 // We maintain a pointer to the bus to be able to request proxies for 232 // We maintain a pointer to the bus to be able to request proxies for
220 // new NFC records that appear. 233 // new NFC records that appear.
221 dbus::Bus* bus_; 234 dbus::Bus* bus_;
222 235
223 // List of observers interested in event notifications. 236 // List of observers interested in event notifications.
224 ObserverList<NfcRecordClient::Observer> observers_; 237 ObserverList<NfcRecordClient::Observer> observers_;
225 238
226 // Mapping from object paths to object proxies and properties structures that 239 // Mapping from object paths to object proxies and properties structures that
227 // were already created by us. Record objects belong to either Tag or Device 240 // were already created by us. Record objects belong to either Tag or Device
228 // objects. This structure stores a different DBusObjectMap for each known 241 // objects. This structure stores a different DBusObjectMap for each known
(...skipping 21 matching lines...) Expand all
250 NfcRecordClient* NfcRecordClient::Create(DBusClientImplementationType type, 263 NfcRecordClient* NfcRecordClient::Create(DBusClientImplementationType type,
251 NfcDeviceClient* device_client, 264 NfcDeviceClient* device_client,
252 NfcTagClient* tag_client) { 265 NfcTagClient* tag_client) {
253 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) 266 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
254 return new NfcRecordClientImpl(device_client, tag_client); 267 return new NfcRecordClientImpl(device_client, tag_client);
255 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); 268 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type);
256 return new FakeNfcRecordClient(); 269 return new FakeNfcRecordClient();
257 } 270 }
258 271
259 } // namespace chromeos 272 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698