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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ 5 #ifndef CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_
6 #define CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ 6 #define CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 protected: 81 protected:
82 ~BluetoothDispatcherHost() override; 82 ~BluetoothDispatcherHost() override;
83 83
84 private: 84 private:
85 friend class base::DeleteHelper<BluetoothDispatcherHost>; 85 friend class base::DeleteHelper<BluetoothDispatcherHost>;
86 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; 86 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>;
87 87
88 struct RequestDeviceSession; 88 struct RequestDeviceSession;
89 struct PrimaryServicesRequest; 89 struct PrimaryServicesRequest;
90 90
91 // Map to keep track of connections. Inserting and removing connections
92 // will update the Web Contents for the frame. Upon destruction
93 // the map will clear Web Contents of Bluetooth connections.
94 struct ConnectedDevicesMap {
95 ConnectedDevicesMap(int render_process_id);
96 ~ConnectedDevicesMap();
97 bool HasActiveConnection(const std::string& device_id);
98 void InsertOrReplace(
99 int frame_routing_id,
100 const std::string& device_id,
101 scoped_ptr<device::BluetoothGattConnection> connection);
102 void Remove(int frame_routing_id, const std::string& device_id);
103 void IncrementBluetoothConnectedDeviceCount(int frame_routing_id);
104 void DecrementBluetoothConnectedDeviceCount(int frame_routing_id);
105
106 int render_process_id_;
107 std::unordered_map<std::string, scoped_ptr<device::BluetoothGattConnection>>
108 device_id_to_connection_map_;
109 // Keeps track of which frame is connected to which device so that
110 // we can clean up the WebContents in our destructor.
111 std::set<std::pair<int, std::string>> frame_ids_device_ids_;
112 };
113
91 // Set |adapter_| to a BluetoothAdapter instance and register observers, 114 // Set |adapter_| to a BluetoothAdapter instance and register observers,
92 // releasing references to previous |adapter_|. 115 // releasing references to previous |adapter_|.
93 void set_adapter(scoped_refptr<device::BluetoothAdapter> adapter); 116 void set_adapter(scoped_refptr<device::BluetoothAdapter> adapter);
94 117
95 // Makes sure a BluetoothDiscoverySession is active for |session|, and resets 118 // Makes sure a BluetoothDiscoverySession is active for |session|, and resets
96 // its timeout. 119 // its timeout.
97 void StartDeviceDiscovery(RequestDeviceSession* session, int chooser_id); 120 void StartDeviceDiscovery(RequestDeviceSession* session, int chooser_id);
98 121
99 // Stops all BluetoothDiscoverySessions being run for requestDevice() 122 // Stops all BluetoothDiscoverySessions being run for requestDevice()
100 // choosers. 123 // choosers.
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 // A BluetoothAdapter instance representing an adapter of the system. 334 // A BluetoothAdapter instance representing an adapter of the system.
312 scoped_refptr<device::BluetoothAdapter> adapter_; 335 scoped_refptr<device::BluetoothAdapter> adapter_;
313 336
314 // Automatically stops Bluetooth discovery a set amount of time after it was 337 // Automatically stops Bluetooth discovery a set amount of time after it was
315 // started. We have a single timer for all of Web Bluetooth because it's 338 // started. We have a single timer for all of Web Bluetooth because it's
316 // simpler than tracking timeouts for each RequestDeviceSession individually, 339 // simpler than tracking timeouts for each RequestDeviceSession individually,
317 // and because there's no harm in extending the length of a few discovery 340 // and because there's no harm in extending the length of a few discovery
318 // sessions when other sessions are active. 341 // sessions when other sessions are active.
319 base::Timer discovery_session_timer_; 342 base::Timer discovery_session_timer_;
320 343
321 // Retain BluetoothGattConnection objects to keep connections open. 344 // Retains BluetoothGattConnection objects to keep connections open.
322 std::map<std::string, scoped_ptr<device::BluetoothGattConnection>> 345 scoped_ptr<ConnectedDevicesMap> connected_devices_map_;
323 device_id_to_connection_map_;
324 346
325 // Map of device_address's to primary-services requests that need responses 347 // Map of device_address's to primary-services requests that need responses
326 // when that device's service discovery completes. 348 // when that device's service discovery completes.
327 std::map<std::string, std::vector<PrimaryServicesRequest>> 349 std::map<std::string, std::vector<PrimaryServicesRequest>>
328 pending_primary_services_requests_; 350 pending_primary_services_requests_;
329 351
330 // |weak_ptr_on_ui_thread_| provides weak pointers, e.g. for callbacks, and 352 // |weak_ptr_on_ui_thread_| provides weak pointers, e.g. for callbacks, and
331 // because it exists and has been bound to the UI thread enforces that all 353 // because it exists and has been bound to the UI thread enforces that all
332 // copies verify they are also used on the UI thread. 354 // copies verify they are also used on the UI thread.
333 base::WeakPtr<BluetoothDispatcherHost> weak_ptr_on_ui_thread_; 355 base::WeakPtr<BluetoothDispatcherHost> weak_ptr_on_ui_thread_;
334 base::WeakPtrFactory<BluetoothDispatcherHost> weak_ptr_factory_; 356 base::WeakPtrFactory<BluetoothDispatcherHost> weak_ptr_factory_;
335 357
336 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcherHost); 358 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcherHost);
337 }; 359 };
338 360
339 } // namespace content 361 } // namespace content
340 362
341 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ 363 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_
OLDNEW
« 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