[downloader] Add implementation for retrieving overall downloading progress for requested countries

This commit is contained in:
Sergey Yershov 2016-04-11 16:22:40 +03:00
parent 7ac842254c
commit 0f8a29e9b5
2 changed files with 23 additions and 0 deletions

View file

@ -88,6 +88,25 @@ void GetQueuedCountries(Storage::TQueue const & queue, TCountriesSet & resultCou
resultCountries.insert(country.GetCountryId());
}
MapFilesDownloader::TProgress Storage::GetOverallProgress(TCountriesVec const & countries)
{
MapFilesDownloader::TProgress overallProgress = {0, 0};
for (auto const & country : countries)
{
NodeAttrs attr;
GetNodeAttrs(country, attr);
ASSERT_EQUAL(attr.m_mwmCounter, 1, ());
if (attr.m_downloadingProgress.second != -1)
{
overallProgress.first += attr.m_downloadingProgress.first;
overallProgress.second += attr.m_downloadingProgress.second;
}
}
return overallProgress;
}
Storage::Storage(string const & pathToCountriesFile /* = COUNTRIES_FILE */, string const & dataDir /* = string() */)
: m_downloader(new HttpMapFilesDownloader()), m_currentSlotId(0), m_dataDir(dataDir),
m_downloadMapOnTheMap(nullptr)

View file

@ -444,6 +444,10 @@ public:
int Subscribe(TChangeCountryFunction const & change, TProgressFunction const & progress);
void Unsubscribe(int slotId);
/// Returns information about selected counties downloading progress.
/// |countries| - watched CountryId, ONLY leaf expected.
MapFilesDownloader::TProgress GetOverallProgress(TCountriesVec const &countries);
Country const & CountryLeafByCountryId(TCountryId const & countryId) const;
Country const & CountryByCountryId(TCountryId const & countryId) const;