| OLD | NEW |
| 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 <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 // Returns the Bluetooth Device's address from |device_id_for_origin|. Returns | 57 // Returns the Bluetooth Device's address from |device_id_for_origin|. Returns |
| 58 // an empty string if the origin is not allowed to access the device. | 58 // an empty string if the origin is not allowed to access the device. |
| 59 const std::string& GetDeviceAddress(const url::Origin& origin, | 59 const std::string& GetDeviceAddress(const url::Origin& origin, |
| 60 const std::string& device_id); | 60 const std::string& device_id); |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 typedef std::map<std::string, std::string> DeviceAddressToIdMap; | 63 typedef std::map<std::string, std::string> DeviceAddressToIdMap; |
| 64 typedef std::map<std::string, std::string> DeviceIdToAddressMap; | 64 typedef std::map<std::string, std::string> DeviceIdToAddressMap; |
| 65 typedef std::map<std::string, std::set<std::string>> DeviceIdToServicesMap; | 65 typedef std::map<std::string, std::set<std::string>> DeviceIdToServicesMap; |
| 66 | 66 |
| 67 // Returns an id guaranteed to be unique for the origin. The id is randomly | 67 // Returns an id guaranteed to be unique for the map. The id is randomly |
| 68 // generated so that an origin can't guess the ID used in another origin. | 68 // generated so that an origin can't guess the ID used in another origin. |
| 69 std::string GenerateDeviceId(const url::Origin& origin); | 69 std::string GenerateDeviceId(const url::Origin& origin); |
| 70 std::set<std::string> UnionOfServices( | 70 std::set<std::string> UnionOfServices( |
| 71 const std::vector<BluetoothScanFilter>& filters, | 71 const std::vector<BluetoothScanFilter>& filters, |
| 72 const std::vector<device::BluetoothUUID>& optional_services); | 72 const std::vector<device::BluetoothUUID>& optional_services); |
| 73 | 73 |
| 74 std::map<url::Origin, DeviceAddressToIdMap> | 74 std::map<url::Origin, DeviceAddressToIdMap> |
| 75 origin_to_device_address_to_id_map_; | 75 origin_to_device_address_to_id_map_; |
| 76 std::map<url::Origin, DeviceIdToAddressMap> | 76 std::map<url::Origin, DeviceIdToAddressMap> |
| 77 origin_to_device_id_to_address_map_; | 77 origin_to_device_id_to_address_map_; |
| 78 std::map<url::Origin, DeviceIdToServicesMap> | 78 std::map<url::Origin, DeviceIdToServicesMap> |
| 79 origin_to_device_id_to_services_map_; | 79 origin_to_device_id_to_services_map_; |
| 80 |
| 81 // Keep track of all device_ids in the map. |
| 82 std::set<std::string> device_id_set_; |
| 80 }; | 83 }; |
| 81 | 84 |
| 82 } // namespace content | 85 } // namespace content |
| 83 | 86 |
| 84 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_ALLOWED_DEVICES_MAP_ | 87 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_ALLOWED_DEVICES_MAP_ |
| OLD | NEW |