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

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

Issue 264053004: device/bluetooth: Improvements to GATT descriptor access API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pull & rebase. Created 6 years, 7 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 | Annotate | Revision Log
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"
11 #include "device/bluetooth/bluetooth_device_chromeos.h" 11 #include "device/bluetooth/bluetooth_device_chromeos.h"
12 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.h" 12 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.h"
13 #include "device/bluetooth/bluetooth_remote_gatt_descriptor_chromeos.h"
13 14
14 namespace chromeos { 15 namespace chromeos {
15 16
16 namespace { 17 namespace {
17 18
18 // Stream operator for logging vector<uint8>. 19 // Stream operator for logging vector<uint8>.
19 std::ostream& operator<<(std::ostream& out, const std::vector<uint8> bytes) { 20 std::ostream& operator<<(std::ostream& out, const std::vector<uint8> bytes) {
20 out << "["; 21 out << "[";
21 for (std::vector<uint8>::const_iterator iter = bytes.begin(); 22 for (std::vector<uint8>::const_iterator iter = bytes.begin();
22 iter != bytes.end(); ++iter) { 23 iter != bytes.end(); ++iter) {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 const ErrorCallback& error_callback) { 158 const ErrorCallback& error_callback) {
158 VLOG(1) << "A remote GATT service cannot be unregistered."; 159 VLOG(1) << "A remote GATT service cannot be unregistered.";
159 error_callback.Run(); 160 error_callback.Run();
160 } 161 }
161 162
162 void BluetoothRemoteGattServiceChromeOS::NotifyServiceChanged() { 163 void BluetoothRemoteGattServiceChromeOS::NotifyServiceChanged() {
163 FOR_EACH_OBSERVER(device::BluetoothGattService::Observer, observers_, 164 FOR_EACH_OBSERVER(device::BluetoothGattService::Observer, observers_,
164 GattServiceChanged(this)); 165 GattServiceChanged(this));
165 } 166 }
166 167
168 void BluetoothRemoteGattServiceChromeOS::NotifyDescriptorAddedOrRemoved(
169 BluetoothRemoteGattCharacteristicChromeOS* characteristic,
170 BluetoothRemoteGattDescriptorChromeOS* descriptor,
171 bool added) {
172 DCHECK(characteristic->GetService() == this);
173 DCHECK(descriptor->GetCharacteristic() == characteristic);
174 if (added) {
175 FOR_EACH_OBSERVER(device::BluetoothGattService::Observer, observers_,
176 GattDescriptorAdded(characteristic, descriptor));
177 return;
178 }
179 FOR_EACH_OBSERVER(device::BluetoothGattService::Observer, observers_,
180 GattDescriptorRemoved(characteristic, descriptor));
181 }
182
183 void BluetoothRemoteGattServiceChromeOS::NotifyDescriptorValueChanged(
184 BluetoothRemoteGattCharacteristicChromeOS* characteristic,
185 BluetoothRemoteGattDescriptorChromeOS* descriptor,
186 const std::vector<uint8>& value) {
187 DCHECK(characteristic->GetService() == this);
188 DCHECK(descriptor->GetCharacteristic() == characteristic);
189 FOR_EACH_OBSERVER(
190 device::BluetoothGattService::Observer, observers_,
191 GattDescriptorValueChanged(characteristic, descriptor, value));
192 }
193
167 void BluetoothRemoteGattServiceChromeOS::GattServicePropertyChanged( 194 void BluetoothRemoteGattServiceChromeOS::GattServicePropertyChanged(
168 const dbus::ObjectPath& object_path, 195 const dbus::ObjectPath& object_path,
169 const std::string& property_name){ 196 const std::string& property_name){
170 NotifyServiceChanged(); 197 NotifyServiceChanged();
171 } 198 }
172 199
173 void BluetoothRemoteGattServiceChromeOS::GattCharacteristicAdded( 200 void BluetoothRemoteGattServiceChromeOS::GattCharacteristicAdded(
174 const dbus::ObjectPath& object_path) { 201 const dbus::ObjectPath& object_path) {
175 if (characteristics_.find(object_path) != characteristics_.end()) { 202 if (characteristics_.find(object_path) != characteristics_.end()) {
176 VLOG(1) << "Remote GATT characteristic already exists: " 203 VLOG(1) << "Remote GATT characteristic already exists: "
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 return; 269 return;
243 270
244 VLOG(1) << "GATT characteristic value has changed: " << object_path.value() 271 VLOG(1) << "GATT characteristic value has changed: " << object_path.value()
245 << ": " << properties->value.value(); 272 << ": " << properties->value.value();
246 FOR_EACH_OBSERVER(device::BluetoothGattService::Observer, observers_, 273 FOR_EACH_OBSERVER(device::BluetoothGattService::Observer, observers_,
247 GattCharacteristicValueChanged(this, iter->second, 274 GattCharacteristicValueChanged(this, iter->second,
248 properties->value.value())); 275 properties->value.value()));
249 } 276 }
250 277
251 } // namespace chromeos 278 } // namespace chromeos
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_remote_gatt_service_chromeos.h ('k') | device/bluetooth/test/mock_bluetooth_gatt_characteristic.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698