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

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

Powered by Google App Engine
This is Rietveld 408576698