| 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/dbus/bluetooth_gatt_descriptor_client.h" | 5 #include "device/bluetooth/dbus/bluetooth_gatt_descriptor_client.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 object_proxy, interface_name, | 153 object_proxy, interface_name, |
| 154 base::Bind(&BluetoothGattDescriptorClientImpl::OnPropertyChanged, | 154 base::Bind(&BluetoothGattDescriptorClientImpl::OnPropertyChanged, |
| 155 weak_ptr_factory_.GetWeakPtr(), object_path)); | 155 weak_ptr_factory_.GetWeakPtr(), object_path)); |
| 156 return static_cast<dbus::PropertySet*>(properties); | 156 return static_cast<dbus::PropertySet*>(properties); |
| 157 } | 157 } |
| 158 | 158 |
| 159 // dbus::ObjectManager::Interface override. | 159 // dbus::ObjectManager::Interface override. |
| 160 void ObjectAdded(const dbus::ObjectPath& object_path, | 160 void ObjectAdded(const dbus::ObjectPath& object_path, |
| 161 const std::string& interface_name) override { | 161 const std::string& interface_name) override { |
| 162 VLOG(2) << "Remote GATT descriptor added: " << object_path.value(); | 162 VLOG(2) << "Remote GATT descriptor added: " << object_path.value(); |
| 163 FOR_EACH_OBSERVER(BluetoothGattDescriptorClient::Observer, observers_, | 163 for (auto& observer : observers_) |
| 164 GattDescriptorAdded(object_path)); | 164 observer.GattDescriptorAdded(object_path); |
| 165 } | 165 } |
| 166 | 166 |
| 167 // dbus::ObjectManager::Interface override. | 167 // dbus::ObjectManager::Interface override. |
| 168 void ObjectRemoved(const dbus::ObjectPath& object_path, | 168 void ObjectRemoved(const dbus::ObjectPath& object_path, |
| 169 const std::string& interface_name) override { | 169 const std::string& interface_name) override { |
| 170 VLOG(2) << "Remote GATT descriptor removed: " << object_path.value(); | 170 VLOG(2) << "Remote GATT descriptor removed: " << object_path.value(); |
| 171 FOR_EACH_OBSERVER(BluetoothGattDescriptorClient::Observer, observers_, | 171 for (auto& observer : observers_) |
| 172 GattDescriptorRemoved(object_path)); | 172 observer.GattDescriptorRemoved(object_path); |
| 173 } | 173 } |
| 174 | 174 |
| 175 protected: | 175 protected: |
| 176 // bluez::DBusClient override. | 176 // bluez::DBusClient override. |
| 177 void Init(dbus::Bus* bus) override { | 177 void Init(dbus::Bus* bus) override { |
| 178 object_manager_ = bus->GetObjectManager( | 178 object_manager_ = bus->GetObjectManager( |
| 179 bluetooth_object_manager::kBluetoothObjectManagerServiceName, | 179 bluetooth_object_manager::kBluetoothObjectManagerServiceName, |
| 180 dbus::ObjectPath( | 180 dbus::ObjectPath( |
| 181 bluetooth_object_manager::kBluetoothObjectManagerServicePath)); | 181 bluetooth_object_manager::kBluetoothObjectManagerServicePath)); |
| 182 object_manager_->RegisterInterface( | 182 object_manager_->RegisterInterface( |
| 183 bluetooth_gatt_descriptor::kBluetoothGattDescriptorInterface, this); | 183 bluetooth_gatt_descriptor::kBluetoothGattDescriptorInterface, this); |
| 184 } | 184 } |
| 185 | 185 |
| 186 private: | 186 private: |
| 187 // Called by dbus::PropertySet when a property value is changed, either by | 187 // Called by dbus::PropertySet when a property value is changed, either by |
| 188 // result of a signal or response to a GetAll() or Get() call. Informs | 188 // result of a signal or response to a GetAll() or Get() call. Informs |
| 189 // observers. | 189 // observers. |
| 190 virtual void OnPropertyChanged(const dbus::ObjectPath& object_path, | 190 virtual void OnPropertyChanged(const dbus::ObjectPath& object_path, |
| 191 const std::string& property_name) { | 191 const std::string& property_name) { |
| 192 VLOG(2) << "Remote GATT descriptor property changed: " | 192 VLOG(2) << "Remote GATT descriptor property changed: " |
| 193 << object_path.value() << ": " << property_name; | 193 << object_path.value() << ": " << property_name; |
| 194 FOR_EACH_OBSERVER( | 194 for (auto& observer : observers_) |
| 195 BluetoothGattDescriptorClient::Observer, observers_, | 195 observer.GattDescriptorPropertyChanged(object_path, property_name); |
| 196 GattDescriptorPropertyChanged(object_path, property_name)); | |
| 197 } | 196 } |
| 198 | 197 |
| 199 // Called when a response for a successful method call is received. | 198 // Called when a response for a successful method call is received. |
| 200 void OnSuccess(const base::Closure& callback, dbus::Response* response) { | 199 void OnSuccess(const base::Closure& callback, dbus::Response* response) { |
| 201 DCHECK(response); | 200 DCHECK(response); |
| 202 callback.Run(); | 201 callback.Run(); |
| 203 } | 202 } |
| 204 | 203 |
| 205 // Called when a descriptor value response for a successful method call is | 204 // Called when a descriptor value response for a successful method call is |
| 206 // received. | 205 // received. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 BluetoothGattDescriptorClient::BluetoothGattDescriptorClient() {} | 255 BluetoothGattDescriptorClient::BluetoothGattDescriptorClient() {} |
| 257 | 256 |
| 258 BluetoothGattDescriptorClient::~BluetoothGattDescriptorClient() {} | 257 BluetoothGattDescriptorClient::~BluetoothGattDescriptorClient() {} |
| 259 | 258 |
| 260 // static | 259 // static |
| 261 BluetoothGattDescriptorClient* BluetoothGattDescriptorClient::Create() { | 260 BluetoothGattDescriptorClient* BluetoothGattDescriptorClient::Create() { |
| 262 return new BluetoothGattDescriptorClientImpl(); | 261 return new BluetoothGattDescriptorClientImpl(); |
| 263 } | 262 } |
| 264 | 263 |
| 265 } // namespace bluez | 264 } // namespace bluez |
| OLD | NEW |