| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_THROTTLER_H | |
| 6 #define COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_THROTTLER_H | |
| 7 | |
| 8 namespace base { | |
| 9 class TimeDelta; | |
| 10 } | |
| 11 | |
| 12 namespace proximity_auth { | |
| 13 | |
| 14 class Connection; | |
| 15 | |
| 16 // An interface for throttling repeated connection attempts to the same device. | |
| 17 // This throttling is necessary to prevent a kernel race condition when | |
| 18 // connecting before the previous connection fully closes, putting the | |
| 19 // connection in a corrupted, and unrecoverable state. http://crbug.com/345232 | |
| 20 class BluetoothThrottler { | |
| 21 public: | |
| 22 virtual ~BluetoothThrottler() {} | |
| 23 | |
| 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 | |
| 26 // no delay is needed. | |
| 27 virtual base::TimeDelta GetDelay() const = 0; | |
| 28 | |
| 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 | |
| 31 // will ensure, by registering as an observer, that it never attempts to use | |
| 32 // the connection after it has been destroyed. | |
| 33 virtual void OnConnection(Connection* connection) = 0; | |
| 34 }; | |
| 35 | |
| 36 } // namespace proximity_auth | |
| 37 | |
| 38 #endif // COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_THROTTLER_H | |
| OLD | NEW |