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

Unified Diff: content/browser/bluetooth/bluetooth_dispatcher_host.h

Issue 1848663002: bluetooth: Remove indicator only when there are no more devices connected (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Fix format" Created 4 years, 8 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 | « chrome/browser/ui/tabs/tab_utils.cc ('k') | content/browser/bluetooth/bluetooth_dispatcher_host.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/bluetooth/bluetooth_dispatcher_host.h
diff --git a/content/browser/bluetooth/bluetooth_dispatcher_host.h b/content/browser/bluetooth/bluetooth_dispatcher_host.h
index 9b40d654238af081e0aec99816e81ec6f674e0bd..e3a4d6178bd8ab617f2025ca8a75140bfb2ea847 100644
--- a/content/browser/bluetooth/bluetooth_dispatcher_host.h
+++ b/content/browser/bluetooth/bluetooth_dispatcher_host.h
@@ -88,6 +88,29 @@ class CONTENT_EXPORT BluetoothDispatcherHost final
struct RequestDeviceSession;
struct PrimaryServicesRequest;
+ // Map to keep track of connections. Inserting and removing connections
+ // will update the Web Contents for the frame. Upon destruction
+ // the map will clear Web Contents of Bluetooth connections.
+ struct ConnectedDevicesMap {
+ ConnectedDevicesMap(int render_process_id);
+ ~ConnectedDevicesMap();
+ bool HasActiveConnection(const std::string& device_id);
+ void InsertOrReplace(
+ int frame_routing_id,
+ const std::string& device_id,
+ scoped_ptr<device::BluetoothGattConnection> connection);
+ void Remove(int frame_routing_id, const std::string& device_id);
+ void IncrementBluetoothConnectedDeviceCount(int frame_routing_id);
+ void DecrementBluetoothConnectedDeviceCount(int frame_routing_id);
+
+ int render_process_id_;
+ std::unordered_map<std::string, scoped_ptr<device::BluetoothGattConnection>>
+ device_id_to_connection_map_;
+ // Keeps track of which frame is connected to which device so that
+ // we can clean up the WebContents in our destructor.
+ std::set<std::pair<int, std::string>> frame_ids_device_ids_;
+ };
+
// Set |adapter_| to a BluetoothAdapter instance and register observers,
// releasing references to previous |adapter_|.
void set_adapter(scoped_refptr<device::BluetoothAdapter> adapter);
@@ -318,9 +341,8 @@ class CONTENT_EXPORT BluetoothDispatcherHost final
// sessions when other sessions are active.
base::Timer discovery_session_timer_;
- // Retain BluetoothGattConnection objects to keep connections open.
- std::map<std::string, scoped_ptr<device::BluetoothGattConnection>>
- device_id_to_connection_map_;
+ // Retains BluetoothGattConnection objects to keep connections open.
+ scoped_ptr<ConnectedDevicesMap> connected_devices_map_;
// Map of device_address's to primary-services requests that need responses
// when that device's service discovery completes.
« no previous file with comments | « chrome/browser/ui/tabs/tab_utils.cc ('k') | content/browser/bluetooth/bluetooth_dispatcher_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698