Chromium Code Reviews| 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 connection with |remote_device|. Exposed for testing. | |
|
Tim Song
2015/05/20 07:47:00
nit: this comment isn't up to date anymore.
sacomoto
2015/05/20 22:34:21
Done.
| |
| 61 virtual scoped_ptr<Connection> CreateConnection( | |
| 62 scoped_ptr<device::BluetoothGattConnection> gatt_connection); | |
| 63 | |
| 60 private: | 64 private: |
| 61 // Callback to be called when the Bluetooth adapter is initialized. | 65 // Callback to be called when the Bluetooth adapter is initialized. |
| 62 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter); | 66 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter); |
| 63 | 67 |
| 64 // Checks if |remote_device| contains |remote_service_uuid| and creates a | 68 // Checks if |remote_device| contains |remote_service_uuid| and creates a |
| 65 // connection in that case. | 69 // connection in that case. |
| 66 void HandleDeviceUpdated(device::BluetoothDevice* remote_device); | 70 void HandleDeviceUpdated(device::BluetoothDevice* remote_device); |
| 67 | 71 |
| 68 // Callback called when a new discovery session is started. | 72 // Callback called when a new discovery session is started. |
| 69 void OnDiscoverySessionStarted( | 73 void OnDiscoverySessionStarted( |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 93 device::BluetoothDevice::ConnectErrorCode error_code); | 97 device::BluetoothDevice::ConnectErrorCode error_code); |
| 94 | 98 |
| 95 // Callback called when a GATT connection is created. | 99 // Callback called when a GATT connection is created. |
| 96 void OnGattConnectionCreated( | 100 void OnGattConnectionCreated( |
| 97 scoped_ptr<device::BluetoothGattConnection> gatt_connection); | 101 scoped_ptr<device::BluetoothGattConnection> gatt_connection); |
| 98 | 102 |
| 99 // Creates a GATT connection with |remote_device|, |connection_callback_| will | 103 // Creates a GATT connection with |remote_device|, |connection_callback_| will |
| 100 // be called once the connection is established. | 104 // be called once the connection is established. |
| 101 void CreateGattConnection(device::BluetoothDevice* remote_device); | 105 void CreateGattConnection(device::BluetoothDevice* remote_device); |
| 102 | 106 |
| 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. | 107 // The uuid of the service it looks for to establish a GattConnection. |
| 108 device::BluetoothUUID remote_service_uuid_; | 108 device::BluetoothUUID remote_service_uuid_; |
| 109 | 109 |
| 110 // Characteristic used to send data to the remote device. | 110 // Characteristic used to send data to the remote device. |
| 111 device::BluetoothUUID to_peripheral_char_uuid_; | 111 device::BluetoothUUID to_peripheral_char_uuid_; |
| 112 | 112 |
| 113 // Characteristic used to receive data from the remote device. | 113 // Characteristic used to receive data from the remote device. |
| 114 device::BluetoothUUID from_peripheral_char_uuid_; | 114 device::BluetoothUUID from_peripheral_char_uuid_; |
| 115 | 115 |
| 116 // The Bluetooth adapter over which the Bluetooth connection will be made. | 116 // 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_; | 134 std::set<device::BluetoothDevice*> pending_connections_; |
| 135 | 135 |
| 136 base::WeakPtrFactory<BluetoothLowEnergyConnectionFinder> weak_ptr_factory_; | 136 base::WeakPtrFactory<BluetoothLowEnergyConnectionFinder> weak_ptr_factory_; |
| 137 | 137 |
| 138 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyConnectionFinder); | 138 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyConnectionFinder); |
| 139 }; | 139 }; |
| 140 | 140 |
| 141 } // namespace proximity_auth | 141 } // namespace proximity_auth |
| 142 | 142 |
| 143 #endif // COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_CONNECTION_FINDER_H | 143 #endif // COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_CONNECTION_FINDER_H |
| OLD | NEW |