| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_LOW_ENERGY_CONNECTION_FINDER_H | 5 #ifndef COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_LOW_ENERGY_CONNECTION_FINDER_H |
| 6 #define COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_LOW_ENERGY_CONNECTION_FINDER_H | 6 #define COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_LOW_ENERGY_CONNECTION_FINDER_H |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 // Closes the connection and forgets the device. | 42 // Closes the connection and forgets the device. |
| 43 void CloseGattConnection( | 43 void CloseGattConnection( |
| 44 scoped_ptr<device::BluetoothGattConnection> gatt_connection); | 44 scoped_ptr<device::BluetoothGattConnection> gatt_connection); |
| 45 | 45 |
| 46 // proximity_auth::ConnectionObserver: | 46 // proximity_auth::ConnectionObserver: |
| 47 void OnConnectionStatusChanged(Connection* connection, | 47 void OnConnectionStatusChanged(Connection* connection, |
| 48 Connection::Status old_status, | 48 Connection::Status old_status, |
| 49 Connection::Status new_status) override; | 49 Connection::Status new_status) override; |
| 50 | 50 |
| 51 protected: | |
| 52 // device::BluetoothAdapter::Observer: | 51 // device::BluetoothAdapter::Observer: |
| 53 void DeviceAdded(device::BluetoothAdapter* adapter, | 52 void DeviceAdded(device::BluetoothAdapter* adapter, |
| 54 device::BluetoothDevice* device) override; | 53 device::BluetoothDevice* device) override; |
| 55 void DeviceChanged(device::BluetoothAdapter* adapter, | 54 void DeviceChanged(device::BluetoothAdapter* adapter, |
| 56 device::BluetoothDevice* device) override; | 55 device::BluetoothDevice* device) override; |
| 57 void DeviceRemoved(device::BluetoothAdapter* adapter, | 56 void DeviceRemoved(device::BluetoothAdapter* adapter, |
| 58 device::BluetoothDevice* device) override; | 57 device::BluetoothDevice* device) override; |
| 59 | 58 |
| 59 protected: |
| 60 // Creates a proximity_auth::Connection based on |gatt_connection|. Exposed |
| 61 // for testing. |
| 62 virtual scoped_ptr<Connection> CreateConnection( |
| 63 scoped_ptr<device::BluetoothGattConnection> gatt_connection); |
| 64 |
| 60 private: | 65 private: |
| 61 // Callback to be called when the Bluetooth adapter is initialized. | 66 // Callback to be called when the Bluetooth adapter is initialized. |
| 62 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter); | 67 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter); |
| 63 | 68 |
| 64 // Checks if |remote_device| contains |remote_service_uuid| and creates a | 69 // Checks if |remote_device| contains |remote_service_uuid| and creates a |
| 65 // connection in that case. | 70 // connection in that case. |
| 66 void HandleDeviceUpdated(device::BluetoothDevice* remote_device); | 71 void HandleDeviceUpdated(device::BluetoothDevice* remote_device); |
| 67 | 72 |
| 68 // Callback called when a new discovery session is started. | 73 // Callback called when a new discovery session is started. |
| 69 void OnDiscoverySessionStarted( | 74 void OnDiscoverySessionStarted( |
| (...skipping 23 matching lines...) Expand all Loading... |
| 93 device::BluetoothDevice::ConnectErrorCode error_code); | 98 device::BluetoothDevice::ConnectErrorCode error_code); |
| 94 | 99 |
| 95 // Callback called when a GATT connection is created. | 100 // Callback called when a GATT connection is created. |
| 96 void OnGattConnectionCreated( | 101 void OnGattConnectionCreated( |
| 97 scoped_ptr<device::BluetoothGattConnection> gatt_connection); | 102 scoped_ptr<device::BluetoothGattConnection> gatt_connection); |
| 98 | 103 |
| 99 // Creates a GATT connection with |remote_device|, |connection_callback_| will | 104 // Creates a GATT connection with |remote_device|, |connection_callback_| will |
| 100 // be called once the connection is established. | 105 // be called once the connection is established. |
| 101 void CreateGattConnection(device::BluetoothDevice* remote_device); | 106 void CreateGattConnection(device::BluetoothDevice* remote_device); |
| 102 | 107 |
| 103 // Creates a connection with |remote_device|. | |
| 104 scoped_ptr<Connection> CreateConnection( | |
| 105 scoped_ptr<device::BluetoothGattConnection> gatt_connection); | |
| 106 | |
| 107 // The uuid of the service it looks for to establish a GattConnection. | 108 // The uuid of the service it looks for to establish a GattConnection. |
| 108 device::BluetoothUUID remote_service_uuid_; | 109 device::BluetoothUUID remote_service_uuid_; |
| 109 | 110 |
| 110 // Characteristic used to send data to the remote device. | 111 // Characteristic used to send data to the remote device. |
| 111 device::BluetoothUUID to_peripheral_char_uuid_; | 112 device::BluetoothUUID to_peripheral_char_uuid_; |
| 112 | 113 |
| 113 // Characteristic used to receive data from the remote device. | 114 // Characteristic used to receive data from the remote device. |
| 114 device::BluetoothUUID from_peripheral_char_uuid_; | 115 device::BluetoothUUID from_peripheral_char_uuid_; |
| 115 | 116 |
| 116 // The Bluetooth adapter over which the Bluetooth connection will be made. | 117 // The Bluetooth adapter over which the Bluetooth connection will be made. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 134 std::set<device::BluetoothDevice*> pending_connections_; | 135 std::set<device::BluetoothDevice*> pending_connections_; |
| 135 | 136 |
| 136 base::WeakPtrFactory<BluetoothLowEnergyConnectionFinder> weak_ptr_factory_; | 137 base::WeakPtrFactory<BluetoothLowEnergyConnectionFinder> weak_ptr_factory_; |
| 137 | 138 |
| 138 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyConnectionFinder); | 139 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyConnectionFinder); |
| 139 }; | 140 }; |
| 140 | 141 |
| 141 } // namespace proximity_auth | 142 } // namespace proximity_auth |
| 142 | 143 |
| 143 #endif // COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_CONNECTION_FINDER_H | 144 #endif // COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_CONNECTION_FINDER_H |
| OLD | NEW |