Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(746)

Unified Diff: device/bluetooth/bluetooth_device_chromeos.cc

Issue 1341103004: Handle change of BLE address after pairing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ***ADDED BY MISTAKE, OMMIT *** Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/bluetooth/bluetooth_device_chromeos.h ('k') | device/bluetooth/bluetooth_gatt_chromeos_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/bluetooth_device_chromeos.cc
diff --git a/device/bluetooth/bluetooth_device_chromeos.cc b/device/bluetooth/bluetooth_device_chromeos.cc
index 2b27d9da2c4bab7a00ae7d35bc8397d10de3e550..c3fdbc43e609af9ef465771b867e978071c92c7b 100644
--- a/device/bluetooth/bluetooth_device_chromeos.cc
+++ b/device/bluetooth/bluetooth_device_chromeos.cc
@@ -201,16 +201,18 @@ std::string BluetoothDeviceChromeOS::GetDeviceName() const {
return properties->alias.value();
}
-void BluetoothDeviceChromeOS::CreateGattConnectionImpl() {
+scoped_ptr<device::BluetoothGattConnection>
+BluetoothDeviceChromeOS::CreateGattConnectionImpl() {
// ChromeOS implementation does not use the default CreateGattConnection
// implementation.
NOTIMPLEMENTED();
+ return NULL;
}
+void EmptyCB() {}
+
void BluetoothDeviceChromeOS::DisconnectGatt() {
- // ChromeOS implementation does not use the default CreateGattConnection
- // implementation.
- NOTIMPLEMENTED();
+ Disconnect(base::Bind(EmptyCB), base::Bind(EmptyCB));
}
std::string BluetoothDeviceChromeOS::GetAddress() const {
@@ -490,26 +492,43 @@ void BluetoothDeviceChromeOS::ConnectToServiceInsecurely(
base::Bind(callback, socket), error_callback);
}
-void BluetoothDeviceChromeOS::CreateGattConnection(
- const GattConnectionCallback& callback,
- const ConnectErrorCallback& error_callback) {
+scoped_ptr<device::BluetoothGattConnection>
+BluetoothDeviceChromeOS::ExistingGattConnection() {
+ DCHECK(IsConnected());
+ return make_scoped_ptr(new BluetoothGattConnectionChromeOS(
+ adapter_, GetAddress(), object_path_, false));
+}
+
+scoped_ptr<device::BluetoothGattConnection>
+BluetoothDeviceChromeOS::CreateGattConnection(
+ const GattConnectionCallback& callback,
+ const ConnectErrorCallback& error_callback) {
// TODO(sacomoto): Workaround to retrieve the connection for already connected
// devices. Currently, BluetoothGattConnection::Disconnect doesn't do
// anything, the unique underlying physical GATT connection is kept. This
// should be removed once the correct behavour is implemented and the GATT
// connections are reference counted (see todo below).
if (IsConnected()) {
- OnCreateGattConnection(callback);
- return;
+ scoped_ptr<device::BluetoothGattConnection> conn(
+ new BluetoothGattConnectionChromeOS(adapter_, GetAddress(),
+ object_path_, false));
+
+ OnCreateGattConnection(conn.get(), callback);
+ return conn.Pass();
}
+ scoped_ptr<device::BluetoothGattConnection> conn(
+ new BluetoothGattConnectionChromeOS(adapter_, GetAddress(), object_path_,
+ true));
+
// TODO(armansito): Until there is a way to create a reference counted GATT
// connection in bluetoothd, simply do a regular connect.
Connect(NULL,
base::Bind(&BluetoothDeviceChromeOS::OnCreateGattConnection,
- weak_ptr_factory_.GetWeakPtr(),
- callback),
+ weak_ptr_factory_.GetWeakPtr(), conn.get(), callback),
error_callback);
+
+ return conn.Pass();
}
BluetoothPairingChromeOS* BluetoothDeviceChromeOS::BeginPairing(
@@ -636,11 +655,9 @@ void BluetoothDeviceChromeOS::OnConnect(bool after_pairing,
}
void BluetoothDeviceChromeOS::OnCreateGattConnection(
+ device::BluetoothGattConnection* conn,
const GattConnectionCallback& callback) {
- scoped_ptr<device::BluetoothGattConnection> conn(
- new BluetoothGattConnectionChromeOS(
- adapter_, GetAddress(), object_path_));
- callback.Run(conn.Pass());
+ callback.Run();
}
void BluetoothDeviceChromeOS::OnConnectError(
« no previous file with comments | « device/bluetooth/bluetooth_device_chromeos.h ('k') | device/bluetooth/bluetooth_gatt_chromeos_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698