Chromium Code Reviews| 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, |