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

Side by Side Diff: device/bluetooth/bluetooth_remote_gatt_service_chromeos.cc

Issue 788193004: chromeos/dbus: Update Bluetooth GATT API clients to upstream definition (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase & tbr Created 5 years, 10 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 | « device/bluetooth/bluetooth_remote_gatt_service_chromeos.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "device/bluetooth/bluetooth_remote_gatt_service_chromeos.h" 5 #include "device/bluetooth/bluetooth_remote_gatt_service_chromeos.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "chromeos/dbus/bluetooth_gatt_service_client.h" 9 #include "chromeos/dbus/bluetooth_gatt_service_client.h"
10 #include "chromeos/dbus/dbus_thread_manager.h" 10 #include "chromeos/dbus/dbus_thread_manager.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // Don't send service changed unless we know that all characteristics have 188 // Don't send service changed unless we know that all characteristics have
189 // already been discovered. This is to prevent spammy events before sending 189 // already been discovered. This is to prevent spammy events before sending
190 // out the first Gatt 190 // out the first Gatt
191 if (!discovery_complete_) 191 if (!discovery_complete_)
192 return; 192 return;
193 193
194 DCHECK(adapter_); 194 DCHECK(adapter_);
195 adapter_->NotifyGattServiceChanged(this); 195 adapter_->NotifyGattServiceChanged(this);
196 } 196 }
197 197
198 void BluetoothRemoteGattServiceChromeOS::NotifyCharacteristicValueChanged(
199 BluetoothRemoteGattCharacteristicChromeOS* characteristic,
200 const std::vector<uint8>& value) {
201 DCHECK(characteristic->GetService() == this);
202 DCHECK(adapter_);
203 adapter_->NotifyGattCharacteristicValueChanged(characteristic, value);
204 }
205
206 void BluetoothRemoteGattServiceChromeOS::NotifyDescriptorAddedOrRemoved( 198 void BluetoothRemoteGattServiceChromeOS::NotifyDescriptorAddedOrRemoved(
207 BluetoothRemoteGattCharacteristicChromeOS* characteristic, 199 BluetoothRemoteGattCharacteristicChromeOS* characteristic,
208 BluetoothRemoteGattDescriptorChromeOS* descriptor, 200 BluetoothRemoteGattDescriptorChromeOS* descriptor,
209 bool added) { 201 bool added) {
210 DCHECK(characteristic->GetService() == this); 202 DCHECK(characteristic->GetService() == this);
211 DCHECK(descriptor->GetCharacteristic() == characteristic); 203 DCHECK(descriptor->GetCharacteristic() == characteristic);
212 DCHECK(adapter_); 204 DCHECK(adapter_);
213 205
214 if (added) { 206 if (added) {
215 adapter_->NotifyGattDescriptorAdded(descriptor); 207 adapter_->NotifyGattDescriptorAdded(descriptor);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 296
305 DCHECK(adapter_); 297 DCHECK(adapter_);
306 adapter_->NotifyGattCharacteristicRemoved(characteristic); 298 adapter_->NotifyGattCharacteristicRemoved(characteristic);
307 299
308 delete characteristic; 300 delete characteristic;
309 } 301 }
310 302
311 void BluetoothRemoteGattServiceChromeOS::GattCharacteristicPropertyChanged( 303 void BluetoothRemoteGattServiceChromeOS::GattCharacteristicPropertyChanged(
312 const dbus::ObjectPath& object_path, 304 const dbus::ObjectPath& object_path,
313 const std::string& property_name) { 305 const std::string& property_name) {
314 if (characteristics_.find(object_path) == characteristics_.end()) { 306 CharacteristicMap::iterator iter = characteristics_.find(object_path);
307 if (iter == characteristics_.end()) {
315 VLOG(3) << "Properties of unknown characteristic changed"; 308 VLOG(3) << "Properties of unknown characteristic changed";
316 return; 309 return;
317 } 310 }
318 311
319 // We may receive a property changed event in certain cases, e.g. when the 312 // We may receive a property changed event in certain cases, e.g. when the
320 // characteristic "Flags" property has been updated with values from the 313 // characteristic "Flags" property has been updated with values from the
321 // "Characteristic Extended Properties" descriptor. In this case, kick off 314 // "Characteristic Extended Properties" descriptor. In this case, kick off
322 // a service changed observer event to let observers refresh the 315 // a service changed observer event to let observers refresh the
323 // characteristics. 316 // characteristics.
324 BluetoothGattCharacteristicClient::Properties* properties = 317 BluetoothGattCharacteristicClient::Properties* properties =
325 DBusThreadManager::Get()->GetBluetoothGattCharacteristicClient()-> 318 DBusThreadManager::Get()->GetBluetoothGattCharacteristicClient()->
326 GetProperties(object_path); 319 GetProperties(object_path);
320
327 DCHECK(properties); 321 DCHECK(properties);
328 if (property_name != properties->flags.name()) 322 DCHECK(adapter_);
329 return;
330 323
331 NotifyServiceChanged(); 324 if (property_name == properties->flags.name())
325 NotifyServiceChanged();
326 else if (property_name == properties->value.name())
327 adapter_->NotifyGattCharacteristicValueChanged(iter->second,
328 properties->value.value());
332 } 329 }
333 330
334 } // namespace chromeos 331 } // namespace chromeos
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_remote_gatt_service_chromeos.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698