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

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

Issue 1898643002: Refactor device::BluetoothGattXXX classes to split into remote/local. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 <memory> 8 #include <memory>
9 #include <unordered_map> 9 #include <unordered_map>
10 10
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/sequenced_task_runner.h" 12 #include "base/sequenced_task_runner.h"
13 #include "device/bluetooth/bluetooth_gatt_characteristic.h"
14 #include "device/bluetooth/bluetooth_low_energy_defs_win.h" 13 #include "device/bluetooth/bluetooth_low_energy_defs_win.h"
14 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h"
15 15
16 namespace device { 16 namespace device {
17 17
18 class BluetoothAdapterWin; 18 class BluetoothAdapterWin;
19 class BluetoothRemoteGattDescriptorWin; 19 class BluetoothRemoteGattDescriptorWin;
20 class BluetoothRemoteGattServiceWin; 20 class BluetoothRemoteGattServiceWin;
21 class BluetoothTaskManagerWin; 21 class BluetoothTaskManagerWin;
22 22
23 // The BluetoothRemoteGattCharacteristicWin class implements 23 // The BluetoothRemoteGattCharacteristicWin class implements
24 // BluetoothGattCharacteristic for remote GATT services on Windows 8 and later. 24 // BluetoothRemoteGattCharacteristic for remote GATT services on Windows 8 and
25 // later.
25 class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattCharacteristicWin 26 class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattCharacteristicWin
26 : public BluetoothGattCharacteristic { 27 : public BluetoothRemoteGattCharacteristic {
27 public: 28 public:
28 BluetoothRemoteGattCharacteristicWin( 29 BluetoothRemoteGattCharacteristicWin(
29 BluetoothRemoteGattServiceWin* parent_service, 30 BluetoothRemoteGattServiceWin* parent_service,
30 BTH_LE_GATT_CHARACTERISTIC* characteristic_info, 31 BTH_LE_GATT_CHARACTERISTIC* characteristic_info,
31 scoped_refptr<base::SequencedTaskRunner>& ui_task_runner); 32 scoped_refptr<base::SequencedTaskRunner>& ui_task_runner);
32 ~BluetoothRemoteGattCharacteristicWin() override; 33 ~BluetoothRemoteGattCharacteristicWin() override;
33 34
34 // Override BluetoothGattCharacteristic interfaces. 35 // Override BluetoothRemoteGattCharacteristic interfaces.
35 std::string GetIdentifier() const override; 36 std::string GetIdentifier() const override;
36 BluetoothUUID GetUUID() const override; 37 BluetoothUUID GetUUID() const override;
37 bool IsLocal() const override; 38 bool IsLocal() const override;
38 std::vector<uint8_t>& GetValue() const override; 39 std::vector<uint8_t>& GetValue() const override;
39 BluetoothGattService* GetService() const override; 40 BluetoothRemoteGattService* GetService() const override;
40 Properties GetProperties() const override; 41 Properties GetProperties() const override;
41 Permissions GetPermissions() const override; 42 Permissions GetPermissions() const override;
42 bool IsNotifying() const override; 43 bool IsNotifying() const override;
43 std::vector<BluetoothGattDescriptor*> GetDescriptors() const override; 44 std::vector<BluetoothRemoteGattDescriptor*> GetDescriptors() const override;
44 BluetoothGattDescriptor* GetDescriptor( 45 BluetoothRemoteGattDescriptor* GetDescriptor(
45 const std::string& identifier) const override; 46 const std::string& identifier) const override;
46 bool AddDescriptor(BluetoothGattDescriptor* descriptor) override; 47 bool AddDescriptor(BluetoothRemoteGattDescriptor* descriptor) override;
47 bool UpdateValue(const std::vector<uint8_t>& value) override; 48 bool UpdateValue(const std::vector<uint8_t>& value) override;
48 void StartNotifySession(const NotifySessionCallback& callback, 49 void StartNotifySession(const NotifySessionCallback& callback,
49 const ErrorCallback& error_callback) override; 50 const ErrorCallback& error_callback) override;
50 void ReadRemoteCharacteristic(const ValueCallback& callback, 51 void ReadRemoteCharacteristic(const ValueCallback& callback,
51 const ErrorCallback& error_callback) override; 52 const ErrorCallback& error_callback) override;
52 void WriteRemoteCharacteristic(const std::vector<uint8_t>& new_value, 53 void WriteRemoteCharacteristic(const std::vector<uint8_t>& new_value,
53 const base::Closure& callback, 54 const base::Closure& callback,
54 const ErrorCallback& error_callback) override; 55 const ErrorCallback& error_callback) override;
55 56
56 // Update included descriptors. 57 // Update included descriptors.
(...skipping 16 matching lines...) Expand all
73 // Checks if |descriptor| still exists in this characteristic according to 74 // Checks if |descriptor| still exists in this characteristic according to
74 // newly discovered |num| of |descriptors|. 75 // newly discovered |num| of |descriptors|.
75 static bool DoesDescriptorExist(PBTH_LE_GATT_DESCRIPTOR descriptors, 76 static bool DoesDescriptorExist(PBTH_LE_GATT_DESCRIPTOR descriptors,
76 uint16_t num, 77 uint16_t num,
77 BluetoothRemoteGattDescriptorWin* descriptor); 78 BluetoothRemoteGattDescriptorWin* descriptor);
78 79
79 void OnReadRemoteCharacteristicValueCallback( 80 void OnReadRemoteCharacteristicValueCallback(
80 std::unique_ptr<BTH_LE_GATT_CHARACTERISTIC_VALUE> value, 81 std::unique_ptr<BTH_LE_GATT_CHARACTERISTIC_VALUE> value,
81 HRESULT hr); 82 HRESULT hr);
82 void OnWriteRemoteCharacteristicValueCallback(HRESULT hr); 83 void OnWriteRemoteCharacteristicValueCallback(HRESULT hr);
83 BluetoothGattService::GattErrorCode HRESULTToGattErrorCode(HRESULT hr); 84 BluetoothRemoteGattService::GattErrorCode HRESULTToGattErrorCode(HRESULT hr);
84 void OnGattCharacteristicValueChanged( 85 void OnGattCharacteristicValueChanged(
85 std::unique_ptr<std::vector<uint8_t>> new_value); 86 std::unique_ptr<std::vector<uint8_t>> new_value);
86 void GattEventRegistrationCallback(PVOID event_handle, HRESULT hr); 87 void GattEventRegistrationCallback(PVOID event_handle, HRESULT hr);
87 void ClearIncludedDescriptors(); 88 void ClearIncludedDescriptors();
88 89
89 BluetoothRemoteGattServiceWin* parent_service_; 90 BluetoothRemoteGattServiceWin* parent_service_;
90 scoped_refptr<BluetoothTaskManagerWin> task_manager_; 91 scoped_refptr<BluetoothTaskManagerWin> task_manager_;
91 92
92 // Characteristic info from OS and used to interact with OS. 93 // Characteristic info from OS and used to interact with OS.
93 std::unique_ptr<BTH_LE_GATT_CHARACTERISTIC> characteristic_info_; 94 std::unique_ptr<BTH_LE_GATT_CHARACTERISTIC> characteristic_info_;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 // GATT event handle returned by GattEventRegistrationCallback. 126 // GATT event handle returned by GattEventRegistrationCallback.
126 PVOID gatt_event_handle_; 127 PVOID gatt_event_handle_;
127 128
128 base::WeakPtrFactory<BluetoothRemoteGattCharacteristicWin> weak_ptr_factory_; 129 base::WeakPtrFactory<BluetoothRemoteGattCharacteristicWin> weak_ptr_factory_;
129 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicWin); 130 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicWin);
130 }; 131 };
131 132
132 } // namespace device 133 } // namespace device
133 134
134 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_WIN_H_ 135 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698