diff options
Diffstat (limited to 'storage')
-rw-r--r-- | storage/storage.cpp | 13 | ||||
-rw-r--r-- | storage/storage.hpp | 5 |
2 files changed, 18 insertions, 0 deletions
diff --git a/storage/storage.cpp b/storage/storage.cpp index 2455e2d38f..54c2300229 100644 --- a/storage/storage.cpp +++ b/storage/storage.cpp @@ -497,9 +497,15 @@ void Storage::DownloadCountry(TCountryId const & countryId, MapOptions opt) m_failedCountries.erase(countryId); m_queue.push_back(QueuedCountry(countryId, opt)); if (m_queue.size() == 1) + { + if (m_startDownloadingCallback) + m_startDownloadingCallback(); DownloadNextCountryFromQueue(); + } else + { NotifyStatusChangedForHierarchy(countryId); + } SaveDownloadQueue(); } @@ -1440,6 +1446,13 @@ bool Storage::IsPossibleToAutoupdate() const return m_diffManager.IsPossibleToAutoupdate(); } +void Storage::SetStartDownloadingCallback(StartDownloadingCallback const & cb) +{ + ASSERT_THREAD_CHECKER(m_threadChecker, ()); + + m_startDownloadingCallback = cb; +} + void Storage::OnDiffStatusReceived(diffs::Status const status) { if (status != diffs::Status::NotAvailable) diff --git a/storage/storage.hpp b/storage/storage.hpp index f63056aed4..e79983b650 100644 --- a/storage/storage.hpp +++ b/storage/storage.hpp @@ -141,6 +141,7 @@ class Storage : public diffs::Manager::Observer { public: struct StatusCallback; + using StartDownloadingCallback = function<void()>; using TUpdateCallback = function<void(storage::TCountryId const &, TLocalFilePtr const)>; using TDeleteCallback = function<bool(storage::TCountryId const &, TLocalFilePtr const)>; using TChangeCountryFunction = function<void(TCountryId const &)>; @@ -251,6 +252,8 @@ private: vector<vector<string>> m_deferredDownloads; + StartDownloadingCallback m_startDownloadingCallback; + void DownloadNextCountryFromQueue(); void LoadCountriesFile(string const & pathToCountriesFile, string const & dataDir, @@ -557,6 +560,8 @@ public: /// diffs. bool IsPossibleToAutoupdate() const; + void SetStartDownloadingCallback(StartDownloadingCallback const & cb); + private: friend struct UnitClass_StorageTest_DeleteCountry; friend struct UnitClass_TwoComponentStorageTest_DeleteCountry; |