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

Side by Side Diff: content/browser/bluetooth/bluetooth_connected_devices_map.h

Issue 1902153003: bluetooth: Move connect/disconnect to mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-separate-connection-tests
Patch Set: Moar clean up Created 4 years, 7 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_CONNECTED_DEVICES_MAP_H_
6 #define CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_CONNECTED_DEVICES_MAP_H_
7
8 #include <memory>
9 #include <string>
10 #include <unordered_map>
11
12 #include "content/common/content_export.h"
13 #include "url/origin.h"
14
15 namespace device {
16 class BluetoothGattConnection;
17 } // namespace device
18
19 namespace content {
20
21 class WebContents;
22 class WebContentsImpl;
23
24 // Holds information about connected devices and updates the WebContents
25 // when new connections are made or connections closed. WebContents should
Jeffrey Yasskin 2016/05/03 01:15:57 s/should/must/
ortuno 2016/05/03 16:11:53 Done.
26 // outlive this class.
27 // This class does not keep track of the status of the connections. Owners of
28 // this class should inform it when a connection is terminated so that the
29 // connection removed from the appropriate maps.
30 class CONTENT_EXPORT BluetoothConnectedDevicesMap final {
Jeffrey Yasskin 2016/05/03 01:15:57 I think I'd name this "FrameConnectedBluetoothDevi
ortuno 2016/05/03 16:11:53 Done.
31 public:
32 explicit BluetoothConnectedDevicesMap(WebContents* web_contents);
Jeffrey Yasskin 2016/05/03 01:15:57 If this argument flows directly into this->web_con
ortuno 2016/05/03 16:11:53 Done.
33 ~BluetoothConnectedDevicesMap();
34
35 // Returns true if the map holds a connection to |device_id|.
36 bool IsConnectedToDeviceWithId(const std::string& device_id);
37
38 // If a connection doesn't exist already for |device_id| adds a connection to
Jeffrey Yasskin 2016/05/03 01:15:57 Add a comma before "adds".
ortuno 2016/05/03 16:11:53 Done.
39 // the map and increases the WebContents count of connected devices.
40 void Insert(const std::string& device_id,
41 std::unique_ptr<device::BluetoothGattConnection> connection);
42
43 // Deletes the BluetoothGattConnection for |device_id| and decrements the
44 // WebContents count of connected devices if |device_id| had a connection.
45 void CloseConnectionToDeviceWithId(const std::string& device_id);
46
47 // Deletes the BluetoothGattConnection for |device_address| and decrements the
48 // WebContents count of connected devices if |device_address| had a
49 // connection. Returns the device_id of the device associated with the
50 // connection.
51 std::string CloseConnectionToDeviceWithAddress(
52 const std::string& device_address);
53
54 private:
55 // Increments the Connected Devices count of the frame's WebContents.
56 void IncrementDevicesConnectedCount();
57 // Decrements the Connected Devices count of the frame's WebContents.
58 void DecrementDevicesConnectedCount();
59
60 // WebContentsImpl that owns the WebBluetoothServiceImpl that owns this map.
61 WebContentsImpl* web_contents_impl_;
62
63 // Keeps the BluetoothGattConnection objects alive so that connections don't
64 // get closed..
Jeffrey Yasskin 2016/05/03 01:15:57 s/.././
ortuno 2016/05/03 16:11:54 Done.
65 std::unordered_map<std::string,
66 std::unique_ptr<device::BluetoothGattConnection>>
67 device_id_to_connection_map_;
68
69 // Keeps track of which device addresses correspond to which ids.
70 std::unordered_map<std::string, std::string> device_address_to_id_map_;
71
72 DISALLOW_COPY_AND_ASSIGN(BluetoothConnectedDevicesMap);
73 };
74
75 } // namespace content
76
77 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_CONNECTED_DEVICES_MAP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698