Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Yershov <yershov@corp.mail.ru>2016-04-11 16:22:40 +0300
committerSergey Yershov <yershov@corp.mail.ru>2016-04-11 17:40:22 +0300
commit0f8a29e9b59272e7e8b74b5259210cb2184130d8 (patch)
tree84ce2dadd6f1e6dc7e8b809a9e9f17074695a51d /storage
parent7ac842254c2bd310efd08f0813ee122efab7a5bf (diff)
[downloader] Add implementation for retrieving overall downloading progress for requested countries
Diffstat (limited to 'storage')
-rw-r--r--storage/storage.cpp19
-rw-r--r--storage/storage.hpp4
2 files changed, 23 insertions, 0 deletions
diff --git a/storage/storage.cpp b/storage/storage.cpp
index 41a38d11ee..82799a6603 100644
--- a/storage/storage.cpp
+++ b/storage/storage.cpp
@@ -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)
diff --git a/storage/storage.hpp b/storage/storage.hpp
index 3f096121c6..3f811be1a8 100644
--- a/storage/storage.hpp
+++ b/storage/storage.hpp
@@ -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;