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

Unified Diff: content/browser/bluetooth/frame_connected_bluetooth_devices.cc

Issue 2713593003: Address some TODOs at frame_connected_bluetooth_devices.cc (Closed)
Patch Set: address comment Created 3 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/bluetooth/frame_connected_bluetooth_devices.cc
diff --git a/content/browser/bluetooth/frame_connected_bluetooth_devices.cc b/content/browser/bluetooth/frame_connected_bluetooth_devices.cc
index 7187609453ccdabce09be39b060ad456eceadbfe..d469a50f0e21b21d3ad3b963c5ebdad13b2a93bd 100644
--- a/content/browser/bluetooth/frame_connected_bluetooth_devices.cc
+++ b/content/browser/bluetooth/frame_connected_bluetooth_devices.cc
@@ -29,45 +29,25 @@ bool FrameConnectedBluetoothDevices::IsConnectedToDeviceWithId(
if (connection_iter == device_id_to_connection_map_.end()) {
return false;
}
- // Owners of FrameConnectedBluetoothDevices should notify it when a device
- // disconnects but currently Android and Mac don't notify of disconnection,
- // so the map could get into a state where it's holding a stale connection.
- // For this reason we return the value of IsConnected for the connection.
- // TODO(ortuno): Always return true once Android and Mac notify of
- // disconnection.
- // http://crbug.com/607273
- return connection_iter->second->IsConnected();
+ DCHECK(connection_iter->second->IsConnected());
+ return true;
}
void FrameConnectedBluetoothDevices::Insert(
const WebBluetoothDeviceId& device_id,
std::unique_ptr<device::BluetoothGattConnection> connection) {
- auto connection_iter = device_id_to_connection_map_.find(device_id);
- if (connection_iter != device_id_to_connection_map_.end()) {
- // Owners of FrameConnectedBluetoothDevices should notify it when a device
- // disconnects but currently Android and Mac don't notify of disconnection,
- // so the map could get into a state where it's holding a stale connection.
- // For this reason we check if the current connection is active and if
- // not we remove it.
- // TODO(ortuno): Remove once Android and Mac notify of disconnection.
- // http://crbug.com/607273
- if (!connection_iter->second->IsConnected()) {
- device_address_to_id_map_.erase(
- connection_iter->second->GetDeviceAddress());
- device_id_to_connection_map_.erase(connection_iter);
- DecrementDevicesConnectedCount();
- } else {
- // It's possible for WebBluetoothServiceImpl to issue two successive
- // connection requests for which it would get two successive responses
- // and consequently try to insert two BluetoothGattConnections for the
- // same device. WebBluetoothServiceImpl should reject or queue connection
- // requests if there is a pending connection already, but the platform
- // abstraction doesn't currently support checking for pending connections.
- // TODO(ortuno): CHECK that this never happens once the platform
- // abstraction allows to check for pending connections.
- // http://crbug.com/583544
- return;
- }
+ if (device_id_to_connection_map_.find(device_id) !=
+ device_id_to_connection_map_.end()) {
+ // It's possible for WebBluetoothServiceImpl to issue two successive
+ // connection requests for which it would get two successive responses
+ // and consequently try to insert two BluetoothGattConnections for the
+ // same device. WebBluetoothServiceImpl should reject or queue connection
+ // requests if there is a pending connection already, but the platform
+ // abstraction doesn't currently support checking for pending connections.
+ // TODO(ortuno): CHECK that this never happens once the platform
+ // abstraction allows to check for pending connections.
+ // http://crbug.com/583544
+ return;
}
device_address_to_id_map_[connection->GetDeviceAddress()] = device_id;
device_id_to_connection_map_[device_id] = std::move(connection);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698