Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(535)

Side by Side Diff: components/proximity_auth/bluetooth_throttler_impl.h

Issue 663693002: [Easy Unlock] Port the BluetoothThrottler class to native code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_IMPL_H
6 #define COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_THROTTLER_IMPL_H
7
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/time/time.h"
11 #include "components/proximity_auth/bluetooth_throttler.h"
12
13 namespace base {
14 class TickClock;
15 }
16
17 namespace proximity_auth {
18
19 // This class throttles repeated connection attempts to the same device. This
20 // throttling is necessary to prevent a kernel race condition when connecting
21 // before the previous connection fully closes, putting the connection in a
22 // corrupted, and unrecoverable state. http://crbug.com/345232
23 class BluetoothThrottlerImpl : public BluetoothThrottler {
24 public:
25 // Creates a throttler for connections to a remote device, using the |clock|
26 // as a time source.
27 explicit BluetoothThrottlerImpl(scoped_ptr<base::TickClock> clock);
28 ~BluetoothThrottlerImpl() override;
29
30 // BluetoothThrottler:
31 base::TimeDelta GetDelay() const override;
32 void OnConnectionClosed() override;
33
34 protected:
35 // Returns the duration to wait, after disconnecting, before reattempting a
36 // connection to the remote device. Exposed for testing.
37 base::TimeDelta GetCooldownTimeDelta() const;
38
39 private:
40 // Tracks the last seen disconnect time for the |remote_device_|.
41 base::TimeTicks last_disconnect_time_;
42
43 // The time source.
44 scoped_ptr<base::TickClock> clock_;
45
46 DISALLOW_COPY_AND_ASSIGN(BluetoothThrottlerImpl);
47 };
48
49 } // namespace proximity_auth
50
51 #endif // COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_THROTTLER_IMPL_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698