| OLD | NEW |
| 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_characteristic_chromeos.h" | 5 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 VLOG(1) << "Remote GATT characteristic descriptor already exists: " | 334 VLOG(1) << "Remote GATT characteristic descriptor already exists: " |
| 335 << object_path.value(); | 335 << object_path.value(); |
| 336 return; | 336 return; |
| 337 } | 337 } |
| 338 | 338 |
| 339 BluetoothGattDescriptorClient::Properties* properties = | 339 BluetoothGattDescriptorClient::Properties* properties = |
| 340 DBusThreadManager::Get()->GetBluetoothGattDescriptorClient()-> | 340 DBusThreadManager::Get()->GetBluetoothGattDescriptorClient()-> |
| 341 GetProperties(object_path); | 341 GetProperties(object_path); |
| 342 DCHECK(properties); | 342 DCHECK(properties); |
| 343 if (properties->characteristic.value() != object_path_) { | 343 if (properties->characteristic.value() != object_path_) { |
| 344 VLOG(2) << "Remote GATT descriptor does not belong to this characteristic."; | 344 VLOG(3) << "Remote GATT descriptor does not belong to this characteristic."; |
| 345 return; | 345 return; |
| 346 } | 346 } |
| 347 | 347 |
| 348 VLOG(1) << "Adding new remote GATT descriptor for GATT characteristic: " | 348 VLOG(1) << "Adding new remote GATT descriptor for GATT characteristic: " |
| 349 << GetIdentifier() << ", UUID: " << GetUUID().canonical_value(); | 349 << GetIdentifier() << ", UUID: " << GetUUID().canonical_value(); |
| 350 | 350 |
| 351 BluetoothRemoteGattDescriptorChromeOS* descriptor = | 351 BluetoothRemoteGattDescriptorChromeOS* descriptor = |
| 352 new BluetoothRemoteGattDescriptorChromeOS(this, object_path); | 352 new BluetoothRemoteGattDescriptorChromeOS(this, object_path); |
| 353 descriptors_[object_path] = descriptor; | 353 descriptors_[object_path] = descriptor; |
| 354 DCHECK(descriptor->GetIdentifier() == object_path.value()); | 354 DCHECK(descriptor->GetIdentifier() == object_path.value()); |
| 355 DCHECK(descriptor->GetUUID().IsValid()); | 355 DCHECK(descriptor->GetUUID().IsValid()); |
| 356 DCHECK(service_); | 356 DCHECK(service_); |
| 357 | 357 |
| 358 service_->NotifyDescriptorAddedOrRemoved(this, descriptor, true /* added */); | 358 service_->NotifyDescriptorAddedOrRemoved(this, descriptor, true /* added */); |
| 359 service_->NotifyServiceChanged(); | |
| 360 } | 359 } |
| 361 | 360 |
| 362 void BluetoothRemoteGattCharacteristicChromeOS::GattDescriptorRemoved( | 361 void BluetoothRemoteGattCharacteristicChromeOS::GattDescriptorRemoved( |
| 363 const dbus::ObjectPath& object_path) { | 362 const dbus::ObjectPath& object_path) { |
| 364 DescriptorMap::iterator iter = descriptors_.find(object_path); | 363 DescriptorMap::iterator iter = descriptors_.find(object_path); |
| 365 if (iter == descriptors_.end()) { | 364 if (iter == descriptors_.end()) { |
| 366 VLOG(2) << "Unknown descriptor removed: " << object_path.value(); | 365 VLOG(2) << "Unknown descriptor removed: " << object_path.value(); |
| 367 return; | 366 return; |
| 368 } | 367 } |
| 369 | 368 |
| 370 VLOG(1) << "Removing remote GATT descriptor from characteristic: " | 369 VLOG(1) << "Removing remote GATT descriptor from characteristic: " |
| 371 << GetIdentifier() << ", UUID: " << GetUUID().canonical_value(); | 370 << GetIdentifier() << ", UUID: " << GetUUID().canonical_value(); |
| 372 | 371 |
| 373 BluetoothRemoteGattDescriptorChromeOS* descriptor = iter->second; | 372 BluetoothRemoteGattDescriptorChromeOS* descriptor = iter->second; |
| 374 DCHECK(descriptor->object_path() == object_path); | 373 DCHECK(descriptor->object_path() == object_path); |
| 375 descriptors_.erase(iter); | 374 descriptors_.erase(iter); |
| 376 | 375 |
| 376 DCHECK(service_); |
| 377 service_->NotifyDescriptorAddedOrRemoved(this, descriptor, false /* added */); | 377 service_->NotifyDescriptorAddedOrRemoved(this, descriptor, false /* added */); |
| 378 |
| 378 delete descriptor; | 379 delete descriptor; |
| 379 | |
| 380 DCHECK(service_); | |
| 381 | |
| 382 service_->NotifyServiceChanged(); | |
| 383 } | 380 } |
| 384 | 381 |
| 385 void BluetoothRemoteGattCharacteristicChromeOS::OnValueSuccess( | 382 void BluetoothRemoteGattCharacteristicChromeOS::OnValueSuccess( |
| 386 const ValueCallback& callback, | 383 const ValueCallback& callback, |
| 387 const std::vector<uint8>& value) { | 384 const std::vector<uint8>& value) { |
| 388 VLOG(1) << "Characteristic value read: " << value; | 385 VLOG(1) << "Characteristic value read: " << value; |
| 389 cached_value_ = value; | 386 cached_value_ = value; |
| 390 | 387 |
| 391 DCHECK(service_); | 388 DCHECK(service_); |
| 392 service_->NotifyCharacteristicValueChanged(this, cached_value_); | 389 service_->NotifyCharacteristicValueChanged(this, cached_value_); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 | 467 |
| 471 void BluetoothRemoteGattCharacteristicChromeOS::ProcessStartNotifyQueue() { | 468 void BluetoothRemoteGattCharacteristicChromeOS::ProcessStartNotifyQueue() { |
| 472 while (!pending_start_notify_calls_.empty()) { | 469 while (!pending_start_notify_calls_.empty()) { |
| 473 PendingStartNotifyCall callbacks = pending_start_notify_calls_.front(); | 470 PendingStartNotifyCall callbacks = pending_start_notify_calls_.front(); |
| 474 pending_start_notify_calls_.pop(); | 471 pending_start_notify_calls_.pop(); |
| 475 StartNotifySession(callbacks.first, callbacks.second); | 472 StartNotifySession(callbacks.first, callbacks.second); |
| 476 } | 473 } |
| 477 } | 474 } |
| 478 | 475 |
| 479 } // namespace chromeos | 476 } // namespace chromeos |
| OLD | NEW |