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

Unified Diff: device/bluetooth/bluetooth_remote_gatt_service_chromeos.cc

Issue 418483003: device/bluetooth: Move GATT observer methods to BluetoothAdapter::Observer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/bluetooth_remote_gatt_service_chromeos.cc
diff --git a/device/bluetooth/bluetooth_remote_gatt_service_chromeos.cc b/device/bluetooth/bluetooth_remote_gatt_service_chromeos.cc
index f7e99b6ab4fcea5b163cacc0169e10dfa9798d4b..b92124229e0124e29133dcc8acbab2f9dc2541c8 100644
--- a/device/bluetooth/bluetooth_remote_gatt_service_chromeos.cc
+++ b/device/bluetooth/bluetooth_remote_gatt_service_chromeos.cc
@@ -54,24 +54,13 @@ BluetoothRemoteGattServiceChromeOS::~BluetoothRemoteGattServiceChromeOS() {
characteristics_.clear();
for (CharacteristicMap::iterator iter = characteristics.begin();
iter != characteristics.end(); ++iter) {
- FOR_EACH_OBSERVER(device::BluetoothGattService::Observer, observers_,
- GattCharacteristicRemoved(this, iter->second));
+ DCHECK(adapter_);
+ adapter_->NotifyGattCharacteristicRemoved(iter->second);
+
delete iter->second;
}
}
-void BluetoothRemoteGattServiceChromeOS::AddObserver(
- device::BluetoothGattService::Observer* observer) {
- DCHECK(observer);
- observers_.AddObserver(observer);
-}
-
-void BluetoothRemoteGattServiceChromeOS::RemoveObserver(
- device::BluetoothGattService::Observer* observer) {
- DCHECK(observer);
- observers_.RemoveObserver(observer);
-}
-
std::string BluetoothRemoteGattServiceChromeOS::GetIdentifier() const {
return object_path_.value();
}
@@ -152,7 +141,7 @@ void BluetoothRemoteGattServiceChromeOS::Unregister(
error_callback.Run();
}
-scoped_refptr<device::BluetoothAdapter>
+BluetoothAdapterChromeOS*
BluetoothRemoteGattServiceChromeOS::GetAdapter() const {
return adapter_;
}
@@ -164,18 +153,16 @@ void BluetoothRemoteGattServiceChromeOS::NotifyServiceChanged() {
if (!discovery_complete_)
return;
- FOR_EACH_OBSERVER(device::BluetoothGattService::Observer, observers_,
- GattServiceChanged(this));
+ DCHECK(adapter_);
+ adapter_->NotifyGattServiceChanged(this);
}
void BluetoothRemoteGattServiceChromeOS::NotifyCharacteristicValueChanged(
BluetoothRemoteGattCharacteristicChromeOS* characteristic,
const std::vector<uint8>& value) {
DCHECK(characteristic->GetService() == this);
- FOR_EACH_OBSERVER(
- device::BluetoothGattService::Observer,
- observers_,
- GattCharacteristicValueChanged(this, characteristic, value));
+ DCHECK(adapter_);
+ adapter_->NotifyGattCharacteristicValueChanged(characteristic, value);
}
void BluetoothRemoteGattServiceChromeOS::NotifyDescriptorAddedOrRemoved(
@@ -184,13 +171,14 @@ void BluetoothRemoteGattServiceChromeOS::NotifyDescriptorAddedOrRemoved(
bool added) {
DCHECK(characteristic->GetService() == this);
DCHECK(descriptor->GetCharacteristic() == characteristic);
+ DCHECK(adapter_);
+
if (added) {
- FOR_EACH_OBSERVER(device::BluetoothGattService::Observer, observers_,
- GattDescriptorAdded(characteristic, descriptor));
+ adapter_->NotifyGattDescriptorAdded(descriptor);
return;
}
- FOR_EACH_OBSERVER(device::BluetoothGattService::Observer, observers_,
- GattDescriptorRemoved(characteristic, descriptor));
+
+ adapter_->NotifyGattDescriptorRemoved(descriptor);
}
void BluetoothRemoteGattServiceChromeOS::NotifyDescriptorValueChanged(
@@ -199,9 +187,8 @@ void BluetoothRemoteGattServiceChromeOS::NotifyDescriptorValueChanged(
const std::vector<uint8>& value) {
DCHECK(characteristic->GetService() == this);
DCHECK(descriptor->GetCharacteristic() == characteristic);
- FOR_EACH_OBSERVER(
- device::BluetoothGattService::Observer, observers_,
- GattDescriptorValueChanged(characteristic, descriptor, value));
+ DCHECK(adapter_);
+ adapter_->NotifyGattDescriptorValueChanged(descriptor, value);
}
void BluetoothRemoteGattServiceChromeOS::GattServicePropertyChanged(
@@ -228,9 +215,8 @@ void BluetoothRemoteGattServiceChromeOS::GattServicePropertyChanged(
VLOG(1) << "All characteristics were discovered for service: "
<< object_path.value();
discovery_complete_ = true;
- FOR_EACH_OBSERVER(device::BluetoothGattService::Observer,
- observers_,
- GattDiscoveryCompleteForService(this));
+ DCHECK(adapter_);
+ adapter_->NotifyGattDiscoveryComplete(this);
}
void BluetoothRemoteGattServiceChromeOS::GattCharacteristicAdded(
@@ -259,8 +245,8 @@ void BluetoothRemoteGattServiceChromeOS::GattCharacteristicAdded(
DCHECK(characteristic->GetIdentifier() == object_path.value());
DCHECK(characteristic->GetUUID().IsValid());
- FOR_EACH_OBSERVER(device::BluetoothGattService::Observer, observers_,
- GattCharacteristicAdded(this, characteristic));
+ DCHECK(adapter_);
+ adapter_->NotifyGattCharacteristicAdded(characteristic);
}
void BluetoothRemoteGattServiceChromeOS::GattCharacteristicRemoved(
@@ -278,8 +264,8 @@ void BluetoothRemoteGattServiceChromeOS::GattCharacteristicRemoved(
DCHECK(characteristic->object_path() == object_path);
characteristics_.erase(iter);
- FOR_EACH_OBSERVER(device::BluetoothGattService::Observer, observers_,
- GattCharacteristicRemoved(this, characteristic));
+ DCHECK(adapter_);
+ adapter_->NotifyGattCharacteristicRemoved(characteristic);
delete characteristic;
}
« no previous file with comments | « device/bluetooth/bluetooth_remote_gatt_service_chromeos.h ('k') | device/bluetooth/test/mock_bluetooth_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698