eche_connection_scheduler.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright 2022 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. #ifndef ASH_WEBUI_ECHE_APP_UI_ECHE_CONNECTION_SCHEDULER_H_
  5. #define ASH_WEBUI_ECHE_APP_UI_ECHE_CONNECTION_SCHEDULER_H_
  6. namespace ash {
  7. namespace eche_app {
  8. // Responsible for requesting connection from the local device
  9. // (e.g. this chromebook) to the user's phone. Will also attempt to connect
  10. // whenever possible and retries upon error with exponential backoff.
  11. class EcheConnectionScheduler {
  12. public:
  13. EcheConnectionScheduler(const EcheConnectionScheduler&) = delete;
  14. EcheConnectionScheduler& operator=(const EcheConnectionScheduler&) = delete;
  15. virtual ~EcheConnectionScheduler() = default;
  16. // Attempts a connection immediately, will be exponentially backed-off upon
  17. // failing to establish a connection.
  18. virtual void ScheduleConnectionNow() = 0;
  19. // Invalidate all pending backoff attempts and disconnects the current
  20. // connection attempt.
  21. virtual void DisconnectAndClearBackoffAttempts() = 0;
  22. protected:
  23. EcheConnectionScheduler() = default;
  24. };
  25. } // namespace eche_app
  26. } // namespace ash
  27. #endif // ASH_WEBUI_ECHE_APP_UI_ECHE_CONNECTION_SCHEDULER_H_