| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 const ErrorCallback& error_callback) override; | 69 const ErrorCallback& error_callback) override; |
| 70 void Forget(const ErrorCallback& error_callback) override; | 70 void Forget(const ErrorCallback& error_callback) override; |
| 71 void ConnectToService( | 71 void ConnectToService( |
| 72 const device::BluetoothUUID& uuid, | 72 const device::BluetoothUUID& uuid, |
| 73 const ConnectToServiceCallback& callback, | 73 const ConnectToServiceCallback& callback, |
| 74 const ConnectToServiceErrorCallback& error_callback) override; | 74 const ConnectToServiceErrorCallback& error_callback) override; |
| 75 void ConnectToServiceInsecurely( | 75 void ConnectToServiceInsecurely( |
| 76 const device::BluetoothUUID& uuid, | 76 const device::BluetoothUUID& uuid, |
| 77 const ConnectToServiceCallback& callback, | 77 const ConnectToServiceCallback& callback, |
| 78 const ConnectToServiceErrorCallback& error_callback) override; | 78 const ConnectToServiceErrorCallback& error_callback) override; |
| 79 void CreateGattConnection( | 79 scoped_ptr<device::BluetoothGattConnection> CreateGattConnection( |
| 80 const GattConnectionCallback& callback, | 80 const GattConnectionCallback& callback, |
| 81 const ConnectErrorCallback& error_callback) override; | 81 const ConnectErrorCallback& error_callback) override; |
| 82 void Pair(device::BluetoothDevice::PairingDelegate* pairing_delegate, | 82 void Pair(device::BluetoothDevice::PairingDelegate* pairing_delegate, |
| 83 const base::Closure& callback, | 83 const base::Closure& callback, |
| 84 const ConnectErrorCallback& error_callback) override; | 84 const ConnectErrorCallback& error_callback) override; |
| 85 | 85 |
| 86 // Creates a pairing object with the given delegate |pairing_delegate| and | 86 // Creates a pairing object with the given delegate |pairing_delegate| and |
| 87 // establishes it as the pairing context for this device. All pairing-related | 87 // establishes it as the pairing context for this device. All pairing-related |
| 88 // method calls will be forwarded to this object until it is released. | 88 // method calls will be forwarded to this object until it is released. |
| 89 BluetoothPairingChromeOS* BeginPairing( | 89 BluetoothPairingChromeOS* BeginPairing( |
| 90 BluetoothDevice::PairingDelegate* pairing_delegate); | 90 BluetoothDevice::PairingDelegate* pairing_delegate); |
| 91 | 91 |
| 92 // Releases the current pairing object, any pairing-related method calls will | 92 // Releases the current pairing object, any pairing-related method calls will |
| 93 // be ignored. | 93 // be ignored. |
| 94 void EndPairing(); | 94 void EndPairing(); |
| 95 | 95 |
| 96 // Returns the current pairing object or NULL if no pairing is in progress. | 96 // Returns the current pairing object or NULL if no pairing is in progress. |
| 97 BluetoothPairingChromeOS* GetPairing() const; | 97 BluetoothPairingChromeOS* GetPairing() const; |
| 98 | 98 |
| 99 // Returns the object path of the device. | 99 // Returns the object path of the device. |
| 100 const dbus::ObjectPath& object_path() const { return object_path_; } | 100 const dbus::ObjectPath& object_path() const { return object_path_; } |
| 101 | 101 |
| 102 // Returns the adapter which owns this device instance. | 102 // Returns the adapter which owns this device instance. |
| 103 BluetoothAdapterChromeOS* adapter() const; | 103 BluetoothAdapterChromeOS* adapter() const; |
| 104 | 104 |
| 105 protected: | 105 protected: |
| 106 // BluetoothDevice override | 106 // BluetoothDevice override |
| 107 std::string GetDeviceName() const override; | 107 std::string GetDeviceName() const override; |
| 108 void CreateGattConnectionImpl() override; | 108 scoped_ptr<device::BluetoothGattConnection> CreateGattConnectionImpl() |
| 109 override; |
| 110 scoped_ptr<device::BluetoothGattConnection> ExistingGattConnection() override; |
| 109 void DisconnectGatt() override; | 111 void DisconnectGatt() override; |
| 110 | 112 |
| 111 private: | 113 private: |
| 112 friend class BluetoothAdapterChromeOS; | 114 friend class BluetoothAdapterChromeOS; |
| 113 | 115 |
| 114 BluetoothDeviceChromeOS( | 116 BluetoothDeviceChromeOS( |
| 115 BluetoothAdapterChromeOS* adapter, | 117 BluetoothAdapterChromeOS* adapter, |
| 116 const dbus::ObjectPath& object_path, | 118 const dbus::ObjectPath& object_path, |
| 117 scoped_refptr<base::SequencedTaskRunner> ui_task_runner, | 119 scoped_refptr<base::SequencedTaskRunner> ui_task_runner, |
| 118 scoped_refptr<device::BluetoothSocketThread> socket_thread); | 120 scoped_refptr<device::BluetoothSocketThread> socket_thread); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 132 const std::string& error_name, | 134 const std::string& error_name, |
| 133 const std::string& error_message); | 135 const std::string& error_message); |
| 134 | 136 |
| 135 // Internal method to initiate a connection to this device, and methods called | 137 // Internal method to initiate a connection to this device, and methods called |
| 136 // by dbus:: on completion of the D-Bus method call. | 138 // by dbus:: on completion of the D-Bus method call. |
| 137 void ConnectInternal(bool after_pairing, | 139 void ConnectInternal(bool after_pairing, |
| 138 const base::Closure& callback, | 140 const base::Closure& callback, |
| 139 const ConnectErrorCallback& error_callback); | 141 const ConnectErrorCallback& error_callback); |
| 140 void OnConnect(bool after_pairing, | 142 void OnConnect(bool after_pairing, |
| 141 const base::Closure& callback); | 143 const base::Closure& callback); |
| 142 void OnCreateGattConnection(const GattConnectionCallback& callback); | 144 void OnCreateGattConnection(device::BluetoothGattConnection* conn, |
| 145 const GattConnectionCallback& callback); |
| 143 void OnConnectError(bool after_pairing, | 146 void OnConnectError(bool after_pairing, |
| 144 const ConnectErrorCallback& error_callback, | 147 const ConnectErrorCallback& error_callback, |
| 145 const std::string& error_name, | 148 const std::string& error_name, |
| 146 const std::string& error_message); | 149 const std::string& error_message); |
| 147 | 150 |
| 148 // Called by dbus:: on completion of the D-Bus method call to pair the device, | 151 // Called by dbus:: on completion of the D-Bus method call to pair the device, |
| 149 // made inside |Connect()|. | 152 // made inside |Connect()|. |
| 150 void OnPairDuringConnect(const base::Closure& callback, | 153 void OnPairDuringConnect(const base::Closure& callback, |
| 151 const ConnectErrorCallback& error_callback); | 154 const ConnectErrorCallback& error_callback); |
| 152 void OnPairDuringConnectError(const ConnectErrorCallback& error_callback, | 155 void OnPairDuringConnectError(const ConnectErrorCallback& error_callback, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 // Note: This should remain the last member so it'll be destroyed and | 212 // Note: This should remain the last member so it'll be destroyed and |
| 210 // invalidate its weak pointers before any other members are destroyed. | 213 // invalidate its weak pointers before any other members are destroyed. |
| 211 base::WeakPtrFactory<BluetoothDeviceChromeOS> weak_ptr_factory_; | 214 base::WeakPtrFactory<BluetoothDeviceChromeOS> weak_ptr_factory_; |
| 212 | 215 |
| 213 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceChromeOS); | 216 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceChromeOS); |
| 214 }; | 217 }; |
| 215 | 218 |
| 216 } // namespace chromeos | 219 } // namespace chromeos |
| 217 | 220 |
| 218 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H | 221 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H |
| OLD | NEW |