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

Side by Side Diff: device/bluetooth/bluetooth_remote_gatt_service_win.h

Issue 1606013002: BLE GATT service implementation in Chrome for Windows 8 and later (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update Build.gn Created 4 years, 11 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_WIN_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_WIN_H_
7
8 #include "base/macros.h"
9 #include "base/files/file.h"
10 #include "device/bluetooth/bluetooth_adapter_win.h"
11 #include "device/bluetooth/bluetooth_device_win.h"
12 #include "device/bluetooth/bluetooth_gatt_service.h"
13 #include "device/bluetooth/bluetooth_low_energy_defs_win.h"
14 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_win.h"
15 #include "device/bluetooth/bluetooth_task_manager_win.h"
16
17 namespace device {
18
19 // The BluetoothRemoteGattServiceWin class implements BluetoothGattService
20 // for remote GATT services on Windows 8 and later.
21 class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattServiceWin
22 : public BluetoothGattService {
23 public:
24 BluetoothRemoteGattServiceWin(
25 BluetoothDeviceWin* device,
26 base::FilePath service_path,
27 BluetoothUUID service_uuid,
28 uint16_t service_attribute_handle,
29 bool is_primary,
30 BluetoothRemoteGattServiceWin* parent_service,
31 scoped_refptr<base::SequencedTaskRunner>& ui_task_runner);
32 ~BluetoothRemoteGattServiceWin() override;
33
34 // Override BluetoothGattService interfaces.
35 std::string GetIdentifier() const override;
36 BluetoothUUID GetUUID() const override;
37 bool IsLocal() const override;
38 bool IsPrimary() const override;
39 BluetoothDevice* GetDevice() const override;
40 std::vector<BluetoothGattCharacteristic*> GetCharacteristics() const override;
41 std::vector<BluetoothGattService*> GetIncludedServices() const override;
42 BluetoothGattCharacteristic* GetCharacteristic(
43 const std::string& identifier) const override;
44 bool AddCharacteristic(BluetoothGattCharacteristic* characteristic) override;
45 bool AddIncludedService(BluetoothGattService* service) override;
46 void Register(const base::Closure& callback,
47 const ErrorCallback& error_callback) override;
48 void Unregister(const base::Closure& callback,
49 const ErrorCallback& error_callback) override;
50
51 // Called by included services to notify it is ready.
52 void NotifyGattServiceAdded(BluetoothRemoteGattServiceWin* service);
53 // Called by included characteristic to notify it is ready.
54 void NotifyGattCharacteristicAdded(
55 BluetoothRemoteGattCharacteristicWin* characteristic);
56
57 // Update included services and characteristics.
58 void Update();
59
60 BluetoothAdapterWin* GetAdapter() { return adapter_; }
61 base::FilePath GetServicePath() { return service_path_; }
62
63 private:
64 friend class BluetoothRemoteGattServiceWinTest;
65
66 void GetIncludedCharacteristicsCallback(
67 PBTH_LE_GATT_CHARACTERISTIC characteristics,
68 uint16_t num,
69 HRESULT hr);
70 void GetIncludedServicesCallback(PBTH_LE_GATT_SERVICE services,
71 uint16_t num,
72 HRESULT hr);
73 void UpdateIncludedCharacteristics(
74 PBTH_LE_GATT_CHARACTERISTIC characteristics,
75 uint16_t num);
76 void UpdateIncludedServices(PBTH_LE_GATT_SERVICE services, uint16_t num);
77 void NotifyServiceDiscComplIfNecessary();
78
79 BluetoothAdapterWin* adapter_;
80 BluetoothDeviceWin* device_;
81 base::FilePath service_path_;
82 BluetoothUUID service_uuid_;
83 uint16_t service_attribute_handle_;
84 bool is_primary_;
85 BluetoothRemoteGattServiceWin* parent_service_;
86
87 scoped_refptr<BluetoothTaskManagerWin> task_manager_;
88
89 // Flag to indicate service added notification has been send out.
90 bool complete_notified_;
91
92 std::set<std::string> discovery_completed_included_charateristics_;
93 std::set<std::string> discovery_completed_included_services_;
94 bool included_services_discovered_;
95 bool included_characteristics_discovered_;
96
97 typedef base::ScopedPtrHashMap<
98 std::string,
99 scoped_ptr<BluetoothRemoteGattCharacteristicWin>> GattCharacteristicsMap;
100 GattCharacteristicsMap included_characteristic_objects_;
101
102 typedef base::ScopedPtrHashMap<std::string,
103 scoped_ptr<BluetoothRemoteGattServiceWin>>
104 GattServicesMap;
105 GattServicesMap included_service_objects_;
106
107 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_;
108
109 base::WeakPtrFactory<BluetoothRemoteGattServiceWin> weak_ptr_factory_;
110 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattServiceWin);
111 };
112
113 } // namespace device.
114 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698