1 // Copyright (c) 2012 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_DEVICE_WIN_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_WIN_H_
11 #include "base/basictypes.h"
12 #include "base/observer_list.h"
13 #include "device/bluetooth/bluetooth_device.h"
14 #include "device/bluetooth/bluetooth_export.h"
15 #include "device/bluetooth/bluetooth_task_manager_win.h"
19 class BluetoothAdapterWin
;
20 class BluetoothServiceRecordWin
;
21 class BluetoothSocketThread
;
23 class DEVICE_BLUETOOTH_EXPORT BluetoothDeviceWin
: public BluetoothDevice
{
25 explicit BluetoothDeviceWin(
26 const BluetoothTaskManagerWin::DeviceState
& device_state
,
27 const scoped_refptr
<base::SequencedTaskRunner
>& ui_task_runner
,
28 const scoped_refptr
<BluetoothSocketThread
>& socket_thread
,
30 const net::NetLog::Source
& net_log_source
);
31 ~BluetoothDeviceWin() override
;
33 // BluetoothDevice override
34 uint32
GetBluetoothClass() const override
;
35 std::string
GetAddress() const override
;
36 VendorIDSource
GetVendorIDSource() const override
;
37 uint16
GetVendorID() const override
;
38 uint16
GetProductID() const override
;
39 uint16
GetDeviceID() const override
;
40 bool IsPaired() const override
;
41 bool IsConnected() const override
;
42 bool IsConnectable() const override
;
43 bool IsConnecting() const override
;
44 UUIDList
GetUUIDs() const override
;
45 bool ExpectingPinCode() const override
;
46 bool ExpectingPasskey() const override
;
47 bool ExpectingConfirmation() const override
;
48 void GetConnectionInfo(const ConnectionInfoCallback
& callback
) override
;
49 void Connect(PairingDelegate
* pairing_delegate
,
50 const base::Closure
& callback
,
51 const ConnectErrorCallback
& error_callback
) override
;
52 void SetPinCode(const std::string
& pincode
) override
;
53 void SetPasskey(uint32 passkey
) override
;
54 void ConfirmPairing() override
;
55 void RejectPairing() override
;
56 void CancelPairing() override
;
57 void Disconnect(const base::Closure
& callback
,
58 const ErrorCallback
& error_callback
) override
;
59 void Forget(const ErrorCallback
& error_callback
) override
;
60 void ConnectToService(
61 const BluetoothUUID
& uuid
,
62 const ConnectToServiceCallback
& callback
,
63 const ConnectToServiceErrorCallback
& error_callback
) override
;
64 void ConnectToServiceInsecurely(
65 const BluetoothUUID
& uuid
,
66 const ConnectToServiceCallback
& callback
,
67 const ConnectToServiceErrorCallback
& error_callback
) override
;
68 void CreateGattConnection(
69 const GattConnectionCallback
& callback
,
70 const ConnectErrorCallback
& error_callback
) override
;
72 // Used by BluetoothProfileWin to retrieve the service record for the given
74 const BluetoothServiceRecordWin
* GetServiceRecord(
75 const device::BluetoothUUID
& uuid
) const;
77 // Returns true if all fields and services of this instance are equal to the
78 // fields and services stored in |device_state|.
79 bool IsEqual(const BluetoothTaskManagerWin::DeviceState
& device_state
);
81 // Updates this instance with all fields and properties stored in
83 void Update(const BluetoothTaskManagerWin::DeviceState
& device_state
);
86 // BluetoothDevice override
87 std::string
GetDeviceName() const override
;
90 friend class BluetoothAdapterWin
;
92 typedef ScopedVector
<BluetoothServiceRecordWin
> ServiceRecordList
;
94 // Used by BluetoothAdapterWin to update the visible state during
96 void SetVisible(bool visible
);
98 // Updates the services with services stored in |device_state|.
99 void UpdateServices(const BluetoothTaskManagerWin::DeviceState
& device_state
);
101 scoped_refptr
<base::SequencedTaskRunner
> ui_task_runner_
;
102 scoped_refptr
<BluetoothSocketThread
> socket_thread_
;
103 net::NetLog
* net_log_
;
104 net::NetLog::Source net_log_source_
;
106 // The Bluetooth class of the device, a bitmask that may be decoded using
107 // https://www.bluetooth.org/Technical/AssignedNumbers/baseband.htm
108 uint32 bluetooth_class_
;
110 // The name of the device, as supplied by the remote device.
113 // The Bluetooth address of the device.
114 std::string address_
;
116 // Tracked device state, updated by the adapter managing the lifecycle of
121 // Used to send change notifications when a device disappears during
125 // The services (identified by UUIDs) that this device provides.
128 // The service records retrieved from SDP.
129 ServiceRecordList service_record_list_
;
131 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceWin
);
134 } // namespace device
136 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_WIN_H_