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

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

Issue 1749403002: Implement BluetoothRemoteGattCharacteristicWin::StartNotifySession and related unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 9 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 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_WIN_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_WIN_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_WIN_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_WIN_H_
7 7
8 #include <unordered_map> 8 #include <unordered_map>
9 9
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 bool AddDescriptor(BluetoothGattDescriptor* descriptor) override; 45 bool AddDescriptor(BluetoothGattDescriptor* descriptor) override;
46 bool UpdateValue(const std::vector<uint8_t>& value) override; 46 bool UpdateValue(const std::vector<uint8_t>& value) override;
47 void StartNotifySession(const NotifySessionCallback& callback, 47 void StartNotifySession(const NotifySessionCallback& callback,
48 const ErrorCallback& error_callback) override; 48 const ErrorCallback& error_callback) override;
49 void ReadRemoteCharacteristic(const ValueCallback& callback, 49 void ReadRemoteCharacteristic(const ValueCallback& callback,
50 const ErrorCallback& error_callback) override; 50 const ErrorCallback& error_callback) override;
51 void WriteRemoteCharacteristic(const std::vector<uint8_t>& new_value, 51 void WriteRemoteCharacteristic(const std::vector<uint8_t>& new_value,
52 const base::Closure& callback, 52 const base::Closure& callback,
53 const ErrorCallback& error_callback) override; 53 const ErrorCallback& error_callback) override;
54 54
55 // Handles Bluetooth LE GATT event from OS.
56 void OnGetRemoteGattEvent(BTH_LE_GATT_EVENT_TYPE type, PVOID event_parameter);
57
55 // Update included descriptors. 58 // Update included descriptors.
56 void Update(); 59 void Update();
57 uint16_t GetAttributeHandle() const; 60 uint16_t GetAttributeHandle() const;
58 BluetoothRemoteGattServiceWin* GetWinService() { return parent_service_; } 61 BluetoothRemoteGattServiceWin* GetWinService() { return parent_service_; }
62 void StopNotifySession();
59 63
60 private: 64 private:
61 void OnGetIncludedDescriptorsCallback( 65 void OnGetIncludedDescriptorsCallback(
62 scoped_ptr<BTH_LE_GATT_DESCRIPTOR> descriptors, 66 scoped_ptr<BTH_LE_GATT_DESCRIPTOR> descriptors,
63 uint16_t num, 67 uint16_t num,
64 HRESULT hr); 68 HRESULT hr);
65 void UpdateIncludedDescriptors(PBTH_LE_GATT_DESCRIPTOR descriptors, 69 void UpdateIncludedDescriptors(PBTH_LE_GATT_DESCRIPTOR descriptors,
66 uint16_t num); 70 uint16_t num);
67 71
68 // Checks if the descriptor with |uuid| and |attribute_handle| has already 72 // Checks if the descriptor with |uuid| and |attribute_handle| has already
69 // been discovered as included descriptor. 73 // been discovered as included descriptor.
70 bool IsDescriptorDiscovered(BTH_LE_UUID& uuid, uint16_t attribute_handle); 74 bool IsDescriptorDiscovered(BTH_LE_UUID& uuid, uint16_t attribute_handle);
71 75
72 // Checks if |descriptor| still exists in this characteristic according to 76 // Checks if |descriptor| still exists in this characteristic according to
73 // newly discovered |num| of |descriptors|. 77 // newly discovered |num| of |descriptors|.
74 static bool DoesDescriptorExist(PBTH_LE_GATT_DESCRIPTOR descriptors, 78 static bool DoesDescriptorExist(PBTH_LE_GATT_DESCRIPTOR descriptors,
75 uint16_t num, 79 uint16_t num,
76 BluetoothRemoteGattDescriptorWin* descriptor); 80 BluetoothRemoteGattDescriptorWin* descriptor);
77 81
78 void OnReadRemoteCharacteristicValueCallback( 82 void OnReadRemoteCharacteristicValueCallback(
79 scoped_ptr<BTH_LE_GATT_CHARACTERISTIC_VALUE> value, 83 scoped_ptr<BTH_LE_GATT_CHARACTERISTIC_VALUE> value,
80 HRESULT hr); 84 HRESULT hr);
81 void OnWriteRemoteCharacteristicValueCallback(HRESULT hr); 85 void OnWriteRemoteCharacteristicValueCallback(HRESULT hr);
82 BluetoothGattService::GattErrorCode HRESULTToGattErrorCode(HRESULT hr); 86 BluetoothGattService::GattErrorCode HRESULTToGattErrorCode(HRESULT hr);
87 void OnGattCharacteristicValueChanged(
88 scoped_ptr<std::vector<uint8_t>> new_value);
89 void GattEventRegistrationCallback(BLUETOOTH_GATT_EVENT_HANDLE event_handle,
90 HRESULT hr);
83 91
84 BluetoothRemoteGattServiceWin* parent_service_; 92 BluetoothRemoteGattServiceWin* parent_service_;
85 scoped_refptr<BluetoothTaskManagerWin> task_manager_; 93 scoped_refptr<BluetoothTaskManagerWin> task_manager_;
86 94
87 // Characteristic info from OS and used to interact with OS. 95 // Characteristic info from OS and used to interact with OS.
88 scoped_ptr<BTH_LE_GATT_CHARACTERISTIC> characteristic_info_; 96 scoped_ptr<BTH_LE_GATT_CHARACTERISTIC> characteristic_info_;
89 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; 97 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_;
90 BluetoothUUID characteristic_uuid_; 98 BluetoothUUID characteristic_uuid_;
91 std::vector<uint8_t> characteristic_value_; 99 std::vector<uint8_t> characteristic_value_;
92 std::string characteristic_identifier_; 100 std::string characteristic_identifier_;
(...skipping 10 matching lines...) Expand all
103 bool characteristic_added_notified_; 111 bool characteristic_added_notified_;
104 112
105 // ReadRemoteCharacteristic request callbacks. 113 // ReadRemoteCharacteristic request callbacks.
106 std::pair<ValueCallback, ErrorCallback> read_characteristic_value_callbacks_; 114 std::pair<ValueCallback, ErrorCallback> read_characteristic_value_callbacks_;
107 115
108 // WriteRemoteCharacteristic request callbacks. 116 // WriteRemoteCharacteristic request callbacks.
109 std::pair<base::Closure, ErrorCallback> write_characteristic_value_callbacks_; 117 std::pair<base::Closure, ErrorCallback> write_characteristic_value_callbacks_;
110 118
111 bool characteristic_value_read_or_write_in_progress_; 119 bool characteristic_value_read_or_write_in_progress_;
112 120
121 unsigned int number_of_active_notify_sessions_;
122
123 // Vector stores StartNotifySession request callbacks.
124 std::vector<std::pair<NotifySessionCallback, ErrorCallback>>
125 start_notify_session_callbacks_;
126
127 // Flag indicates if GATT event registration is in progress.
128 bool gatt_event_registeration_in_progress_;
129
130 // GATT event handle from OS.
131 BLUETOOTH_GATT_EVENT_HANDLE gatt_event_handle_;
132
113 base::WeakPtrFactory<BluetoothRemoteGattCharacteristicWin> weak_ptr_factory_; 133 base::WeakPtrFactory<BluetoothRemoteGattCharacteristicWin> weak_ptr_factory_;
114 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicWin); 134 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicWin);
115 }; 135 };
116 136
117 } // namespace device 137 } // namespace device
118 138
119 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_WIN_H_ 139 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698