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

Unified Diff: chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_event_router.cc

Issue 1287753002: bluetooth: Remove callback from BluetoothGattConnection::Disconnect (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge TOT 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
Index: chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_event_router.cc
diff --git a/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_event_router.cc b/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_event_router.cc
index cd4d2d53d0c658f89db547e963c0ec6ecf7a6fe8..32bfdd14ada7a04342c8a9803c11a06cafdb9ef3 100644
--- a/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_event_router.cc
+++ b/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_event_router.cc
@@ -302,12 +302,6 @@ void BluetoothLowEnergyEventRouter::Disconnect(
}
const std::string extension_id = extension->id();
- const std::string disconnect_id = extension_id + device_address;
-
- if (disconnecting_devices_.count(disconnect_id) != 0) {
- error_callback.Run(kStatusErrorInProgress);
- return;
- }
BluetoothLowEnergyConnection* conn =
FindConnection(extension_id, device_address);
@@ -317,13 +311,15 @@ void BluetoothLowEnergyEventRouter::Disconnect(
return;
}
- disconnecting_devices_.insert(disconnect_id);
- conn->GetConnection()->Disconnect(
- base::Bind(&BluetoothLowEnergyEventRouter::OnDisconnect,
- weak_ptr_factory_.GetWeakPtr(),
- extension_id,
- device_address,
- callback));
+ conn->GetConnection()->Disconnect();
+ VLOG(2) << "GATT connection terminated.";
+
+ if (!RemoveConnection(extension_id, device_address)) {
+ VLOG(1) << "The connection was removed before disconnect completed, id: "
+ << extension_id << ", device: " << device_address;
+ }
+
+ callback.Run();
}
bool BluetoothLowEnergyEventRouter::GetServices(
@@ -1281,24 +1277,6 @@ void BluetoothLowEnergyEventRouter::OnCreateGattConnection(
callback.Run();
}
-void BluetoothLowEnergyEventRouter::OnDisconnect(
- const std::string& extension_id,
- const std::string& device_address,
- const base::Closure& callback) {
- VLOG(2) << "GATT connection terminated.";
-
- const std::string disconnect_id = extension_id + device_address;
- DCHECK_NE(0U, disconnecting_devices_.count(disconnect_id));
-
- if (!RemoveConnection(extension_id, device_address)) {
- VLOG(1) << "The connection was removed before disconnect completed, id: "
- << extension_id << ", device: " << device_address;
- }
-
- disconnecting_devices_.erase(disconnect_id);
- callback.Run();
-}
-
void BluetoothLowEnergyEventRouter::OnError(
const ErrorCallback& error_callback,
BluetoothGattService::GattErrorCode error_code) {

Powered by Google App Engine
This is Rietveld 408576698