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 CHROMEOS_COMPONENTS_TETHER_BLE_ADVERTISEMENT_DEVICE_QUEUE_H_ | 5 #ifndef CHROMEOS_COMPONENTS_TETHER_BLE_ADVERTISEMENT_DEVICE_QUEUE_H_ |
6 #define CHROMEOS_COMPONENTS_TETHER_BLE_ADVERTISEMENT_DEVICE_QUEUE_H_ | 6 #define CHROMEOS_COMPONENTS_TETHER_BLE_ADVERTISEMENT_DEVICE_QUEUE_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "components/cryptauth/remote_device.h" | 11 #include "components/cryptauth/remote_device.h" |
12 | 12 |
13 namespace chromeos { | 13 namespace chromeos { |
14 | 14 |
15 namespace tether { | 15 namespace tether { |
16 | 16 |
17 // Queue of devices to which to advertise. Because only | 17 // Queue of devices to which to advertise. Because only |
18 // |kMaxConcurrentAdvertisements| devices can be advertised to concurrently, | 18 // |kMaxConcurrentAdvertisements| devices can be advertised to concurrently, |
19 // this queue maintains the order of devices to ensure that each device gets its | 19 // this queue maintains the order of devices to ensure that each device gets its |
20 // fair share of time spent contacting it. | 20 // fair share of time spent contacting it. |
21 class BleAdvertisementDeviceQueue { | 21 class BleAdvertisementDeviceQueue { |
22 public: | 22 public: |
23 // The maximum number of devices to which to advertise concurrently. If more | |
24 // than this number of devices are registered, some advertisement must be | |
25 // stopped before new ones can be added. | |
26 // | |
27 // Note that this upper limit on concurrent advertisements is imposed due to a | |
28 // hardware limit of advertisements. | |
29 static const int kMaxConcurrentAdvertisements; | |
30 | |
31 BleAdvertisementDeviceQueue(); | 23 BleAdvertisementDeviceQueue(); |
32 virtual ~BleAdvertisementDeviceQueue(); | 24 virtual ~BleAdvertisementDeviceQueue(); |
33 | 25 |
34 // Updates the queue with the given |devices|. Devices which are already in | 26 // Updates the queue with the given |devices|. Devices which are already in |
35 // the queue and are not in |devices| are removed from the queue, and all | 27 // the queue and are not in |devices| are removed from the queue, and all |
36 // devices which are not in the queue but are in |devices| are added to the | 28 // devices which are not in the queue but are in |devices| are added to the |
37 // end of the queue. Note devices that are already in the queue will not | 29 // end of the queue. Note devices that are already in the queue will not |
38 // change order as a result of this function being called to ensure that the | 30 // change order as a result of this function being called to ensure that the |
39 // queue remains in order. Returns whether the device list has changed due to | 31 // queue remains in order. Returns whether the device list has changed due to |
40 // the function call. | 32 // the function call. |
(...skipping 14 matching lines...) Expand all Loading... |
55 std::vector<cryptauth::RemoteDevice> device_queue_; | 47 std::vector<cryptauth::RemoteDevice> device_queue_; |
56 | 48 |
57 DISALLOW_COPY_AND_ASSIGN(BleAdvertisementDeviceQueue); | 49 DISALLOW_COPY_AND_ASSIGN(BleAdvertisementDeviceQueue); |
58 }; | 50 }; |
59 | 51 |
60 } // namespace tether | 52 } // namespace tether |
61 | 53 |
62 } // namespace chromeos | 54 } // namespace chromeos |
63 | 55 |
64 #endif // CHROMEOS_COMPONENTS_TETHER_BLE_ADVERTISEMENT_DEVICE_QUEUE_H_ | 56 #endif // CHROMEOS_COMPONENTS_TETHER_BLE_ADVERTISEMENT_DEVICE_QUEUE_H_ |
OLD | NEW |