diff --git a/iphone/Maps/Classes/CustomAlert/DownloadTransitMapsAlert/MWMDownloadTransitMapAlert.mm b/iphone/Maps/Classes/CustomAlert/DownloadTransitMapsAlert/MWMDownloadTransitMapAlert.mm index f927fd96c4..18c64f4d0d 100644 --- a/iphone/Maps/Classes/CustomAlert/DownloadTransitMapsAlert/MWMDownloadTransitMapAlert.mm +++ b/iphone/Maps/Classes/CustomAlert/DownloadTransitMapsAlert/MWMDownloadTransitMapAlert.mm @@ -27,7 +27,7 @@ if (self) { NSMutableArray * titles = [@[] mutableCopy]; - size_t totalRoutingSize = 0; + storage::TMwmSize totalRoutingSize = 0; auto & s = GetFramework().Storage(); for (auto const & countryId : countriesVec) { diff --git a/iphone/Maps/Classes/MapDownloader/MWMBaseMapDownloaderViewController.mm b/iphone/Maps/Classes/MapDownloader/MWMBaseMapDownloaderViewController.mm index 2502f4ec08..0853688923 100644 --- a/iphone/Maps/Classes/MapDownloader/MWMBaseMapDownloaderViewController.mm +++ b/iphone/Maps/Classes/MapDownloader/MWMBaseMapDownloaderViewController.mm @@ -325,7 +325,7 @@ using namespace storage; s.GetQueuedChildren(parentCountryId, queuedChildren); if (!queuedChildren.empty()) { - size_t queuedSize = 0; + storage::TMwmSize queuedSize = 0; for (TCountryId const & countryId : queuedChildren) { NodeAttrs nodeAttrs; diff --git a/platform/local_country_file.cpp b/platform/local_country_file.cpp index a84bd59d62..a69c7439e0 100644 --- a/platform/local_country_file.cpp +++ b/platform/local_country_file.cpp @@ -70,17 +70,15 @@ string LocalCountryFile::GetPath(MapOptions file) const return my::JoinFoldersToPath(m_directory, GetFileName(m_countryFile.GetName(), file, GetVersion())); } -uint32_t LocalCountryFile::GetSize(MapOptions filesMask) const +uint64_t LocalCountryFile::GetSize(MapOptions filesMask) const { - uint64_t size64 = 0; + uint64_t size = 0; if (HasOptions(filesMask, MapOptions::Map)) - size64 += m_mapSize; + size += m_mapSize; if (!version::IsSingleMwm(GetVersion()) && HasOptions(filesMask, MapOptions::CarRouting)) - size64 += m_routingSize; + size += m_routingSize; - uint32_t const size32 = static_cast(size64); - ASSERT_EQUAL(size32, size64, ()); - return size32; + return size; } bool LocalCountryFile::operator<(LocalCountryFile const & rhs) const diff --git a/platform/local_country_file.hpp b/platform/local_country_file.hpp index fa0fbec278..e506a72f0e 100644 --- a/platform/local_country_file.hpp +++ b/platform/local_country_file.hpp @@ -51,7 +51,7 @@ public: // Returns size of a file. Return value may be zero until // SyncWithDisk() is called. - uint32_t GetSize(MapOptions filesMask) const; + uint64_t GetSize(MapOptions filesMask) const; // Returns a mask of all known country files. Return value may be // empty until SyncWithDisk() is called. diff --git a/qt/draw_widget.cpp b/qt/draw_widget.cpp index 882c8d5191..23fc076c14 100644 --- a/qt/draw_widget.cpp +++ b/qt/draw_widget.cpp @@ -129,7 +129,7 @@ void DrawWidget::UpdateCountryStatus(storage::TCountryId const & countryId) auto status = m_framework->Storage().CountryStatusEx(countryId); - uint64_t sizeInBytes = 0; + storage::TMwmSize sizeInBytes = 0; if (!countryId.empty()) { storage::NodeAttrs nodeAttrs; diff --git a/storage/country.cpp b/storage/country.cpp index d7b2d6bb42..5f9973020c 100644 --- a/storage/country.cpp +++ b/storage/country.cpp @@ -17,7 +17,7 @@ namespace storage // Mwm subtree attributes. They can be calculated based on information contained in countries.txt. // The first in the pair is number of mwms in a subtree. The second is sum of sizes of // all mwms in a subtree. -using TMwmSubtreeAttrs = pair; +using TMwmSubtreeAttrs = pair; namespace { @@ -25,7 +25,7 @@ class StoreSingleMwmInterface { public: virtual ~StoreSingleMwmInterface() = default; - virtual Country * InsertToCountryTree(TCountryId const & id, uint32_t mapSize, size_t depth, + virtual Country * InsertToCountryTree(TCountryId const & id, TMwmSize mapSize, size_t depth, TCountryId const & parent) = 0; virtual void InsertOldMwmMapping(TCountryId const & newId, TCountryId const & oldId) = 0; virtual void InsertAffiliation(TCountryId const & countryId, string const & affilation) = 0; @@ -50,7 +50,7 @@ public: } // StoreSingleMwmInterface overrides: - Country * InsertToCountryTree(TCountryId const & id, uint32_t mapSize, size_t depth, + Country * InsertToCountryTree(TCountryId const & id, TMwmSize mapSize, size_t depth, TCountryId const & parent) override { Country country(id, parent); @@ -88,7 +88,7 @@ public: StoreFile2InfoSingleMwms(map & file2info) : m_file2info(file2info) {} // StoreSingleMwmInterface overrides: - Country * InsertToCountryTree(TCountryId const & id, uint32_t /* mapSize */, size_t /* depth */, + Country * InsertToCountryTree(TCountryId const & id, TMwmSize /* mapSize */, size_t /* depth */, TCountryId const & /* parent */) override { CountryInfo info(id); @@ -135,8 +135,8 @@ TMwmSubtreeAttrs LoadGroupSingleMwmsImpl(size_t depth, json_t * node, TCountryId // We expect that mwm and routing files should be less than 2GB. Country * addedNode = store.InsertToCountryTree(id, nodeSize, depth, parent); - uint32_t mwmCounter = 0; - size_t mwmSize = 0; + TMwmCounter mwmCounter = 0; + TMwmSize mwmSize = 0; vector children; my::FromJSONObjectOptionalField(node, "g", children); if (children.empty()) @@ -181,7 +181,7 @@ class StoreTwoComponentMwmInterface { public: virtual ~StoreTwoComponentMwmInterface() = default; - virtual Country * Insert(string const & id, uint32_t mapSize, uint32_t /* routingSize */, size_t depth, + virtual Country * Insert(string const & id, TMwmSize mapSize, TMwmSize /* routingSize */, size_t depth, TCountryId const & parent) = 0; }; @@ -197,7 +197,7 @@ public: } // StoreTwoComponentMwmInterface overrides: - virtual Country * Insert(string const & id, uint32_t mapSize, uint32_t routingSize, size_t depth, + virtual Country * Insert(string const & id, TMwmSize mapSize, TMwmSize routingSize, size_t depth, TCountryId const & parent) override { Country country(id, parent); @@ -220,7 +220,7 @@ public: StoreFile2InfoTwoComponentMwms(map & file2info) : m_file2info(file2info) {} // StoreTwoComponentMwmInterface overrides: - virtual Country * Insert(string const & id, uint32_t mapSize, uint32_t /* routingSize */, size_t /* depth */, + virtual Country * Insert(string const & id, TMwmSize mapSize, TMwmSize /* routingSize */, size_t /* depth */, TCountryId const & /* parent */) override { if (mapSize == 0) @@ -250,11 +250,11 @@ TMwmSubtreeAttrs LoadGroupTwoComponentMwmsImpl(size_t depth, json_t * node, TCou ASSERT_LESS_OR_EQUAL(0, mwmSize, ()); ASSERT_LESS_OR_EQUAL(0, routingSize, ()); - Country * addedNode = store.Insert(file, static_cast(mwmSize), static_cast(routingSize), + Country * addedNode = store.Insert(file, static_cast(mwmSize), static_cast(routingSize), depth, parent); - uint32_t countryCounter = 0; - size_t countrySize = 0; + TMwmCounter countryCounter = 0; + TMwmSize countrySize = 0; vector children; my::FromJSONObjectOptionalField(node, "g", children); if (children.empty()) diff --git a/storage/country.hpp b/storage/country.hpp index f4a13c95b9..1dd8953a2c 100644 --- a/storage/country.hpp +++ b/storage/country.hpp @@ -50,10 +50,10 @@ class Country platform::CountryFile m_file; /// The number of descendant mwm files of |m_name|. Only files (leaves in tree) are counted. /// If |m_name| is a mwm file name |m_childrenNumber| == 1. - uint32_t m_subtreeMwmNumber; + TMwmCounter m_subtreeMwmNumber; /// Size of descendant mwm files of |m_name|. /// If |m_name| is a mwm file name |m_subtreeMwmSizeBytes| is equal to size of the mwm. - size_t m_subtreeMwmSizeBytes; + TMwmSize m_subtreeMwmSizeBytes; public: Country() = default; @@ -61,13 +61,13 @@ public: : m_name(name), m_parent(parent) {} void SetFile(platform::CountryFile const & file) { m_file = file; } - void SetSubtreeAttrs(uint32_t subtreeMwmNumber, size_t subtreeMwmSizeBytes) + void SetSubtreeAttrs(TMwmCounter subtreeMwmNumber, TMwmSize subtreeMwmSizeBytes) { m_subtreeMwmNumber = subtreeMwmNumber; m_subtreeMwmSizeBytes = subtreeMwmSizeBytes; } - uint32_t GetSubtreeMwmCounter() const { return m_subtreeMwmNumber; } - size_t GetSubtreeMwmSizeBytes() const { return m_subtreeMwmSizeBytes; } + TMwmCounter GetSubtreeMwmCounter() const { return m_subtreeMwmNumber; } + TMwmSize GetSubtreeMwmSizeBytes() const { return m_subtreeMwmSizeBytes; } TCountryId GetParent() const { return m_parent; } /// This function valid for current logic - one file for one country (region). diff --git a/storage/storage.cpp b/storage/storage.cpp index d9a8fe4cc0..a98f0321a1 100644 --- a/storage/storage.cpp +++ b/storage/storage.cpp @@ -1318,7 +1318,7 @@ void Storage::GetNodeAttrs(TCountryId const & countryId, NodeAttrs & nodeAttrs) if (nodeAttrs.m_status == NodeStatus::OnDisk) { // Group or leaf node is on disk and up to date. - size_t const subTreeSizeBytes = node->Value().GetSubtreeMwmSizeBytes(); + TMwmSize const subTreeSizeBytes = node->Value().GetSubtreeMwmSizeBytes(); nodeAttrs.m_downloadingProgress.first = subTreeSizeBytes; nodeAttrs.m_downloadingProgress.second = subTreeSizeBytes; } diff --git a/storage/storage.hpp b/storage/storage.hpp index 6b5953b22a..42b83158e7 100644 --- a/storage/storage.hpp +++ b/storage/storage.hpp @@ -3,6 +3,7 @@ #include "storage/country.hpp" #include "storage/country_name_getter.hpp" #include "storage/country_tree.hpp" +#include "storage/storage_defines.hpp" #include "storage/index.hpp" #include "storage/map_files_downloader.hpp" #include "storage/queued_country.hpp" @@ -45,31 +46,31 @@ struct NodeAttrs /// If the node is expandable (a big country) |m_mwmCounter| is number of mwm files (leaves) /// belonging to the node. If the node isn't expandable |m_mwmCounter| == 1. /// Note. For every expandable node |m_mwmCounter| >= 2. - uint32_t m_mwmCounter; + TMwmCounter m_mwmCounter; /// Number of mwms belonging to the node which have been downloaded. - uint32_t m_localMwmCounter; + TMwmCounter m_localMwmCounter; /// Number of leaves of the node which have been downloaded /// plus which is in progress of downloading (zero or one) /// plus which are staying in queue. - uint32_t m_downloadingMwmCounter; + TMwmCounter m_downloadingMwmCounter; /// If it's not an expandable node, |m_mwmSize| is size of one mwm according to countries.txt. /// Otherwise |m_mwmSize| is the sum of all mwm file sizes which belong to the group /// according to countries.txt. - size_t m_mwmSize; + TMwmSize m_mwmSize; /// If it's not an expandable node, |m_localMwmSize| is size of one downloaded mwm. /// Otherwise |m_localNodeSize| is the sum of all mwm file sizes which belong to the group and /// have been downloaded. - size_t m_localMwmSize; + TMwmSize m_localMwmSize; /// Size of leaves of the node which have been downloaded /// plus which is in progress of downloading (zero or one) /// plus which are staying in queue. /// \note The size of leaves is the size is written in countries.txt. - size_t m_downloadingMwmSize; + TMwmSize m_downloadingMwmSize; /// The name of the node in a local language. That means the language dependent on /// a device locale. @@ -88,7 +89,7 @@ struct NodeAttrs /// Locale language is a language set by Storage::SetLocale(). /// \note Most number of nodes have only first level parent. But in case of a disputed territories /// an mwm could have two or even more parents. See Country description for details. - vector m_topmostParentInfo; + vector m_topmostParentInfo; /// Progress of downloading for the node expandable or not. It reflects downloading progress in case of /// downloading and updating mwm. @@ -294,8 +295,8 @@ public: { UpdateInfo() : m_numberOfMwmFilesToUpdate(0), m_totalUpdateSizeInBytes(0) {} - size_t m_numberOfMwmFilesToUpdate; - size_t m_totalUpdateSizeInBytes; + uint32_t m_numberOfMwmFilesToUpdate; + uint64_t m_totalUpdateSizeInBytes; }; struct StatusCallback diff --git a/storage/storage_defines.hpp b/storage/storage_defines.hpp index 364d58fd73..619ac120af 100644 --- a/storage/storage_defines.hpp +++ b/storage/storage_defines.hpp @@ -63,7 +63,9 @@ namespace storage }; string DebugPrint(StatusAndError statusAndError); - using TLocalAndRemoteSize = pair; + using TMwmCounter = uint32_t; + using TMwmSize = uint64_t; + using TLocalAndRemoteSize = pair; StatusAndError ParseStatus(Status innerStatus); } // namespace storage diff --git a/storage/storage_integration_tests/storage_group_download_tests.cpp b/storage/storage_integration_tests/storage_group_download_tests.cpp index 3793c99a4d..34c0b9805a 100644 --- a/storage/storage_integration_tests/storage_group_download_tests.cpp +++ b/storage/storage_integration_tests/storage_group_download_tests.cpp @@ -102,7 +102,7 @@ void DownloadGroup(Storage & storage, bool oneByOne) TEST(downloaded.empty(), ()); // Check status for the all children nodes is set to ENotDownloaded. - size_t totalGroupSize = 0; + TMwmSize totalGroupSize = 0; for (auto const & countryId : children) { TEST_EQUAL(Status::ENotDownloaded, storage.CountryStatusEx(countryId), ()); diff --git a/storage/storage_tests/storage_tests.cpp b/storage/storage_tests/storage_tests.cpp index d6cbd5774b..6e528d4f1d 100644 --- a/storage/storage_tests/storage_tests.cpp +++ b/storage/storage_tests/storage_tests.cpp @@ -467,7 +467,7 @@ void OnCountryDownloaded(TCountryId const & countryId, TLocalFilePtr const local LOG(LINFO, ("OnCountryDownloaded:", *localFile)); } -TLocalFilePtr CreateDummyMapFile(CountryFile const & countryFile, int64_t version, size_t size) +TLocalFilePtr CreateDummyMapFile(CountryFile const & countryFile, int64_t version, uint64_t size) { TLocalFilePtr localFile = PreparePlaceForCountryFiles(version, string() /* dataDir */, countryFile); TEST(localFile.get(), ("Can't prepare place for", countryFile, "(version", version, ")"));