summaryrefslogtreecommitdiffstats
path: root/device/bluetooth/bluetooth_remote_gatt_descriptor_win.h
blob: cb6642b6a6a5a83aff738803bd01a2a6d1bfa2ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_WIN_H_
#define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_WIN_H_

#include "base/files/file_path.h"
#include "base/memory/weak_ptr.h"
#include "device/bluetooth/bluetooth_gatt_descriptor.h"
#include "device/bluetooth/bluetooth_low_energy_defs_win.h"

namespace device {

class BluetoothAdapterWin;
class BluetoothRemoteGattCharacteristicWin;
class BluetoothTaskManagerWin;

class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattDescriptorWin
    : public BluetoothGattDescriptor {
 public:
  BluetoothRemoteGattDescriptorWin(
      BluetoothRemoteGattCharacteristicWin* parent_characteristic,
      BTH_LE_GATT_DESCRIPTOR* descriptor_info,
      scoped_refptr<base::SequencedTaskRunner>& ui_task_runner);
  ~BluetoothRemoteGattDescriptorWin() override;

  // Override BluetoothGattDescriptor interfaces.
  std::string GetIdentifier() const override;
  BluetoothUUID GetUUID() const override;
  bool IsLocal() const override;
  std::vector<uint8_t>& GetValue() const override;
  BluetoothGattCharacteristic* GetCharacteristic() const override;
  BluetoothGattCharacteristic::Permissions GetPermissions() const override;
  void ReadRemoteDescriptor(const ValueCallback& callback,
                            const ErrorCallback& error_callback) override;
  void WriteRemoteDescriptor(const std::vector<uint8_t>& new_value,
                             const base::Closure& callback,
                             const ErrorCallback& error_callback) override;

  uint16_t GetAttributeHandle() const;

 private:
  BluetoothRemoteGattCharacteristicWin* parent_characteristic_;
  scoped_ptr<BTH_LE_GATT_DESCRIPTOR> descriptor_info_;
  scoped_refptr<base::SequencedTaskRunner> ui_task_runner_;

  base::FilePath service_path_;
  scoped_refptr<BluetoothTaskManagerWin> task_manager_;
  BluetoothGattCharacteristic::Permissions descriptor_permissions_;
  BluetoothUUID descriptor_uuid_;
  std::string descriptor_identifier_;
  std::vector<uint8_t> descriptor_value_;

  base::WeakPtrFactory<BluetoothRemoteGattDescriptorWin> weak_ptr_factory_;
  DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattDescriptorWin);
};

}  // namespace device.
#endif  // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_WIN_H_