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 virtual ~BluetoothDeviceWin();
33 // BluetoothDevice override
34 virtual uint32
GetBluetoothClass() const override
;
35 virtual std::string
GetAddress() const override
;
36 virtual VendorIDSource
GetVendorIDSource() const override
;
37 virtual uint16
GetVendorID() const override
;
38 virtual uint16
GetProductID() const override
;
39 virtual uint16
GetDeviceID() const override
;
40 virtual bool IsPaired() const override
;
41 virtual bool IsConnected() const override
;
42 virtual bool IsConnectable() const override
;
43 virtual bool IsConnecting() const override
;
44 virtual UUIDList
GetUUIDs() const override
;
45 virtual bool ExpectingPinCode() const override
;
46 virtual bool ExpectingPasskey() const override
;
47 virtual bool ExpectingConfirmation() const override
;
48 virtual void GetConnectionInfo(
49 const ConnectionInfoCallback
& callback
) override
;
51 PairingDelegate
* pairing_delegate
,
52 const base::Closure
& callback
,
53 const ConnectErrorCallback
& error_callback
) override
;
54 virtual void SetPinCode(const std::string
& pincode
) override
;
55 virtual void SetPasskey(uint32 passkey
) override
;
56 virtual void ConfirmPairing() override
;
57 virtual void RejectPairing() override
;
58 virtual void CancelPairing() override
;
59 virtual void Disconnect(
60 const base::Closure
& callback
,
61 const ErrorCallback
& error_callback
) override
;
62 virtual void Forget(const ErrorCallback
& error_callback
) override
;
63 virtual void ConnectToService(
64 const BluetoothUUID
& uuid
,
65 const ConnectToServiceCallback
& callback
,
66 const ConnectToServiceErrorCallback
& error_callback
) override
;
67 virtual void ConnectToServiceInsecurely(
68 const BluetoothUUID
& uuid
,
69 const ConnectToServiceCallback
& callback
,
70 const ConnectToServiceErrorCallback
& error_callback
) override
;
71 virtual void CreateGattConnection(
72 const GattConnectionCallback
& callback
,
73 const ConnectErrorCallback
& error_callback
) override
;
75 // Used by BluetoothProfileWin to retrieve the service record for the given
77 const BluetoothServiceRecordWin
* GetServiceRecord(
78 const device::BluetoothUUID
& uuid
) const;
80 // Returns true if all fields and services of this instance are equal to the
81 // fields and services stored in |device_state|.
82 bool IsEqual(const BluetoothTaskManagerWin::DeviceState
& device_state
);
84 // Updates this instance with all fields and properties stored in
86 void Update(const BluetoothTaskManagerWin::DeviceState
& device_state
);
89 // BluetoothDevice override
90 virtual std::string
GetDeviceName() const override
;
93 friend class BluetoothAdapterWin
;
95 // Used by BluetoothAdapterWin to update the visible state during
97 void SetVisible(bool visible
);
99 // Updates the services with services stored in |device_state|.
100 void UpdateServices(const BluetoothTaskManagerWin::DeviceState
& device_state
);
102 scoped_refptr
<base::SequencedTaskRunner
> ui_task_runner_
;
103 scoped_refptr
<BluetoothSocketThread
> socket_thread_
;
104 net::NetLog
* net_log_
;
105 net::NetLog::Source net_log_source_
;
107 // The Bluetooth class of the device, a bitmask that may be decoded using
108 // https://www.bluetooth.org/Technical/AssignedNumbers/baseband.htm
109 uint32 bluetooth_class_
;
111 // The name of the device, as supplied by the remote device.
114 // The Bluetooth address of the device.
115 std::string address_
;
117 // Tracked device state, updated by the adapter managing the lifecycle of
122 // Used to send change notifications when a device disappears during
126 // The services (identified by UUIDs) that this device provides.
129 // The service records retrieved from SDP.
130 typedef ScopedVector
<BluetoothServiceRecordWin
> ServiceRecordList
;
131 ServiceRecordList service_record_list_
;
133 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceWin
);
136 } // namespace device
138 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_WIN_H_