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

Side by Side Diff: chromeos/dbus/nfc_tag_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_record_client.cc ('k') | chromeos/dbus/permission_broker_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_tag_client.h" 5 #include "chromeos/dbus/nfc_tag_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 "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 weak_ptr_factory_(this) { 45 weak_ptr_factory_(this) {
46 DCHECK(adapter_client); 46 DCHECK(adapter_client);
47 } 47 }
48 48
49 virtual ~NfcTagClientImpl() { 49 virtual ~NfcTagClientImpl() {
50 DCHECK(adapter_client_); 50 DCHECK(adapter_client_);
51 adapter_client_->RemoveObserver(this); 51 adapter_client_->RemoveObserver(this);
52 } 52 }
53 53
54 // NfcTagClient override. 54 // NfcTagClient override.
55 virtual void AddObserver(NfcTagClient::Observer* observer) OVERRIDE { 55 virtual void AddObserver(NfcTagClient::Observer* observer) override {
56 DCHECK(observer); 56 DCHECK(observer);
57 observers_.AddObserver(observer); 57 observers_.AddObserver(observer);
58 } 58 }
59 59
60 // NfcTagClient override. 60 // NfcTagClient override.
61 virtual void RemoveObserver(NfcTagClient::Observer* observer) OVERRIDE { 61 virtual void RemoveObserver(NfcTagClient::Observer* observer) override {
62 DCHECK(observer); 62 DCHECK(observer);
63 observers_.RemoveObserver(observer); 63 observers_.RemoveObserver(observer);
64 } 64 }
65 65
66 // NfcTagClient override. 66 // NfcTagClient override.
67 virtual std::vector<dbus::ObjectPath> GetTagsForAdapter( 67 virtual std::vector<dbus::ObjectPath> GetTagsForAdapter(
68 const dbus::ObjectPath& adapter_path) OVERRIDE { 68 const dbus::ObjectPath& adapter_path) override {
69 DBusObjectMap* object_map = 69 DBusObjectMap* object_map =
70 adapters_to_object_maps_.GetObjectMap(adapter_path); 70 adapters_to_object_maps_.GetObjectMap(adapter_path);
71 if (!object_map) 71 if (!object_map)
72 return std::vector<dbus::ObjectPath>(); 72 return std::vector<dbus::ObjectPath>();
73 return object_map->GetObjectPaths(); 73 return object_map->GetObjectPaths();
74 } 74 }
75 75
76 // NfcTagClient override. 76 // NfcTagClient override.
77 virtual Properties* GetProperties( 77 virtual Properties* GetProperties(
78 const dbus::ObjectPath& object_path) OVERRIDE { 78 const dbus::ObjectPath& object_path) override {
79 return static_cast<Properties*>( 79 return static_cast<Properties*>(
80 adapters_to_object_maps_.FindObjectProperties(object_path)); 80 adapters_to_object_maps_.FindObjectProperties(object_path));
81 } 81 }
82 82
83 // NfcTagClient override. 83 // NfcTagClient override.
84 virtual void Write( 84 virtual void Write(
85 const dbus::ObjectPath& object_path, 85 const dbus::ObjectPath& object_path,
86 const base::DictionaryValue& attributes, 86 const base::DictionaryValue& attributes,
87 const base::Closure& callback, 87 const base::Closure& callback,
88 const nfc_client_helpers::ErrorCallback& error_callback) OVERRIDE { 88 const nfc_client_helpers::ErrorCallback& error_callback) override {
89 dbus::ObjectProxy* object_proxy = 89 dbus::ObjectProxy* object_proxy =
90 adapters_to_object_maps_.FindObjectProxy(object_path); 90 adapters_to_object_maps_.FindObjectProxy(object_path);
91 if (!object_proxy) { 91 if (!object_proxy) {
92 std::string error_message = 92 std::string error_message =
93 base::StringPrintf("NFC tag with object path \"%s\" does not exist.", 93 base::StringPrintf("NFC tag with object path \"%s\" does not exist.",
94 object_path.value().c_str()); 94 object_path.value().c_str());
95 LOG(ERROR) << error_message; 95 LOG(ERROR) << error_message;
96 error_callback.Run(nfc_client_helpers::kUnknownObjectError, 96 error_callback.Run(nfc_client_helpers::kUnknownObjectError,
97 error_message); 97 error_message);
98 return; 98 return;
(...skipping 15 matching lines...) Expand all
114 114
115 object_proxy->CallMethodWithErrorCallback( 115 object_proxy->CallMethodWithErrorCallback(
116 &method_call, 116 &method_call,
117 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 117 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
118 base::Bind(&nfc_client_helpers::OnSuccess, callback), 118 base::Bind(&nfc_client_helpers::OnSuccess, callback),
119 base::Bind(&nfc_client_helpers::OnError, error_callback)); 119 base::Bind(&nfc_client_helpers::OnError, error_callback));
120 } 120 }
121 121
122 protected: 122 protected:
123 // DBusClient override. 123 // DBusClient override.
124 virtual void Init(dbus::Bus* bus) OVERRIDE { 124 virtual void Init(dbus::Bus* bus) override {
125 VLOG(1) << "Creating NfcTagClientImpl"; 125 VLOG(1) << "Creating NfcTagClientImpl";
126 DCHECK(bus); 126 DCHECK(bus);
127 bus_ = bus; 127 bus_ = bus;
128 DCHECK(adapter_client_); 128 DCHECK(adapter_client_);
129 adapter_client_->AddObserver(this); 129 adapter_client_->AddObserver(this);
130 } 130 }
131 131
132 private: 132 private:
133 // NfcAdapterClient::Observer override. 133 // NfcAdapterClient::Observer override.
134 virtual void AdapterAdded(const dbus::ObjectPath& object_path) OVERRIDE { 134 virtual void AdapterAdded(const dbus::ObjectPath& object_path) override {
135 VLOG(1) << "Adapter added. Creating map for tag proxies belonging to " 135 VLOG(1) << "Adapter added. Creating map for tag proxies belonging to "
136 << "adapter: " << object_path.value(); 136 << "adapter: " << object_path.value();
137 adapters_to_object_maps_.CreateObjectMap( 137 adapters_to_object_maps_.CreateObjectMap(
138 object_path, nfc_tag::kNfcTagServiceName, this, bus_); 138 object_path, nfc_tag::kNfcTagServiceName, this, bus_);
139 } 139 }
140 140
141 // NfcAdapterClient::Observer override. 141 // NfcAdapterClient::Observer override.
142 virtual void AdapterRemoved(const dbus::ObjectPath& object_path) OVERRIDE { 142 virtual void AdapterRemoved(const dbus::ObjectPath& object_path) override {
143 // Neard doesn't send out property changed signals for the tags that 143 // Neard doesn't send out property changed signals for the tags that
144 // are removed when the adapter they belong to is removed. Clean up the 144 // are removed when the adapter they belong to is removed. Clean up the
145 // object proxies for devices that are managed by the removed adapter. 145 // object proxies for devices that are managed by the removed adapter.
146 // Note: DBusObjectMap guarantees that the Properties structure for the 146 // Note: DBusObjectMap guarantees that the Properties structure for the
147 // removed adapter will be valid before this method returns. 147 // removed adapter will be valid before this method returns.
148 VLOG(1) << "Adapter removed. Cleaning up tag proxies belonging to " 148 VLOG(1) << "Adapter removed. Cleaning up tag proxies belonging to "
149 << "adapter: " << object_path.value(); 149 << "adapter: " << object_path.value();
150 adapters_to_object_maps_.RemoveObjectMap(object_path); 150 adapters_to_object_maps_.RemoveObjectMap(object_path);
151 } 151 }
152 152
153 // NfcAdapterClient::Observer override. 153 // NfcAdapterClient::Observer override.
154 virtual void AdapterPropertyChanged( 154 virtual void AdapterPropertyChanged(
155 const dbus::ObjectPath& object_path, 155 const dbus::ObjectPath& object_path,
156 const std::string& property_name) OVERRIDE { 156 const std::string& property_name) override {
157 // Update the tag proxies. 157 // Update the tag proxies.
158 DCHECK(adapter_client_); 158 DCHECK(adapter_client_);
159 NfcAdapterClient::Properties *adapter_properties = 159 NfcAdapterClient::Properties *adapter_properties =
160 adapter_client_->GetProperties(object_path); 160 adapter_client_->GetProperties(object_path);
161 DCHECK(adapter_properties); 161 DCHECK(adapter_properties);
162 if (!adapter_properties) { 162 if (!adapter_properties) {
163 LOG(ERROR) << "No property structure found for adapter: " 163 LOG(ERROR) << "No property structure found for adapter: "
164 << object_path.value(); 164 << object_path.value();
165 return; 165 return;
166 } 166 }
167 167
168 // Ignore changes to properties other than "Tags". 168 // Ignore changes to properties other than "Tags".
169 if (property_name != adapter_properties->tags.name()) 169 if (property_name != adapter_properties->tags.name())
170 return; 170 return;
171 171
172 // Update the known tags. 172 // Update the known tags.
173 VLOG(1) << "NFC tags changed."; 173 VLOG(1) << "NFC tags changed.";
174 const std::vector<dbus::ObjectPath>& received_tags = 174 const std::vector<dbus::ObjectPath>& received_tags =
175 adapter_properties->tags.value(); 175 adapter_properties->tags.value();
176 DBusObjectMap* object_map = 176 DBusObjectMap* object_map =
177 adapters_to_object_maps_.GetObjectMap(object_path); 177 adapters_to_object_maps_.GetObjectMap(object_path);
178 DCHECK(object_map); 178 DCHECK(object_map);
179 object_map->UpdateObjects(received_tags); 179 object_map->UpdateObjects(received_tags);
180 } 180 }
181 181
182 // nfc_client_helpers::DBusObjectMap::Delegate override. 182 // nfc_client_helpers::DBusObjectMap::Delegate override.
183 virtual NfcPropertySet* CreateProperties( 183 virtual NfcPropertySet* CreateProperties(
184 dbus::ObjectProxy* object_proxy) OVERRIDE { 184 dbus::ObjectProxy* object_proxy) override {
185 Properties* properties = new Properties( 185 Properties* properties = new Properties(
186 object_proxy, 186 object_proxy,
187 base::Bind(&NfcTagClientImpl::OnPropertyChanged, 187 base::Bind(&NfcTagClientImpl::OnPropertyChanged,
188 weak_ptr_factory_.GetWeakPtr(), 188 weak_ptr_factory_.GetWeakPtr(),
189 object_proxy->object_path())); 189 object_proxy->object_path()));
190 properties->SetAllPropertiesReceivedCallback( 190 properties->SetAllPropertiesReceivedCallback(
191 base::Bind(&NfcTagClientImpl::OnPropertiesReceived, 191 base::Bind(&NfcTagClientImpl::OnPropertiesReceived,
192 weak_ptr_factory_.GetWeakPtr(), 192 weak_ptr_factory_.GetWeakPtr(),
193 object_proxy->object_path())); 193 object_proxy->object_path()));
194 return properties; 194 return properties;
195 } 195 }
196 196
197 // nfc_client_helpers::DBusObjectMap::Delegate override. 197 // nfc_client_helpers::DBusObjectMap::Delegate override.
198 virtual void ObjectAdded(const dbus::ObjectPath& object_path) OVERRIDE { 198 virtual void ObjectAdded(const dbus::ObjectPath& object_path) override {
199 FOR_EACH_OBSERVER(NfcTagClient::Observer, observers_, 199 FOR_EACH_OBSERVER(NfcTagClient::Observer, observers_,
200 TagAdded(object_path)); 200 TagAdded(object_path));
201 } 201 }
202 202
203 virtual void ObjectRemoved(const dbus::ObjectPath& object_path) OVERRIDE { 203 virtual void ObjectRemoved(const dbus::ObjectPath& object_path) override {
204 FOR_EACH_OBSERVER(NfcTagClient::Observer, observers_, 204 FOR_EACH_OBSERVER(NfcTagClient::Observer, observers_,
205 TagRemoved(object_path)); 205 TagRemoved(object_path));
206 } 206 }
207 207
208 // Called by NfcPropertySet when a property value is changed, either by 208 // Called by NfcPropertySet when a property value is changed, either by
209 // result of a signal or response to a GetAll() or Get() call. 209 // result of a signal or response to a GetAll() or Get() call.
210 void OnPropertyChanged(const dbus::ObjectPath& object_path, 210 void OnPropertyChanged(const dbus::ObjectPath& object_path,
211 const std::string& property_name) { 211 const std::string& property_name) {
212 VLOG(1) << "Tag property changed; Path: " << object_path.value() 212 VLOG(1) << "Tag property changed; Path: " << object_path.value()
213 << " Property: " << property_name; 213 << " Property: " << property_name;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 } 251 }
252 252
253 NfcTagClient::~NfcTagClient() { 253 NfcTagClient::~NfcTagClient() {
254 } 254 }
255 255
256 NfcTagClient* NfcTagClient::Create(NfcAdapterClient* adapter_client) { 256 NfcTagClient* NfcTagClient::Create(NfcAdapterClient* adapter_client) {
257 return new NfcTagClientImpl(adapter_client); 257 return new NfcTagClientImpl(adapter_client);
258 } 258 }
259 259
260 } // namespace chromeos 260 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/nfc_record_client.cc ('k') | chromeos/dbus/permission_broker_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698