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

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

Issue 628883002: replace OVERRIDE and FINAL with override and final in chromeos/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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_tag_client.cc » ('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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 } 53 }
54 54
55 virtual ~NfcRecordClientImpl() { 55 virtual ~NfcRecordClientImpl() {
56 DCHECK(device_client_); 56 DCHECK(device_client_);
57 DCHECK(tag_client_); 57 DCHECK(tag_client_);
58 device_client_->RemoveObserver(this); 58 device_client_->RemoveObserver(this);
59 tag_client_->RemoveObserver(this); 59 tag_client_->RemoveObserver(this);
60 } 60 }
61 61
62 // NfcRecordClient override. 62 // NfcRecordClient override.
63 virtual void AddObserver(NfcRecordClient::Observer* observer) OVERRIDE { 63 virtual void AddObserver(NfcRecordClient::Observer* observer) override {
64 DCHECK(observer); 64 DCHECK(observer);
65 observers_.AddObserver(observer); 65 observers_.AddObserver(observer);
66 } 66 }
67 67
68 // NfcRecordClient override. 68 // NfcRecordClient override.
69 virtual void RemoveObserver(NfcRecordClient::Observer* observer) OVERRIDE { 69 virtual void RemoveObserver(NfcRecordClient::Observer* observer) override {
70 DCHECK(observer); 70 DCHECK(observer);
71 observers_.RemoveObserver(observer); 71 observers_.RemoveObserver(observer);
72 } 72 }
73 73
74 virtual std::vector<dbus::ObjectPath> GetRecordsForDevice( 74 virtual std::vector<dbus::ObjectPath> GetRecordsForDevice(
75 const dbus::ObjectPath& device_path) OVERRIDE { 75 const dbus::ObjectPath& device_path) override {
76 DBusObjectMap* object_map = 76 DBusObjectMap* object_map =
77 devices_and_tags_to_object_maps_.GetObjectMap(device_path); 77 devices_and_tags_to_object_maps_.GetObjectMap(device_path);
78 if (!object_map) 78 if (!object_map)
79 return std::vector<dbus::ObjectPath>(); 79 return std::vector<dbus::ObjectPath>();
80 return object_map->GetObjectPaths(); 80 return object_map->GetObjectPaths();
81 } 81 }
82 82
83 virtual std::vector<dbus::ObjectPath> GetRecordsForTag( 83 virtual std::vector<dbus::ObjectPath> GetRecordsForTag(
84 const dbus::ObjectPath& tag_path) OVERRIDE { 84 const dbus::ObjectPath& tag_path) override {
85 return GetRecordsForDevice(tag_path); 85 return GetRecordsForDevice(tag_path);
86 } 86 }
87 87
88 // NfcRecordClient override. 88 // NfcRecordClient override.
89 virtual Properties* GetProperties( 89 virtual Properties* GetProperties(
90 const dbus::ObjectPath& object_path) OVERRIDE { 90 const dbus::ObjectPath& object_path) override {
91 return static_cast<Properties*>( 91 return static_cast<Properties*>(
92 devices_and_tags_to_object_maps_.FindObjectProperties(object_path)); 92 devices_and_tags_to_object_maps_.FindObjectProperties(object_path));
93 } 93 }
94 94
95 protected: 95 protected:
96 // DBusClient override. 96 // DBusClient override.
97 virtual void Init(dbus::Bus* bus) OVERRIDE { 97 virtual void Init(dbus::Bus* bus) override {
98 VLOG(1) << "Creating NfcRecordClient impl"; 98 VLOG(1) << "Creating NfcRecordClient impl";
99 DCHECK(bus); 99 DCHECK(bus);
100 bus_ = bus; 100 bus_ = bus;
101 DCHECK(device_client_); 101 DCHECK(device_client_);
102 DCHECK(tag_client_); 102 DCHECK(tag_client_);
103 device_client_->AddObserver(this); 103 device_client_->AddObserver(this);
104 tag_client_->AddObserver(this); 104 tag_client_->AddObserver(this);
105 } 105 }
106 106
107 private: 107 private:
108 // NfcDeviceClient::Observer override. 108 // NfcDeviceClient::Observer override.
109 virtual void DeviceAdded(const dbus::ObjectPath& object_path) OVERRIDE { 109 virtual void DeviceAdded(const dbus::ObjectPath& object_path) override {
110 VLOG(1) << "Device added. Creating map for record proxies belonging to " 110 VLOG(1) << "Device added. Creating map for record proxies belonging to "
111 << "device: " << object_path.value(); 111 << "device: " << object_path.value();
112 devices_and_tags_to_object_maps_.CreateObjectMap( 112 devices_and_tags_to_object_maps_.CreateObjectMap(
113 object_path, nfc_record::kNfcRecordServiceName, this, bus_); 113 object_path, nfc_record::kNfcRecordServiceName, this, bus_);
114 } 114 }
115 115
116 // NfcDeviceClient::Observer override. 116 // NfcDeviceClient::Observer override.
117 virtual void DeviceRemoved(const dbus::ObjectPath& object_path) OVERRIDE { 117 virtual void DeviceRemoved(const dbus::ObjectPath& object_path) override {
118 // Neard doesn't send out property changed signals for the records that 118 // Neard doesn't send out property changed signals for the records that
119 // are removed when the device they belong to is removed. Clean up the 119 // are removed when the device they belong to is removed. Clean up the
120 // object proxies for records that belong to the removed device. 120 // object proxies for records that belong to the removed device.
121 // Note: DBusObjectMap guarantees that the Properties structure for the 121 // Note: DBusObjectMap guarantees that the Properties structure for the
122 // removed adapter will be valid before this method returns. 122 // removed adapter will be valid before this method returns.
123 VLOG(1) << "Device removed. Cleaning up record proxies belonging to " 123 VLOG(1) << "Device removed. Cleaning up record proxies belonging to "
124 << "device: " << object_path.value(); 124 << "device: " << object_path.value();
125 devices_and_tags_to_object_maps_.RemoveObjectMap(object_path); 125 devices_and_tags_to_object_maps_.RemoveObjectMap(object_path);
126 } 126 }
127 127
128 // NfcDeviceClient::Observer override. 128 // NfcDeviceClient::Observer override.
129 virtual void DevicePropertyChanged( 129 virtual void DevicePropertyChanged(
130 const dbus::ObjectPath& object_path, 130 const dbus::ObjectPath& object_path,
131 const std::string& property_name) OVERRIDE { 131 const std::string& property_name) override {
132 // Update the record proxies using records from the device. 132 // Update the record proxies using records from the device.
133 DCHECK(device_client_); 133 DCHECK(device_client_);
134 NfcDeviceClient::Properties* device_properties = 134 NfcDeviceClient::Properties* device_properties =
135 device_client_->GetProperties(object_path); 135 device_client_->GetProperties(object_path);
136 136
137 // Ignore changes to properties other than "Records". 137 // Ignore changes to properties other than "Records".
138 if (property_name != device_properties->records.name()) 138 if (property_name != device_properties->records.name())
139 return; 139 return;
140 140
141 // Update known records. 141 // Update known records.
142 VLOG(1) << "NFC records changed."; 142 VLOG(1) << "NFC records changed.";
143 const std::vector<dbus::ObjectPath>& received_records = 143 const std::vector<dbus::ObjectPath>& received_records =
144 device_properties->records.value(); 144 device_properties->records.value();
145 DBusObjectMap* object_map = 145 DBusObjectMap* object_map =
146 devices_and_tags_to_object_maps_.GetObjectMap(object_path); 146 devices_and_tags_to_object_maps_.GetObjectMap(object_path);
147 DCHECK(object_map); 147 DCHECK(object_map);
148 object_map->UpdateObjects(received_records); 148 object_map->UpdateObjects(received_records);
149 } 149 }
150 150
151 // NfcTagClient::Observer override. 151 // NfcTagClient::Observer override.
152 virtual void TagAdded(const dbus::ObjectPath& object_path) OVERRIDE { 152 virtual void TagAdded(const dbus::ObjectPath& object_path) override {
153 VLOG(1) << "Tag added. Creating map for record proxies belonging to " 153 VLOG(1) << "Tag added. Creating map for record proxies belonging to "
154 << "tag: " << object_path.value(); 154 << "tag: " << object_path.value();
155 devices_and_tags_to_object_maps_.CreateObjectMap( 155 devices_and_tags_to_object_maps_.CreateObjectMap(
156 object_path, nfc_record::kNfcRecordServiceName, this, bus_); 156 object_path, nfc_record::kNfcRecordServiceName, this, bus_);
157 } 157 }
158 158
159 // NfcTagClient::Observer override. 159 // NfcTagClient::Observer override.
160 virtual void TagRemoved(const dbus::ObjectPath& object_path) OVERRIDE { 160 virtual void TagRemoved(const dbus::ObjectPath& object_path) override {
161 // Neard doesn't send out property changed signals for the records that 161 // Neard doesn't send out property changed signals for the records that
162 // are removed when the tag they belong to is removed. Clean up the 162 // are removed when the tag they belong to is removed. Clean up the
163 // object proxies for records that belong to the removed tag. 163 // object proxies for records that belong to the removed tag.
164 // Note: DBusObjectMap guarantees that the Properties structure for the 164 // Note: DBusObjectMap guarantees that the Properties structure for the
165 // removed adapter will be valid before this method returns. 165 // removed adapter will be valid before this method returns.
166 VLOG(1) << "Tag removed. Cleaning up record proxies belonging to " 166 VLOG(1) << "Tag removed. Cleaning up record proxies belonging to "
167 << "tag: " << object_path.value(); 167 << "tag: " << object_path.value();
168 devices_and_tags_to_object_maps_.RemoveObjectMap(object_path); 168 devices_and_tags_to_object_maps_.RemoveObjectMap(object_path);
169 } 169 }
170 170
171 // NfcTagClient::Observer override. 171 // NfcTagClient::Observer override.
172 virtual void TagPropertyChanged(const dbus::ObjectPath& object_path, 172 virtual void TagPropertyChanged(const dbus::ObjectPath& object_path,
173 const std::string& property_name) OVERRIDE { 173 const std::string& property_name) override {
174 // Update the record proxies using records from the tag. 174 // Update the record proxies using records from the tag.
175 DCHECK(device_client_); 175 DCHECK(device_client_);
176 NfcTagClient::Properties* tag_properties = 176 NfcTagClient::Properties* tag_properties =
177 tag_client_->GetProperties(object_path); 177 tag_client_->GetProperties(object_path);
178 178
179 // Ignore changes to properties other than "Records". 179 // Ignore changes to properties other than "Records".
180 if (property_name != tag_properties->records.name()) 180 if (property_name != tag_properties->records.name())
181 return; 181 return;
182 182
183 // Update known records. 183 // Update known records.
184 VLOG(1) << "NFC records changed."; 184 VLOG(1) << "NFC records changed.";
185 const std::vector<dbus::ObjectPath>& received_records = 185 const std::vector<dbus::ObjectPath>& received_records =
186 tag_properties->records.value(); 186 tag_properties->records.value();
187 DBusObjectMap* object_map = 187 DBusObjectMap* object_map =
188 devices_and_tags_to_object_maps_.GetObjectMap(object_path); 188 devices_and_tags_to_object_maps_.GetObjectMap(object_path);
189 DCHECK(object_map); 189 DCHECK(object_map);
190 object_map->UpdateObjects(received_records); 190 object_map->UpdateObjects(received_records);
191 191
192 // When rewriting the record to a tag, neard fires a property changed 192 // When rewriting the record to a tag, neard fires a property changed
193 // signal for the tags "Records" property, without creating a new object 193 // signal for the tags "Records" property, without creating a new object
194 // path. Sync the properties of all records here, in case Update objects 194 // path. Sync the properties of all records here, in case Update objects
195 // doesn't do it. 195 // doesn't do it.
196 VLOG(1) << "Fetch properties for all records."; 196 VLOG(1) << "Fetch properties for all records.";
197 object_map->RefreshAllProperties(); 197 object_map->RefreshAllProperties();
198 } 198 }
199 199
200 // nfc_client_helpers::DBusObjectMap::Delegate override. 200 // nfc_client_helpers::DBusObjectMap::Delegate override.
201 virtual NfcPropertySet* CreateProperties( 201 virtual NfcPropertySet* CreateProperties(
202 dbus::ObjectProxy* object_proxy) OVERRIDE { 202 dbus::ObjectProxy* object_proxy) override {
203 Properties* properties = new Properties( 203 Properties* properties = new Properties(
204 object_proxy, 204 object_proxy,
205 base::Bind(&NfcRecordClientImpl::OnPropertyChanged, 205 base::Bind(&NfcRecordClientImpl::OnPropertyChanged,
206 weak_ptr_factory_.GetWeakPtr(), 206 weak_ptr_factory_.GetWeakPtr(),
207 object_proxy->object_path())); 207 object_proxy->object_path()));
208 properties->SetAllPropertiesReceivedCallback( 208 properties->SetAllPropertiesReceivedCallback(
209 base::Bind(&NfcRecordClientImpl::OnPropertiesReceived, 209 base::Bind(&NfcRecordClientImpl::OnPropertiesReceived,
210 weak_ptr_factory_.GetWeakPtr(), 210 weak_ptr_factory_.GetWeakPtr(),
211 object_proxy->object_path())); 211 object_proxy->object_path()));
212 return properties; 212 return properties;
213 } 213 }
214 214
215 // nfc_client_helpers::DBusObjectMap::Delegate override. 215 // nfc_client_helpers::DBusObjectMap::Delegate override.
216 virtual void ObjectAdded(const dbus::ObjectPath& object_path) OVERRIDE { 216 virtual void ObjectAdded(const dbus::ObjectPath& object_path) override {
217 FOR_EACH_OBSERVER(NfcRecordClient::Observer, observers_, 217 FOR_EACH_OBSERVER(NfcRecordClient::Observer, observers_,
218 RecordAdded(object_path)); 218 RecordAdded(object_path));
219 } 219 }
220 220
221 // nfc_client_helpers::DBusObjectMap::Delegate override. 221 // nfc_client_helpers::DBusObjectMap::Delegate override.
222 virtual void ObjectRemoved(const dbus::ObjectPath& object_path) OVERRIDE { 222 virtual void ObjectRemoved(const dbus::ObjectPath& object_path) override {
223 FOR_EACH_OBSERVER(NfcRecordClient::Observer, observers_, 223 FOR_EACH_OBSERVER(NfcRecordClient::Observer, observers_,
224 RecordRemoved(object_path)); 224 RecordRemoved(object_path));
225 } 225 }
226 226
227 // Called by NfcPropertySet when a property value is changed, either by 227 // Called by NfcPropertySet when a property value is changed, either by
228 // result of a signal or response to a GetAll() or Get() call. 228 // result of a signal or response to a GetAll() or Get() call.
229 void OnPropertyChanged(const dbus::ObjectPath& object_path, 229 void OnPropertyChanged(const dbus::ObjectPath& object_path,
230 const std::string& property_name) { 230 const std::string& property_name) {
231 VLOG(1) << "Record property changed; Path: " << object_path.value() 231 VLOG(1) << "Record property changed; Path: " << object_path.value()
232 << " Property: " << property_name; 232 << " Property: " << property_name;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 272
273 NfcRecordClient::~NfcRecordClient() { 273 NfcRecordClient::~NfcRecordClient() {
274 } 274 }
275 275
276 NfcRecordClient* NfcRecordClient::Create(NfcDeviceClient* device_client, 276 NfcRecordClient* NfcRecordClient::Create(NfcDeviceClient* device_client,
277 NfcTagClient* tag_client) { 277 NfcTagClient* tag_client) {
278 return new NfcRecordClientImpl(device_client, tag_client); 278 return new NfcRecordClientImpl(device_client, tag_client);
279 } 279 }
280 280
281 } // namespace chromeos 281 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/nfc_property_set.h ('k') | chromeos/dbus/nfc_tag_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698