Respect --profile-directory flag when used with --show-app-list flag.
[chromium-blink-merge.git] / device / bluetooth / bluetooth_low_energy_win.h
blobffcb4de46993afc4bccaded4cd52d6aba874bf1e
1 // Copyright 2014 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.
5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_H_
8 #include "base/files/file_path.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/scoped_vector.h"
11 #include "base/win/scoped_handle.h"
12 #include "device/bluetooth/bluetooth_low_energy_defs_win.h"
14 namespace device {
15 namespace win {
17 // Represents a device registry property value
18 class DeviceRegistryPropertyValue {
19 public:
20 // Creates a property value instance, where |property_type| is one of REG_xxx
21 // registry value type (e.g. REG_SZ, REG_DWORD), |value| is a byte array
22 // containing the propery value and |value_size| is the number of bytes in
23 // |value|. Note the returned instance takes ownership of the bytes in
24 // |value|.
25 static scoped_ptr<DeviceRegistryPropertyValue> Create(
26 DWORD property_type,
27 scoped_ptr<uint8_t[]> value,
28 size_t value_size);
29 ~DeviceRegistryPropertyValue();
31 // Returns the vaue type a REG_xxx value (e.g. REG_SZ, REG_DWORD, ...)
32 DWORD property_type() const { return property_type_; }
34 std::string AsString() const;
35 DWORD AsDWORD() const;
37 private:
38 DeviceRegistryPropertyValue(DWORD property_type,
39 scoped_ptr<uint8_t[]> value,
40 size_t value_size);
42 DWORD property_type_;
43 scoped_ptr<uint8_t[]> value_;
44 size_t value_size_;
46 DISALLOW_COPY_AND_ASSIGN(DeviceRegistryPropertyValue);
49 // Represents the value associated to a DEVPROPKEY.
50 class DevicePropertyValue {
51 public:
52 // Creates a property value instance, where |property_type| is one of
53 // DEVPROP_TYPE_xxx value type , |value| is a byte array containing the
54 // propery value and |value_size| is the number of bytes in |value|. Note the
55 // returned instance takes ownership of the bytes in |value|.
56 DevicePropertyValue(DEVPROPTYPE property_type,
57 scoped_ptr<uint8_t[]> value,
58 size_t value_size);
60 DEVPROPTYPE property_type() const { return property_type_; }
62 uint32_t AsUint32() const;
64 private:
65 DEVPROPTYPE property_type_;
66 scoped_ptr<uint8_t[]> value_;
67 size_t value_size_;
69 DISALLOW_COPY_AND_ASSIGN(DevicePropertyValue);
72 // Returns true only on Windows platforms supporting Bluetooth Low Energy.
73 bool IsBluetoothLowEnergySupported();
75 struct BluetoothLowEnergyServiceInfo {
76 BluetoothLowEnergyServiceInfo();
77 ~BluetoothLowEnergyServiceInfo();
79 BTH_LE_UUID uuid;
82 struct BluetoothLowEnergyDeviceInfo {
83 BluetoothLowEnergyDeviceInfo();
84 ~BluetoothLowEnergyDeviceInfo();
86 base::FilePath path;
87 std::string id;
88 std::string friendly_name;
89 BLUETOOTH_ADDRESS address;
90 bool visible;
91 bool authenticated;
92 bool connected;
95 // Enumerates the list of known (i.e. already paired) Bluetooth LE devices on
96 // this machine. In case of error, returns false and sets |error| with an error
97 // message describing the problem.
98 // Note: This function returns an error if Bluetooth Low Energy is not supported
99 // on this Windows platform.
100 bool EnumerateKnownBluetoothLowEnergyDevices(
101 ScopedVector<BluetoothLowEnergyDeviceInfo>* devices,
102 std::string* error);
104 // Enumerates the list of known (i.e. cached) GATT services for a given
105 // Bluetooth LE device |device_path| into |services|. In case of error, returns
106 // false and sets |error| with an error message describing the problem. Note:
107 // This function returns an error if Bluetooth Low Energy is not supported on
108 // this Windows platform.
109 bool EnumerateKnownBluetoothLowEnergyServices(
110 const base::FilePath& device_path,
111 ScopedVector<BluetoothLowEnergyServiceInfo>* services,
112 std::string* error);
114 bool ExtractBluetoothAddressFromDeviceInstanceIdForTesting(
115 const std::string& instance_id,
116 BLUETOOTH_ADDRESS* btha,
117 std::string* error);
119 } // namespace win
120 } // namespace device
122 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_H_