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( |