#ifndef CHROMEOS_ASH_COMPONENTS_PHONEHUB_CONNECTION_SCHEDULER_IMPL_H_
#define CHROMEOS_ASH_COMPONENTS_PHONEHUB_CONNECTION_SCHEDULER_IMPL_H_
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
#include "chromeos/ash/components/phonehub/connection_scheduler.h"
#include "chromeos/ash/components/phonehub/feature_status.h"
#include "chromeos/ash/components/phonehub/feature_status_provider.h"
#include "chromeos/ash/components/phonehub/phone_hub_structured_metrics_logger.h"
#include "net/base/backoff_entry.h"
namespace ash {
namespace secure_channel {
class ConnectionManager;
}
namespace phonehub {
class ConnectionSchedulerImpl : public ConnectionScheduler,
public FeatureStatusProvider::Observer {
public:
ConnectionSchedulerImpl(
secure_channel::ConnectionManager* connection_manager,
FeatureStatusProvider* feature_status_provider,
PhoneHubStructuredMetricsLogger* phone_hub_structured_metrics_logger);
~ConnectionSchedulerImpl() override;
void ScheduleConnectionNow(DiscoveryEntryPoint entry_point) override;
private:
friend class ConnectionSchedulerImplTest;
void OnFeatureStatusChanged() override;
void DisconnectAndClearBackoffAttempts();
void ClearBackoffAttempts();
base::TimeDelta GetCurrentBackoffDelayTimeForTesting();
int GetBackoffFailureCountForTesting();
raw_ptr<secure_channel::ConnectionManager> connection_manager_;
raw_ptr<FeatureStatusProvider> feature_status_provider_;
raw_ptr<PhoneHubStructuredMetricsLogger> phone_hub_structured_metrics_logger_;
net::BackoffEntry retry_backoff_;
FeatureStatus current_feature_status_;
base::WeakPtrFactory<ConnectionSchedulerImpl> weak_ptr_factory_{this};
};
}
}
#endif