OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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_BLACKLIST_H_ | 5 #ifndef CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_BLACKLIST_H_ |
6 #define CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_BLACKLIST_H_ | 6 #define CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_BLACKLIST_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 ~BluetoothBlacklist(); | 38 ~BluetoothBlacklist(); |
39 | 39 |
40 // Returns a singleton instance of the blacklist. | 40 // Returns a singleton instance of the blacklist. |
41 static BluetoothBlacklist& Get(); | 41 static BluetoothBlacklist& Get(); |
42 | 42 |
43 // Adds a UUID to the blacklist to be excluded from operations. Crash if the | 43 // Adds a UUID to the blacklist to be excluded from operations. Crash if the |
44 // UUID is already in the blacklist. | 44 // UUID is already in the blacklist. |
45 void AddOrDie(const device::BluetoothUUID&, Value); | 45 void AddOrDie(const device::BluetoothUUID&, Value); |
46 | 46 |
47 // Returns if a UUID is excluded from all operations. | 47 // Returns if a UUID is excluded from all operations. UUID must be valid. |
48 bool IsExcluded(const device::BluetoothUUID&) const; | 48 bool IsExcluded(const device::BluetoothUUID&) const; |
49 | 49 |
50 // Returns if any UUID in a set of filters is excluded from all operations. | 50 // Returns if any UUID in a set of filters is excluded from all operations. |
| 51 // UUID must be valid. |
51 bool IsExcluded(const std::vector<content::BluetoothScanFilter>&); | 52 bool IsExcluded(const std::vector<content::BluetoothScanFilter>&); |
52 | 53 |
53 // Returns if a UUID is excluded from read operations. | 54 // Returns if a UUID is excluded from read operations. UUID must be valid. |
54 bool IsExcludedFromReads(const device::BluetoothUUID&) const; | 55 bool IsExcludedFromReads(const device::BluetoothUUID&) const; |
55 | 56 |
56 // Returns if a UUID is excluded from write operations. | 57 // Returns if a UUID is excluded from write operations. UUID must be valid. |
57 bool IsExcludedFromWrites(const device::BluetoothUUID&) const; | 58 bool IsExcludedFromWrites(const device::BluetoothUUID&) const; |
58 | 59 |
59 // Modifies a list of UUIDs, removing any UUIDs with Value::EXCLUDE. | 60 // Modifies a list of UUIDs, removing any UUIDs with Value::EXCLUDE. |
60 void RemoveExcludedUuids(std::vector<device::BluetoothUUID>*); | 61 void RemoveExcludedUuids(std::vector<device::BluetoothUUID>*); |
61 | 62 |
62 // Size of blacklist. | 63 // Size of blacklist. |
63 size_t size() { return blacklisted_uuids_.size(); } | 64 size_t size() { return blacklisted_uuids_.size(); } |
64 | 65 |
65 void ResetToDefaultValuesForTest(); | 66 void ResetToDefaultValuesForTest(); |
66 | 67 |
67 private: | 68 private: |
68 // friend LazyInstance to permit access to private constructor. | 69 // friend LazyInstance to permit access to private constructor. |
69 friend base::DefaultLazyInstanceTraits<BluetoothBlacklist>; | 70 friend base::DefaultLazyInstanceTraits<BluetoothBlacklist>; |
70 | 71 |
71 BluetoothBlacklist(); | 72 BluetoothBlacklist(); |
72 | 73 |
73 void PopulateWithDefaultValues(); | 74 void PopulateWithDefaultValues(); |
74 | 75 |
75 // Map of UUID to blacklisted value. | 76 // Map of UUID to blacklisted value. |
76 std::map<device::BluetoothUUID, Value> blacklisted_uuids_; | 77 std::map<device::BluetoothUUID, Value> blacklisted_uuids_; |
77 | 78 |
78 DISALLOW_COPY_AND_ASSIGN(BluetoothBlacklist); | 79 DISALLOW_COPY_AND_ASSIGN(BluetoothBlacklist); |
79 }; | 80 }; |
80 | 81 |
81 } // namespace content | 82 } // namespace content |
82 | 83 |
83 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_BLACKLIST_H_ | 84 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_BLACKLIST_H_ |
OLD | NEW |