OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 : public device::BluetoothDevice, | 32 : public device::BluetoothDevice, |
33 public BluetoothGattServiceClient::Observer { | 33 public BluetoothGattServiceClient::Observer { |
34 public: | 34 public: |
35 // BluetoothDevice override | 35 // BluetoothDevice override |
36 virtual uint32 GetBluetoothClass() const override; | 36 virtual uint32 GetBluetoothClass() const override; |
37 virtual std::string GetAddress() const override; | 37 virtual std::string GetAddress() const override; |
38 virtual VendorIDSource GetVendorIDSource() const override; | 38 virtual VendorIDSource GetVendorIDSource() const override; |
39 virtual uint16 GetVendorID() const override; | 39 virtual uint16 GetVendorID() const override; |
40 virtual uint16 GetProductID() const override; | 40 virtual uint16 GetProductID() const override; |
41 virtual uint16 GetDeviceID() const override; | 41 virtual uint16 GetDeviceID() const override; |
42 virtual int GetRSSI() const override; | |
43 virtual int GetCurrentHostTransmitPower() const override; | |
44 virtual int GetMaximumHostTransmitPower() const override; | |
45 virtual bool IsPaired() const override; | 42 virtual bool IsPaired() const override; |
46 virtual bool IsConnected() const override; | 43 virtual bool IsConnected() const override; |
47 virtual bool IsConnectable() const override; | 44 virtual bool IsConnectable() const override; |
48 virtual bool IsConnecting() const override; | 45 virtual bool IsConnecting() const override; |
49 virtual UUIDList GetUUIDs() const override; | 46 virtual UUIDList GetUUIDs() const override; |
50 virtual bool ExpectingPinCode() const override; | 47 virtual bool ExpectingPinCode() const override; |
51 virtual bool ExpectingPasskey() const override; | 48 virtual bool ExpectingPasskey() const override; |
52 virtual bool ExpectingConfirmation() const override; | 49 virtual bool ExpectingConfirmation() const override; |
| 50 void GetConnectionInfo( |
| 51 const ConnectionInfoCallback& callback) override; |
53 virtual void Connect( | 52 virtual void Connect( |
54 device::BluetoothDevice::PairingDelegate* pairing_delegate, | 53 device::BluetoothDevice::PairingDelegate* pairing_delegate, |
55 const base::Closure& callback, | 54 const base::Closure& callback, |
56 const ConnectErrorCallback& error_callback) override; | 55 const ConnectErrorCallback& error_callback) override; |
57 virtual void SetPinCode(const std::string& pincode) override; | 56 virtual void SetPinCode(const std::string& pincode) override; |
58 virtual void SetPasskey(uint32 passkey) override; | 57 virtual void SetPasskey(uint32 passkey) override; |
59 virtual void ConfirmPairing() override; | 58 virtual void ConfirmPairing() override; |
60 virtual void RejectPairing() override; | 59 virtual void RejectPairing() override; |
61 virtual void CancelPairing() override; | 60 virtual void CancelPairing() override; |
62 virtual void Disconnect( | 61 virtual void Disconnect( |
63 const base::Closure& callback, | 62 const base::Closure& callback, |
64 const ErrorCallback& error_callback) override; | 63 const ErrorCallback& error_callback) override; |
65 virtual void Forget(const ErrorCallback& error_callback) override; | 64 virtual void Forget(const ErrorCallback& error_callback) override; |
66 virtual void ConnectToService( | 65 virtual void ConnectToService( |
67 const device::BluetoothUUID& uuid, | 66 const device::BluetoothUUID& uuid, |
68 const ConnectToServiceCallback& callback, | 67 const ConnectToServiceCallback& callback, |
69 const ConnectToServiceErrorCallback& error_callback) override; | 68 const ConnectToServiceErrorCallback& error_callback) override; |
70 virtual void ConnectToServiceInsecurely( | 69 virtual void ConnectToServiceInsecurely( |
71 const device::BluetoothUUID& uuid, | 70 const device::BluetoothUUID& uuid, |
72 const ConnectToServiceCallback& callback, | 71 const ConnectToServiceCallback& callback, |
73 const ConnectToServiceErrorCallback& error_callback) override; | 72 const ConnectToServiceErrorCallback& error_callback) override; |
74 virtual void CreateGattConnection( | 73 virtual void CreateGattConnection( |
75 const GattConnectionCallback& callback, | 74 const GattConnectionCallback& callback, |
76 const ConnectErrorCallback& error_callback) override; | 75 const ConnectErrorCallback& error_callback) override; |
77 virtual void StartConnectionMonitor( | |
78 const base::Closure& callback, | |
79 const ErrorCallback& error_callback) override; | |
80 | 76 |
81 // Creates a pairing object with the given delegate |pairing_delegate| and | 77 // Creates a pairing object with the given delegate |pairing_delegate| and |
82 // establishes it as the pairing context for this device. All pairing-related | 78 // establishes it as the pairing context for this device. All pairing-related |
83 // method calls will be forwarded to this object until it is released. | 79 // method calls will be forwarded to this object until it is released. |
84 BluetoothPairingChromeOS* BeginPairing( | 80 BluetoothPairingChromeOS* BeginPairing( |
85 BluetoothDevice::PairingDelegate* pairing_delegate); | 81 BluetoothDevice::PairingDelegate* pairing_delegate); |
86 | 82 |
87 // Releases the current pairing object, any pairing-related method calls will | 83 // Releases the current pairing object, any pairing-related method calls will |
88 // be ignored. | 84 // be ignored. |
89 void EndPairing(); | 85 void EndPairing(); |
(...skipping 15 matching lines...) Expand all Loading... |
105 BluetoothAdapterChromeOS* adapter, | 101 BluetoothAdapterChromeOS* adapter, |
106 const dbus::ObjectPath& object_path, | 102 const dbus::ObjectPath& object_path, |
107 scoped_refptr<base::SequencedTaskRunner> ui_task_runner, | 103 scoped_refptr<base::SequencedTaskRunner> ui_task_runner, |
108 scoped_refptr<device::BluetoothSocketThread> socket_thread); | 104 scoped_refptr<device::BluetoothSocketThread> socket_thread); |
109 virtual ~BluetoothDeviceChromeOS(); | 105 virtual ~BluetoothDeviceChromeOS(); |
110 | 106 |
111 // BluetoothGattServiceClient::Observer overrides. | 107 // BluetoothGattServiceClient::Observer overrides. |
112 virtual void GattServiceAdded(const dbus::ObjectPath& object_path) override; | 108 virtual void GattServiceAdded(const dbus::ObjectPath& object_path) override; |
113 virtual void GattServiceRemoved(const dbus::ObjectPath& object_path) override; | 109 virtual void GattServiceRemoved(const dbus::ObjectPath& object_path) override; |
114 | 110 |
| 111 // Called by dbus:: on completion of the D-Bus method call to get the |
| 112 // connection attributes of the current connection to the device. |
| 113 void OnGetConnInfo(const ConnectionInfoCallback& callback, |
| 114 int16 rssi, |
| 115 int16 transmit_power, |
| 116 int16 max_transmit_power); |
| 117 void OnGetConnInfoError(const ConnectionInfoCallback& callback, |
| 118 const std::string& error_name, |
| 119 const std::string& error_message); |
| 120 |
115 // Internal method to initiate a connection to this device, and methods called | 121 // Internal method to initiate a connection to this device, and methods called |
116 // by dbus:: on completion of the D-Bus method call. | 122 // by dbus:: on completion of the D-Bus method call. |
117 void ConnectInternal(bool after_pairing, | 123 void ConnectInternal(bool after_pairing, |
118 const base::Closure& callback, | 124 const base::Closure& callback, |
119 const ConnectErrorCallback& error_callback); | 125 const ConnectErrorCallback& error_callback); |
120 void OnConnect(bool after_pairing, | 126 void OnConnect(bool after_pairing, |
121 const base::Closure& callback); | 127 const base::Closure& callback); |
122 void OnCreateGattConnection(const GattConnectionCallback& callback); | 128 void OnCreateGattConnection(const GattConnectionCallback& callback); |
123 void OnConnectError(bool after_pairing, | 129 void OnConnectError(bool after_pairing, |
124 const ConnectErrorCallback& error_callback, | 130 const ConnectErrorCallback& error_callback, |
(...skipping 27 matching lines...) Expand all Loading... |
152 const std::string& error_name, | 158 const std::string& error_name, |
153 const std::string& error_message); | 159 const std::string& error_message); |
154 | 160 |
155 // Called by dbus:: on failure of the D-Bus method call to unpair the device; | 161 // Called by dbus:: on failure of the D-Bus method call to unpair the device; |
156 // there is no matching completion call since this object is deleted in the | 162 // there is no matching completion call since this object is deleted in the |
157 // process of unpairing. | 163 // process of unpairing. |
158 void OnForgetError(const ErrorCallback& error_callback, | 164 void OnForgetError(const ErrorCallback& error_callback, |
159 const std::string& error_name, | 165 const std::string& error_name, |
160 const std::string& error_message); | 166 const std::string& error_message); |
161 | 167 |
162 // Called by dbus:: on completion of the D-Bus method call to start the | |
163 // connection monitor. | |
164 void OnStartConnectionMonitor(const base::Closure& callback); | |
165 void OnStartConnectionMonitorError(const ErrorCallback& error_callback, | |
166 const std::string& error_name, | |
167 const std::string& error_message); | |
168 | |
169 // The adapter that owns this device instance. | 168 // The adapter that owns this device instance. |
170 BluetoothAdapterChromeOS* adapter_; | 169 BluetoothAdapterChromeOS* adapter_; |
171 | 170 |
172 // The dbus object path of the device object. | 171 // The dbus object path of the device object. |
173 dbus::ObjectPath object_path_; | 172 dbus::ObjectPath object_path_; |
174 | 173 |
175 // Number of ongoing calls to Connect(). | 174 // Number of ongoing calls to Connect(). |
176 int num_connecting_calls_; | 175 int num_connecting_calls_; |
177 | 176 |
178 // True if the connection monitor has been started, tracking the connection | 177 // True if the connection monitor has been started, tracking the connection |
(...skipping 12 matching lines...) Expand all Loading... |
191 // Note: This should remain the last member so it'll be destroyed and | 190 // Note: This should remain the last member so it'll be destroyed and |
192 // invalidate its weak pointers before any other members are destroyed. | 191 // invalidate its weak pointers before any other members are destroyed. |
193 base::WeakPtrFactory<BluetoothDeviceChromeOS> weak_ptr_factory_; | 192 base::WeakPtrFactory<BluetoothDeviceChromeOS> weak_ptr_factory_; |
194 | 193 |
195 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceChromeOS); | 194 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceChromeOS); |
196 }; | 195 }; |
197 | 196 |
198 } // namespace chromeos | 197 } // namespace chromeos |
199 | 198 |
200 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H | 199 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H |
OLD | NEW |