Implement chrome.bluetoothSocket.connect()
[chromium-blink-merge.git] / device / bluetooth / bluetooth_device_win.h
blobfa0c752ae34530f07912c8ea8942a1331cd85f0c
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_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/observer_list.h"
13 #include "device/bluetooth/bluetooth_device.h"
14 #include "device/bluetooth/bluetooth_task_manager_win.h"
16 namespace device {
18 class BluetoothAdapterWin;
19 class BluetoothServiceRecord;
20 class BluetoothSocketThread;
22 class BluetoothDeviceWin : public BluetoothDevice {
23 public:
24 explicit BluetoothDeviceWin(
25 const BluetoothTaskManagerWin::DeviceState& state,
26 scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
27 scoped_refptr<BluetoothSocketThread> socket_thread,
28 net::NetLog* net_log,
29 const net::NetLog::Source& net_log_source);
30 virtual ~BluetoothDeviceWin();
32 // BluetoothDevice override
33 virtual void AddObserver(
34 device::BluetoothDevice::Observer* observer) OVERRIDE;
35 virtual void RemoveObserver(
36 device::BluetoothDevice::Observer* observer) OVERRIDE;
37 virtual uint32 GetBluetoothClass() const OVERRIDE;
38 virtual std::string GetAddress() const OVERRIDE;
39 virtual VendorIDSource GetVendorIDSource() const OVERRIDE;
40 virtual uint16 GetVendorID() const OVERRIDE;
41 virtual uint16 GetProductID() const OVERRIDE;
42 virtual uint16 GetDeviceID() const OVERRIDE;
43 virtual int GetRSSI() const OVERRIDE;
44 virtual int GetCurrentHostTransmitPower() const OVERRIDE;
45 virtual int GetMaximumHostTransmitPower() const OVERRIDE;
46 virtual bool IsPaired() const OVERRIDE;
47 virtual bool IsConnected() const OVERRIDE;
48 virtual bool IsConnectable() const OVERRIDE;
49 virtual bool IsConnecting() const OVERRIDE;
50 virtual UUIDList GetUUIDs() const OVERRIDE;
51 virtual bool ExpectingPinCode() const OVERRIDE;
52 virtual bool ExpectingPasskey() const OVERRIDE;
53 virtual bool ExpectingConfirmation() const OVERRIDE;
54 virtual void Connect(
55 PairingDelegate* pairing_delegate,
56 const base::Closure& callback,
57 const ConnectErrorCallback& error_callback) OVERRIDE;
58 virtual void SetPinCode(const std::string& pincode) OVERRIDE;
59 virtual void SetPasskey(uint32 passkey) OVERRIDE;
60 virtual void ConfirmPairing() OVERRIDE;
61 virtual void RejectPairing() OVERRIDE;
62 virtual void CancelPairing() OVERRIDE;
63 virtual void Disconnect(
64 const base::Closure& callback,
65 const ErrorCallback& error_callback) OVERRIDE;
66 virtual void Forget(const ErrorCallback& error_callback) OVERRIDE;
67 virtual void ConnectToProfile(
68 device::BluetoothProfile* profile,
69 const base::Closure& callback,
70 const ConnectToProfileErrorCallback& error_callback) OVERRIDE;
71 virtual void ConnectToService(
72 const BluetoothUUID& uuid,
73 const ConnectToServiceCallback& callback,
74 const ConnectToServiceErrorCallback& error_callback) OVERRIDE;
75 virtual void SetOutOfBandPairingData(
76 const BluetoothOutOfBandPairingData& data,
77 const base::Closure& callback,
78 const ErrorCallback& error_callback) OVERRIDE;
79 virtual void ClearOutOfBandPairingData(
80 const base::Closure& callback,
81 const ErrorCallback& error_callback) OVERRIDE;
83 // Used by BluetoothProfileWin to retrieve the service record for the given
84 // |uuid|.
85 const BluetoothServiceRecord* GetServiceRecord(
86 const device::BluetoothUUID& uuid) const;
88 protected:
89 // BluetoothDevice override
90 virtual std::string GetDeviceName() const OVERRIDE;
92 private:
93 friend class BluetoothAdapterWin;
95 // Used by BluetoothAdapterWin to update the visible state during
96 // discovery.
97 void SetVisible(bool visible);
99 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_;
100 scoped_refptr<BluetoothSocketThread> socket_thread_;
101 net::NetLog* net_log_;
102 net::NetLog::Source net_log_source_;
104 // List of observers interested in event notifications from us.
105 ObserverList<Observer> observers_;
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.
112 std::string name_;
114 // The Bluetooth address of the device.
115 std::string address_;
117 // Tracked device state, updated by the adapter managing the lifecycle of
118 // the device.
119 bool paired_;
120 bool connected_;
122 // Used to send change notifications when a device disappears during
123 // discovery.
124 bool visible_;
126 // The services (identified by UUIDs) that this device provides.
127 UUIDList uuids_;
129 // The service records retrieved from SDP.
130 typedef ScopedVector<BluetoothServiceRecord> ServiceRecordList;
131 ServiceRecordList service_record_list_;
133 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceWin);
136 } // namespace device
138 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_WIN_H_