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

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

Issue 2015463004: bluetooth: Use BluetoothUUID instead of string when sending uuids (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-mojo-request-device
Patch Set: Fix merge conflict Created 4 years, 6 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
« no previous file with comments | « no previous file | content/browser/bluetooth/bluetooth_allowed_devices_map.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_ALLOWED_DEVICES_MAP_ 5 #ifndef CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_ALLOWED_DEVICES_MAP_
6 #define CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_ALLOWED_DEVICES_MAP_ 6 #define CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_ALLOWED_DEVICES_MAP_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
11 #include <unordered_set>
11 #include <vector> 12 #include <vector>
12 13
13 #include "content/common/content_export.h" 14 #include "content/common/content_export.h"
14 #include "third_party/WebKit/public/platform/modules/bluetooth/web_bluetooth.moj om.h" 15 #include "third_party/WebKit/public/platform/modules/bluetooth/web_bluetooth.moj om.h"
15 #include "url/origin.h" 16 #include "url/origin.h"
16 17
17 namespace device { 18 namespace device {
18 class BluetoothUUID; 19 class BluetoothUUID;
19 } 20 }
20 21
(...skipping 30 matching lines...) Expand all
51 const std::string& GetDeviceId(const url::Origin& origin, 52 const std::string& GetDeviceId(const url::Origin& origin,
52 const std::string& device_address); 53 const std::string& device_address);
53 54
54 // For |device_id| in |origin|, returns the Bluetooth device's address. If 55 // For |device_id| in |origin|, returns the Bluetooth device's address. If
55 // there is no such |device_id| in |origin|, returns an empty string. 56 // there is no such |device_id| in |origin|, returns an empty string.
56 const std::string& GetDeviceAddress(const url::Origin& origin, 57 const std::string& GetDeviceAddress(const url::Origin& origin,
57 const std::string& device_id); 58 const std::string& device_id);
58 59
59 // Returns true if the origin has previously been granted access to 60 // Returns true if the origin has previously been granted access to
60 // the service. 61 // the service.
61 bool IsOriginAllowedToAccessService(const url::Origin& origin, 62 bool IsOriginAllowedToAccessService(
62 const std::string& device_id, 63 const url::Origin& origin,
63 const std::string& service_uuid) const; 64 const std::string& device_id,
65 const device::BluetoothUUID& service_uuid) const;
64 66
65 private: 67 private:
66 typedef std::map<std::string, std::string> DeviceAddressToIdMap; 68 typedef std::map<std::string, std::string> DeviceAddressToIdMap;
67 typedef std::map<std::string, std::string> DeviceIdToAddressMap; 69 typedef std::map<std::string, std::string> DeviceIdToAddressMap;
68 typedef std::map<std::string, std::set<std::string>> DeviceIdToServicesMap; 70 typedef std::map<
71 std::string,
72 std::unordered_set<device::BluetoothUUID, device::BluetoothUUIDHash>>
73 DeviceIdToServicesMap;
69 74
70 // Returns an id guaranteed to be unique for the map. The id is randomly 75 // Returns an id guaranteed to be unique for the map. The id is randomly
71 // generated so that an origin can't guess the id used in another origin. 76 // generated so that an origin can't guess the id used in another origin.
72 std::string GenerateDeviceId(); 77 std::string GenerateDeviceId();
73 void AddUnionOfServicesTo( 78 void AddUnionOfServicesTo(
74 const blink::mojom::WebBluetoothRequestDeviceOptionsPtr& options, 79 const blink::mojom::WebBluetoothRequestDeviceOptionsPtr& options,
75 std::set<std::string>* unionOfServices); 80 std::unordered_set<device::BluetoothUUID, device::BluetoothUUIDHash>*
81 unionOfServices);
76 82
77 // TODO(ortuno): Now that there is only one instance of this class per frame 83 // TODO(ortuno): Now that there is only one instance of this class per frame
78 // and that this map gets destroyed when navigating consider removing the 84 // and that this map gets destroyed when navigating consider removing the
79 // origin mapping. 85 // origin mapping.
80 // http://crbug.com/610343 86 // http://crbug.com/610343
81 std::map<url::Origin, DeviceAddressToIdMap> 87 std::map<url::Origin, DeviceAddressToIdMap>
82 origin_to_device_address_to_id_map_; 88 origin_to_device_address_to_id_map_;
83 std::map<url::Origin, DeviceIdToAddressMap> 89 std::map<url::Origin, DeviceIdToAddressMap>
84 origin_to_device_id_to_address_map_; 90 origin_to_device_id_to_address_map_;
85 std::map<url::Origin, DeviceIdToServicesMap> 91 std::map<url::Origin, DeviceIdToServicesMap>
86 origin_to_device_id_to_services_map_; 92 origin_to_device_id_to_services_map_;
87 93
88 // Keep track of all device_ids in the map. 94 // Keep track of all device_ids in the map.
89 std::set<std::string> device_id_set_; 95 std::set<std::string> device_id_set_;
90 }; 96 };
91 97
92 } // namespace content 98 } // namespace content
93 99
94 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_ALLOWED_DEVICES_MAP_ 100 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_ALLOWED_DEVICES_MAP_
OLDNEW
« no previous file with comments | « no previous file | content/browser/bluetooth/bluetooth_allowed_devices_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698