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

Side by Side Diff: device/bluetooth/bluez/bluetooth_remote_gatt_service_bluez.cc

Issue 1979633004: Invoke GattDiscoveryCompleteForService by observing ServicesResolved property (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_attr
Patch Set: Created 4 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <iterator> 5 #include <iterator>
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "dbus/property.h" 8 #include "dbus/property.h"
9 #include "device/bluetooth/bluez/bluetooth_adapter_bluez.h" 9 #include "device/bluetooth/bluez/bluetooth_adapter_bluez.h"
10 #include "device/bluetooth/bluez/bluetooth_device_bluez.h" 10 #include "device/bluetooth/bluez/bluetooth_device_bluez.h"
11 #include "device/bluetooth/bluez/bluetooth_gatt_characteristic_bluez.h" 11 #include "device/bluetooth/bluez/bluetooth_gatt_characteristic_bluez.h"
12 #include "device/bluetooth/bluez/bluetooth_remote_gatt_characteristic_bluez.h" 12 #include "device/bluetooth/bluez/bluetooth_remote_gatt_characteristic_bluez.h"
13 #include "device/bluetooth/bluez/bluetooth_remote_gatt_descriptor_bluez.h" 13 #include "device/bluetooth/bluez/bluetooth_remote_gatt_descriptor_bluez.h"
14 #include "device/bluetooth/bluez/bluetooth_remote_gatt_service_bluez.h" 14 #include "device/bluetooth/bluez/bluetooth_remote_gatt_service_bluez.h"
15 #include "device/bluetooth/dbus/bluez_dbus_manager.h" 15 #include "device/bluetooth/dbus/bluez_dbus_manager.h"
16 16
17 namespace bluez { 17 namespace bluez {
18 18
19 BluetoothRemoteGattServiceBlueZ::BluetoothRemoteGattServiceBlueZ( 19 BluetoothRemoteGattServiceBlueZ::BluetoothRemoteGattServiceBlueZ(
20 BluetoothAdapterBlueZ* adapter, 20 BluetoothAdapterBlueZ* adapter,
21 BluetoothDeviceBlueZ* device, 21 BluetoothDeviceBlueZ* device,
22 const dbus::ObjectPath& object_path) 22 const dbus::ObjectPath& object_path)
23 : BluetoothGattServiceBlueZ(adapter, object_path), 23 : BluetoothGattServiceBlueZ(adapter, object_path),
24 device_(device), 24 device_(device),
25 discovery_complete_(false),
26 weak_ptr_factory_(this) { 25 weak_ptr_factory_(this) {
27 VLOG(1) << "Creating remote GATT service with identifier: " 26 VLOG(1) << "Creating remote GATT service with identifier: "
28 << object_path.value(); 27 << object_path.value();
29 DCHECK(GetAdapter()); 28 DCHECK(GetAdapter());
30 29
31 bluez::BluezDBusManager::Get()->GetBluetoothGattServiceClient()->AddObserver( 30 bluez::BluezDBusManager::Get()->GetBluetoothGattServiceClient()->AddObserver(
32 this); 31 this);
33 bluez::BluezDBusManager::Get() 32 bluez::BluezDBusManager::Get()
34 ->GetBluetoothGattCharacteristicClient() 33 ->GetBluetoothGattCharacteristicClient()
35 ->AddObserver(this); 34 ->AddObserver(this);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 characteristics_.find(dbus::ObjectPath(identifier)); 110 characteristics_.find(dbus::ObjectPath(identifier));
112 if (iter == characteristics_.end()) 111 if (iter == characteristics_.end())
113 return nullptr; 112 return nullptr;
114 return iter->second; 113 return iter->second;
115 } 114 }
116 115
117 void BluetoothRemoteGattServiceBlueZ::NotifyServiceChanged() { 116 void BluetoothRemoteGattServiceBlueZ::NotifyServiceChanged() {
118 // Don't send service changed unless we know that all characteristics have 117 // Don't send service changed unless we know that all characteristics have
119 // already been discovered. This is to prevent spammy events before sending 118 // already been discovered. This is to prevent spammy events before sending
120 // out the first Gatt 119 // out the first Gatt
121 if (!discovery_complete_) 120 if (!device_->IsGattServicesDiscoveryComplete())
122 return; 121 return;
123 122
124 DCHECK(GetAdapter()); 123 DCHECK(GetAdapter());
125 GetAdapter()->NotifyGattServiceChanged(this); 124 GetAdapter()->NotifyGattServiceChanged(this);
126 } 125 }
127 126
128 void BluetoothRemoteGattServiceBlueZ::NotifyDescriptorAddedOrRemoved( 127 void BluetoothRemoteGattServiceBlueZ::NotifyDescriptorAddedOrRemoved(
129 BluetoothRemoteGattCharacteristicBlueZ* characteristic, 128 BluetoothRemoteGattCharacteristicBlueZ* characteristic,
130 BluetoothRemoteGattDescriptorBlueZ* descriptor, 129 BluetoothRemoteGattDescriptorBlueZ* descriptor,
131 bool added) { 130 bool added) {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 DCHECK(GetAdapter()); 242 DCHECK(GetAdapter());
244 243
245 if (property_name == properties->flags.name()) 244 if (property_name == properties->flags.name())
246 NotifyServiceChanged(); 245 NotifyServiceChanged();
247 else if (property_name == properties->value.name()) 246 else if (property_name == properties->value.name())
248 GetAdapter()->NotifyGattCharacteristicValueChanged( 247 GetAdapter()->NotifyGattCharacteristicValueChanged(
249 iter->second, properties->value.value()); 248 iter->second, properties->value.value());
250 } 249 }
251 250
252 } // namespace bluez 251 } // namespace bluez
OLDNEW
« no previous file with comments | « device/bluetooth/bluez/bluetooth_remote_gatt_service_bluez.h ('k') | device/bluetooth/dbus/fake_bluetooth_device_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698