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

Unified Diff: components/cryptauth/bluetooth_throttler_impl.h

Issue 2805113002: [CrOS Tether] Make BluetoothThrottler a singleton which can be easily shared between EasyUnlock and… (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
Index: components/cryptauth/bluetooth_throttler_impl.h
diff --git a/components/cryptauth/bluetooth_throttler_impl.h b/components/cryptauth/bluetooth_throttler_impl.h
index 2933f1681193e391cc8a9020dbd8c236d6b778a2..7a9fef028f094000ef4e92a1debb09dfe9da420f 100644
--- a/components/cryptauth/bluetooth_throttler_impl.h
+++ b/components/cryptauth/bluetooth_throttler_impl.h
@@ -9,6 +9,7 @@
#include <set>
#include "base/macros.h"
+#include "base/memory/singleton.h"
#include "base/time/time.h"
#include "components/cryptauth/bluetooth_throttler.h"
#include "components/cryptauth/connection_observer.h"
@@ -28,9 +29,7 @@ class Connection;
class BluetoothThrottlerImpl : public BluetoothThrottler,
public ConnectionObserver {
public:
- // Creates a throttler for connections to a remote device, using the |clock|
- // as a time source.
- explicit BluetoothThrottlerImpl(std::unique_ptr<base::TickClock> clock);
+ static BluetoothThrottlerImpl* GetInstance();
Tim Song 2017/04/06 23:38:12 I would put this singleton getter in bluetooth_thr
~BluetoothThrottlerImpl() override;
// BluetoothThrottler:
@@ -38,11 +37,19 @@ class BluetoothThrottlerImpl : public BluetoothThrottler,
void OnConnection(Connection* connection) override;
protected:
+ // Creates a throttler for connections to a remote device, using the |clock|
+ // as a time source.
+ explicit BluetoothThrottlerImpl(std::unique_ptr<base::TickClock> clock);
+
// Returns the duration to wait, after disconnecting, before reattempting a
// connection to the remote device. Exposed for testing.
base::TimeDelta GetCooldownTimeDelta() const;
private:
+ friend struct base::DefaultSingletonTraits<BluetoothThrottlerImpl>;
+
+ BluetoothThrottlerImpl();
+
// ConnectionObserver:
void OnConnectionStatusChanged(Connection* connection,
Connection::Status old_status,

Powered by Google App Engine
This is Rietveld 408576698