#ifndef ASH_WEBUI_ECHE_APP_UI_ECHE_CONNECTION_SCHEDULER_IMPL_H_
#define ASH_WEBUI_ECHE_APP_UI_ECHE_CONNECTION_SCHEDULER_IMPL_H_
#include "ash/webui/eche_app_ui/eche_connection_scheduler.h"
#include "ash/webui/eche_app_ui/feature_status.h"
#include "ash/webui/eche_app_ui/feature_status_provider.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
#include "chromeos/ash/services/secure_channel/public/cpp/client/connection_manager.h"
#include "net/base/backoff_entry.h"
namespace ash {
namespace eche_app {
using ConnectionStatus = secure_channel::ConnectionManager::Status;
class EcheConnectionSchedulerImpl
: public EcheConnectionScheduler,
public FeatureStatusProvider::Observer,
public secure_channel::ConnectionManager::Observer {
public:
EcheConnectionSchedulerImpl(
secure_channel::ConnectionManager* connection_manager,
FeatureStatusProvider* feature_status_provider);
~EcheConnectionSchedulerImpl() override;
void ScheduleConnectionNow() override;
void DisconnectAndClearBackoffAttempts() override;
private:
friend class EcheConnectionSchedulerImplTest;
void OnFeatureStatusChanged() override;
void OnConnectionStatusChanged() override;
void ScheduleConnectionIfNeeded();
void ClearBackoffAttempts();
base::TimeDelta GetCurrentBackoffDelayTimeForTesting();
int GetBackoffFailureCountForTesting();
raw_ptr<secure_channel::ConnectionManager> connection_manager_;
raw_ptr<FeatureStatusProvider> feature_status_provider_;
net::BackoffEntry retry_backoff_;
FeatureStatus current_feature_status_;
ConnectionStatus current_connection_status_;
base::WeakPtrFactory<EcheConnectionSchedulerImpl> weak_ptr_factory_{this};
};
}
}
#endif