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 COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_THROTTLER_H | 5 #ifndef COMPONENTS_CRYPTAUTH_BLUETOOTH_THROTTLER_H |
6 #define COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_THROTTLER_H | 6 #define COMPONENTS_CRYPTAUTH_BLUETOOTH_THROTTLER_H |
7 | 7 |
8 namespace base { | 8 namespace base { |
9 class TimeDelta; | 9 class TimeDelta; |
10 } | 10 } |
11 | 11 |
12 namespace proximity_auth { | 12 namespace cryptauth { |
13 | 13 |
14 class Connection; | 14 class Connection; |
15 | 15 |
16 // An interface for throttling repeated connection attempts to the same device. | 16 // An interface for throttling repeated connection attempts to the same device. |
17 // This throttling is necessary to prevent a kernel race condition when | 17 // This throttling is necessary to prevent a kernel race condition when |
18 // connecting before the previous connection fully closes, putting the | 18 // connecting before the previous connection fully closes, putting the |
19 // connection in a corrupted, and unrecoverable state. http://crbug.com/345232 | 19 // connection in a corrupted, and unrecoverable state. http://crbug.com/345232 |
20 class BluetoothThrottler { | 20 class BluetoothThrottler { |
21 public: | 21 public: |
22 virtual ~BluetoothThrottler() {} | 22 virtual ~BluetoothThrottler() {} |
23 | 23 |
24 // Returns the current delay that must be respected prior to reattempting to | 24 // Returns the current delay that must be respected prior to reattempting to |
25 // establish a connection with the remote device. The returned value is 0 if | 25 // establish a connection with the remote device. The returned value is 0 if |
26 // no delay is needed. | 26 // no delay is needed. |
27 virtual base::TimeDelta GetDelay() const = 0; | 27 virtual base::TimeDelta GetDelay() const = 0; |
28 | 28 |
29 // Should be called when a connection to the remote device is established. | 29 // Should be called when a connection to the remote device is established. |
30 // Note that the |connection| is passed as a weak reference. The throttler | 30 // Note that the |connection| is passed as a weak reference. The throttler |
31 // will ensure, by registering as an observer, that it never attempts to use | 31 // will ensure, by registering as an observer, that it never attempts to use |
32 // the connection after it has been destroyed. | 32 // the connection after it has been destroyed. |
33 virtual void OnConnection(Connection* connection) = 0; | 33 virtual void OnConnection(Connection* connection) = 0; |
34 }; | 34 }; |
35 | 35 |
36 } // namespace proximity_auth | 36 } // namespace cryptauth |
37 | 37 |
38 #endif // COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_THROTTLER_H | 38 #endif // COMPONENTS_CRYPTAUTH_BLUETOOTH_THROTTLER_H |
OLD | NEW |