Roll leveldb 3f7758:803d69 (v1.17 -> v1.18)
[chromium-blink-merge.git] / device / bluetooth / bluetooth_device_win.h
blobafa54503b8da2f0dc13de86c88666a28ca601bd7
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 BluetoothServiceRecordWin;
20 class BluetoothSocketThread;
22 class BluetoothDeviceWin : public BluetoothDevice {
23 public:
24 explicit BluetoothDeviceWin(
25 const BluetoothTaskManagerWin::DeviceState& device_state,
26 const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner,
27 const 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 uint32 GetBluetoothClass() const override;
34 virtual std::string GetAddress() const override;
35 virtual VendorIDSource GetVendorIDSource() const override;
36 virtual uint16 GetVendorID() const override;
37 virtual uint16 GetProductID() const override;
38 virtual uint16 GetDeviceID() const override;
39 virtual int GetRSSI() const override;
40 virtual int GetCurrentHostTransmitPower() const override;
41 virtual int GetMaximumHostTransmitPower() const override;
42 virtual bool IsPaired() const override;
43 virtual bool IsConnected() const override;
44 virtual bool IsConnectable() const override;
45 virtual bool IsConnecting() const override;
46 virtual UUIDList GetUUIDs() const override;
47 virtual bool ExpectingPinCode() const override;
48 virtual bool ExpectingPasskey() const override;
49 virtual bool ExpectingConfirmation() const override;
50 virtual void Connect(
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;
74 virtual void StartConnectionMonitor(
75 const base::Closure& callback,
76 const ErrorCallback& error_callback) override;
78 // Used by BluetoothProfileWin to retrieve the service record for the given
79 // |uuid|.
80 const BluetoothServiceRecordWin* GetServiceRecord(
81 const device::BluetoothUUID& uuid) const;
83 // Returns true if all fields and services of this instance are equal to the
84 // fields and services stored in |device_state|.
85 bool IsEqual(const BluetoothTaskManagerWin::DeviceState& device_state);
87 // Updates this instance with all fields and properties stored in
88 // |device_state|.
89 void Update(const BluetoothTaskManagerWin::DeviceState& device_state);
91 protected:
92 // BluetoothDevice override
93 virtual std::string GetDeviceName() const override;
95 private:
96 friend class BluetoothAdapterWin;
98 // Used by BluetoothAdapterWin to update the visible state during
99 // discovery.
100 void SetVisible(bool visible);
102 // Updates the services with services stored in |device_state|.
103 void UpdateServices(const BluetoothTaskManagerWin::DeviceState& device_state);
105 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_;
106 scoped_refptr<BluetoothSocketThread> socket_thread_;
107 net::NetLog* net_log_;
108 net::NetLog::Source net_log_source_;
110 // The Bluetooth class of the device, a bitmask that may be decoded using
111 // https://www.bluetooth.org/Technical/AssignedNumbers/baseband.htm
112 uint32 bluetooth_class_;
114 // The name of the device, as supplied by the remote device.
115 std::string name_;
117 // The Bluetooth address of the device.
118 std::string address_;
120 // Tracked device state, updated by the adapter managing the lifecycle of
121 // the device.
122 bool paired_;
123 bool connected_;
125 // Used to send change notifications when a device disappears during
126 // discovery.
127 bool visible_;
129 // The services (identified by UUIDs) that this device provides.
130 UUIDList uuids_;
132 // The service records retrieved from SDP.
133 typedef ScopedVector<BluetoothServiceRecordWin> ServiceRecordList;
134 ServiceRecordList service_record_list_;
136 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceWin);
139 } // namespace device
141 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_WIN_H_