Index: device/bluetooth/bluetooth_remote_gatt_service_win.h |
diff --git a/device/bluetooth/bluetooth_remote_gatt_service_win.h b/device/bluetooth/bluetooth_remote_gatt_service_win.h |
index 218bc90a03e343170a443d6da69c4fead898846b..25bf5cadd91f16993f11470673c48615ad9c7fa8 100644 |
--- a/device/bluetooth/bluetooth_remote_gatt_service_win.h |
+++ b/device/bluetooth/bluetooth_remote_gatt_service_win.h |
@@ -5,12 +5,21 @@ |
#ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_WIN_H_ |
#define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_WIN_H_ |
+#include <set> |
+ |
#include "base/files/file.h" |
-#include "device/bluetooth/bluetooth_device_win.h" |
+#include "base/memory/weak_ptr.h" |
+#include "base/sequenced_task_runner.h" |
#include "device/bluetooth/bluetooth_gatt_service.h" |
+#include "device/bluetooth/bluetooth_low_energy_defs_win.h" |
namespace device { |
+class BluetoothAdapterWin; |
+class BluetoothDeviceWin; |
+class BluetoothRemoteGattCharacteristicWin; |
+class BluetoothTaskManagerWin; |
+ |
// The BluetoothRemoteGattServiceWin class implements BluetoothGattService |
// for remote GATT services on Windows 8 and later. |
class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattServiceWin |
@@ -43,11 +52,66 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattServiceWin |
void Unregister(const base::Closure& callback, |
const ErrorCallback& error_callback) override; |
+ // Notify |service| discovery complete, |service| is the included service of |
+ // this service. |
+ void GattServiceDiscoverComplete(BluetoothRemoteGattServiceWin* service); |
scheib
2016/02/25 06:22:44
Discovery
gogerald1
2016/02/25 23:19:18
Done.
|
+ |
+ // Notify |characteristic| discovery complete, |characteristic| is the |
+ // included characteritic of this service. |
+ void GattCharacteristicDiscoverComplete( |
scheib
2016/02/25 06:22:44
Discovery
gogerald1
2016/02/25 23:19:18
Done.
|
+ BluetoothRemoteGattCharacteristicWin* characteristic); |
+ |
// Update included services and characteristics. |
void Update(); |
- uint16_t GetAttributeHandle(); |
+ uint16_t GetAttributeHandle() const { return service_attribute_handle_; } |
+ BluetoothRemoteGattServiceWin* GetParentService() const { |
+ return parent_service_; |
+ } |
private: |
+ void GetIncludedCharacteristicsCallback( |
scheib
2016/02/25 06:22:44
OnGetIncludedCharacteristics. The previous name ca
gogerald1
2016/02/25 23:19:18
Done.
|
+ scoped_ptr<BTH_LE_GATT_CHARACTERISTIC> characteristics, |
+ uint16_t num, |
+ HRESULT hr); |
+ void GetIncludedServicesCallback(scoped_ptr<BTH_LE_GATT_SERVICE> services, |
scheib
2016/02/25 06:22:44
OnGetIncludedServices
gogerald1
2016/02/25 23:19:18
Done.
|
+ uint16_t num, |
+ HRESULT hr); |
+ void UpdateIncludedCharacteristics( |
+ PBTH_LE_GATT_CHARACTERISTIC characteristics, |
+ uint16_t num); |
+ void UpdateIncludedServices(PBTH_LE_GATT_SERVICE services, uint16_t num); |
+ |
+ // Sends GattDiscoveryCompleteForService notification if necessary. |
+ void NotifyServiceDiscComplIfNecessary(); |
scheib
2016/02/25 06:22:44
https://google.github.io/styleguide/cppguide.html#
gogerald1
2016/02/25 23:19:18
Done.
|
+ |
+ // Checks if the characteristic with |uuid| and |attribute_handle| has already |
+ // been discovered as included characteristic. |
+ bool IsCharacteristicDiscovered(BTH_LE_UUID& uuid, uint16_t attribute_handle); |
+ |
+ // Checks if |characteristic| is still exist in this service according to |
scheib
2016/02/25 06:22:44
"| still exists"
gogerald1
2016/02/25 23:19:18
Done.
gogerald1
2016/02/25 23:19:18
Done.
|
+ // newly retreived |num| of included |characteristics|. |
+ bool DoesCharacteristicExist( |
scheib
2016/02/25 06:22:44
static
gogerald1
2016/02/25 23:19:18
Done.
|
+ PBTH_LE_GATT_CHARACTERISTIC characteristics, |
+ uint16_t num, |
+ BluetoothRemoteGattCharacteristicWin* characteristic); |
+ |
+ void RemoveIncludedCharacteristic(std::string identifier); |
+ void ClearIncludedCharacteristics(); |
+ |
+ // Checks if the service with |uuid| and |attribute_handle| has already been |
+ // discovered as included service. |
+ bool IsServiceDiscovered(BluetoothUUID& uuid, uint16_t attribute_handle); |
+ |
+ // Checks if |service| is still exist in this service according to newly |
+ // retrieved |num| of included |services|. |
+ bool DoesServiceExist(PBTH_LE_GATT_SERVICE services, |
+ uint16_t num, |
+ BluetoothRemoteGattServiceWin* service); |
+ |
+ void RemoveIncludedService(std::string identifier); |
+ void ClearIncludedServices(); |
+ |
+ BluetoothAdapterWin* adapter_; |
BluetoothDeviceWin* device_; |
base::FilePath service_path_; |
BluetoothUUID service_uuid_; |
@@ -56,6 +120,44 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattServiceWin |
BluetoothRemoteGattServiceWin* parent_service_; |
scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; |
+ // BluetoothTaskManagerWin to handle asynchronously Bluetooth IO and platform |
+ // dependent operations. |
+ scoped_refptr<BluetoothTaskManagerWin> task_manager_; |
+ |
+ // The key of GattCharacteristicsMap is the identifier of |
+ // BluetoothRemoteGattCharacteristicWin instance. |
+ typedef std::unordered_map<std::string, |
+ scoped_ptr<BluetoothRemoteGattCharacteristicWin>> |
+ GattCharacteristicsMap; |
+ GattCharacteristicsMap included_characteristic_; |
scheib
2016/02/25 06:22:44
plural as it is a container, included_characterist
gogerald1
2016/02/25 23:19:18
Done.
|
+ |
+ // The element of the set is the identifier of |
+ // BluetoothRemoteGattCharacteristicWin instance. |
+ std::set<std::string> discovery_completed_included_charateristics_; |
+ |
+ // The key of GattServicesMap is the identifier of |
+ // BluetoothRemoteGattServiceWin instance. |
+ typedef std::unordered_map<std::string, |
+ scoped_ptr<BluetoothRemoteGattServiceWin>> |
+ GattServicesMap; |
+ GattServicesMap included_service_; |
scheib
2016/02/25 06:22:44
included_services_
gogerald1
2016/02/25 23:19:18
Done.
|
+ |
+ // The element of the set is the identifier of BluetoothRemoteGattServiceWin |
+ // instance. |
+ std::set<std::string> discovery_completed_included_services_; |
+ |
+ // Flag indicates if discovery complete notification has been send out to |
+ // avoid duplicate notification. |
+ bool discovery_complete_notified_; |
+ |
+ // Flag indicates if asynchronous discovery of included service has completed. |
+ bool included_services_discovered_; |
+ |
+ // Flag indicates if asynchronous discovery of included characteristic has |
+ // completed. |
+ bool included_characteristics_discovered_; |
+ |
+ base::WeakPtrFactory<BluetoothRemoteGattServiceWin> weak_ptr_factory_; |
DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattServiceWin); |
}; |