OLD | NEW |
(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_DESCRIPTOR_WIN_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_WIN_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "device/bluetooth/bluetooth_adapter_win.h" |
| 10 #include "device/bluetooth/bluetooth_device_win.h" |
| 11 #include "device/bluetooth/bluetooth_gatt_descriptor.h" |
| 12 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_win.h" |
| 13 #include "device/bluetooth/bluetooth_task_manager_win.h" |
| 14 |
| 15 namespace device { |
| 16 |
| 17 // The BluetoothRemoteGattDescriptorWin class implements BluetoothGattDescriptor |
| 18 // for remote GATT services on Windows 8 and later. |
| 19 class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattDescriptorWin |
| 20 : public BluetoothGattDescriptor { |
| 21 public: |
| 22 BluetoothRemoteGattDescriptorWin( |
| 23 BluetoothAdapterWin* adapter, |
| 24 base::FilePath service_path, |
| 25 BluetoothRemoteGattCharacteristicWin* parent_characteristic, |
| 26 BTH_LE_GATT_DESCRIPTOR* descriptor_info, |
| 27 scoped_refptr<base::SequencedTaskRunner>& ui_task_runner); |
| 28 ~BluetoothRemoteGattDescriptorWin(); |
| 29 |
| 30 // Override BluetoothGattDescriptor interfaces. |
| 31 std::string GetIdentifier() const override; |
| 32 BluetoothUUID GetUUID() const override; |
| 33 bool IsLocal() const override; |
| 34 std::vector<uint8_t>& GetValue() const override; |
| 35 BluetoothGattCharacteristic* GetCharacteristic() const override; |
| 36 BluetoothGattCharacteristic::Permissions GetPermissions() const override; |
| 37 void ReadRemoteDescriptor(const ValueCallback& callback, |
| 38 const ErrorCallback& error_callback) override; |
| 39 void WriteRemoteDescriptor(const std::vector<uint8_t>& new_value, |
| 40 const base::Closure& callback, |
| 41 const ErrorCallback& error_callback) override; |
| 42 |
| 43 void Update(); |
| 44 |
| 45 private: |
| 46 void ReadRemoteDescriptorValueCallback(BTH_LE_GATT_DESCRIPTOR_VALUE* value, |
| 47 HRESULT hr); |
| 48 void WriteRemoteDescriptorValueCallback(HRESULT hr); |
| 49 BluetoothGattService::GattErrorCode SystemErrorToGattErrorCode(HRESULT hr); |
| 50 |
| 51 BluetoothAdapterWin* adapter_; |
| 52 base::FilePath service_path_; |
| 53 scoped_refptr<BluetoothTaskManagerWin> task_manager_; |
| 54 |
| 55 BluetoothRemoteGattCharacteristicWin* parent_characteristic_; |
| 56 scoped_ptr<BTH_LE_GATT_DESCRIPTOR> descriptor_info_; |
| 57 BluetoothGattCharacteristic::Permissions permissions_; |
| 58 |
| 59 BluetoothUUID descriptor_uuid_; |
| 60 bool descriptor_initialized_; |
| 61 std::vector<uint8_t> descriptor_value_; |
| 62 |
| 63 std::vector<std::pair<ValueCallback, ErrorCallback>> |
| 64 read_remote_descriptor_value_callbacks_; |
| 65 std::vector<std::pair<base::Closure, ErrorCallback>> |
| 66 write_remote_descriptor_value_callbacks_; |
| 67 |
| 68 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; |
| 69 |
| 70 base::WeakPtrFactory<BluetoothRemoteGattDescriptorWin> weak_ptr_factory_; |
| 71 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattDescriptorWin); |
| 72 }; |
| 73 |
| 74 } // namespace device. |
| 75 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_WIN_H_ |
OLD | NEW |