mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-04 20:03:45 +00:00
Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run: git remote add om-historic [om-historic.git repo url] git fetch --tags om-historic git replace squashed-history historic-commits
This commit is contained in:
44
storage/downloading_policy.hpp
Normal file
44
storage/downloading_policy.hpp
Normal file
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#include "storage/storage_defines.hpp"
|
||||
|
||||
#include "base/deferred_task.hpp"
|
||||
|
||||
#include <chrono>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
class DownloadingPolicy
|
||||
{
|
||||
public:
|
||||
using TProcessFunc = std::function<void(storage::CountriesSet const &)>;
|
||||
virtual ~DownloadingPolicy() = default;
|
||||
virtual bool IsDownloadingAllowed() { return true; }
|
||||
virtual void ScheduleRetry(storage::CountriesSet const &, TProcessFunc const &) {}
|
||||
};
|
||||
|
||||
class StorageDownloadingPolicy : public DownloadingPolicy
|
||||
{
|
||||
bool m_cellularDownloadEnabled = false;
|
||||
bool m_downloadRetryFailed = false;
|
||||
static size_t constexpr kAutoRetryCounterMax = 3;
|
||||
size_t m_autoRetryCounter = kAutoRetryCounterMax;
|
||||
base::DeferredTask m_autoRetryWorker;
|
||||
|
||||
std::chrono::time_point<std::chrono::steady_clock> m_disableCellularTime;
|
||||
|
||||
public:
|
||||
StorageDownloadingPolicy() : m_autoRetryWorker(std::chrono::seconds(20)) {}
|
||||
void EnableCellularDownload(bool enabled);
|
||||
bool IsCellularDownloadEnabled();
|
||||
|
||||
inline bool IsAutoRetryDownloadFailed() const
|
||||
{
|
||||
return m_downloadRetryFailed || m_autoRetryCounter == 0;
|
||||
}
|
||||
|
||||
// DownloadingPolicy overrides:
|
||||
bool IsDownloadingAllowed() override;
|
||||
void ScheduleRetry(storage::CountriesSet const & failedCountries,
|
||||
TProcessFunc const & func) override;
|
||||
};
|
||||
Reference in New Issue
Block a user