Skip to content

Commit

Permalink
[downloader] Updated downloading policy.
Browse files Browse the repository at this point in the history
Added info about last auto retry download failed.
  • Loading branch information
igrechuhin authored and bykoianko committed Jun 23, 2016
1 parent 880c877 commit 990a620
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions storage/downloading_policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ void StorageDownloadingPolicy::ScheduleRetry(storage::TCountriesSet const & fail
{
if (IsDownloadingAllowed() && !failedCountries.empty() && m_autoRetryCounter > 0)
{
m_downloadRetryFailed = false;
auto action = [this, func, failedCountries]
{
--m_autoRetryCounter;
Expand All @@ -22,6 +23,8 @@ void StorageDownloadingPolicy::ScheduleRetry(storage::TCountriesSet const & fail
}
else
{
if(!failedCountries.empty())
m_downloadRetryFailed = true;
m_autoRetryCounter = kAutoRetryCounterMax;
}
}
3 changes: 2 additions & 1 deletion storage/downloading_policy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class DownloadingPolicy
class StorageDownloadingPolicy : public DownloadingPolicy
{
bool m_cellularDownloadEnabled = false;
bool m_downloadRetryFailed = false;
static size_t constexpr kAutoRetryCounterMax = 3;
size_t m_autoRetryCounter = kAutoRetryCounterMax;
my::DeferredTask m_autoRetryWorker;
Expand All @@ -27,7 +28,7 @@ class StorageDownloadingPolicy : public DownloadingPolicy

inline void EnableCellularDownload(bool value) { m_cellularDownloadEnabled = value; }
inline bool IsCellularDownloadEnabled() const { return m_cellularDownloadEnabled; }
inline bool IsAutoRetryDownloadFailed() const { return m_autoRetryCounter == 0; }
inline bool IsAutoRetryDownloadFailed() const { return m_downloadRetryFailed || m_autoRetryCounter == 0; }

bool IsDownloadingAllowed() const override;
void ScheduleRetry(storage::TCountriesSet const & failedCountries, TProcessFunc const & func) override;
Expand Down

0 comments on commit 990a620

Please sign in to comment.