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:
authorVladiMihaylenko <vxmihaylenko@gmail.com>2018-02-01 14:10:04 +0300
committerVladimir Byko-Ianko <bykoianko@gmail.com>2018-02-01 18:17:27 +0300
commit91483a5cf6e07864eb3bb16f848666571530b255 (patch)
tree3ea129363d178c9a700ddf91ab58fd5982ded709 /storage
parentcbd1fab9598d99ccd1a1ef5fa317c409ef52039b (diff)
Added applying status to nodes.
Diffstat (limited to 'storage')
-rw-r--r--storage/storage.cpp13
-rw-r--r--storage/storage.hpp3
-rw-r--r--storage/storage_defines.cpp53
-rw-r--r--storage/storage_defines.hpp20
4 files changed, 57 insertions, 32 deletions
diff --git a/storage/storage.cpp b/storage/storage.cpp
index b0e4750dce..34083c4123 100644
--- a/storage/storage.cpp
+++ b/storage/storage.cpp
@@ -404,7 +404,7 @@ Status Storage::CountryStatus(TCountryId const & countryId) const
if (IsCountryInQueue(countryId))
{
if (IsCountryFirstInQueue(countryId))
- return Status::EDownloading;
+ return IsDiffApplyingInProgressToCountry(countryId) ? Status::EApplying : Status::EDownloading;
else
return Status::EInQueue;
}
@@ -871,6 +871,7 @@ void Storage::RegisterDownloadedFiles(TCountryId const & countryId, MapOptions o
/// and we can't stop the process.
/// TODO: Make the applying process cancellable.
m_queue.begin()->SetFrozen();
+ NotifyStatusChangedForHierarchy(countryId);
ApplyDiff(countryId, fn);
return;
}
@@ -1067,6 +1068,16 @@ bool Storage::IsCountryFirstInQueue(TCountryId const & countryId) const
return !m_queue.empty() && m_queue.front().GetCountryId() == countryId;
}
+bool Storage::IsDiffApplyingInProgressToCountry(TCountryId const & countryId) const
+{
+ ASSERT_THREAD_CHECKER(m_threadChecker, ());
+
+ if (!IsCountryFirstInQueue(countryId))
+ return false;
+
+ return m_queue.front().IsFrozen();
+}
+
void Storage::SetLocale(string const & locale) { m_countryNameGetter.SetLocale(locale); }
string Storage::GetLocale() const { return m_countryNameGetter.GetLocale(); }
void Storage::SetDownloaderForTesting(unique_ptr<MapFilesDownloader> && downloader)
diff --git a/storage/storage.hpp b/storage/storage.hpp
index e79983b650..b938eca52c 100644
--- a/storage/storage.hpp
+++ b/storage/storage.hpp
@@ -588,6 +588,9 @@ private:
// Returns true when country is first in the downloader's queue.
bool IsCountryFirstInQueue(TCountryId const & countryId) const;
+ // Returns true if we started the diff applying procedure for an mwm with countryId.
+ bool IsDiffApplyingInProgressToCountry(TCountryId const & countryId) const;
+
// Returns local country files of a particular version, or wrapped
// nullptr if there're no country files corresponding to the
// version.
diff --git a/storage/storage_defines.cpp b/storage/storage_defines.cpp
index cd36806f2e..17e359bb5c 100644
--- a/storage/storage_defines.cpp
+++ b/storage/storage_defines.cpp
@@ -1,6 +1,9 @@
#include "storage/storage_defines.hpp"
-#include "std/sstream.hpp"
+#include <sstream>
+
+using namespace std;
+using namespace string_literals;
namespace storage
{
@@ -9,23 +12,25 @@ string DebugPrint(Status status)
switch (status)
{
case Status::EUndefined:
- return string("EUndefined");
+ return "EUndefined"s;
case Status::EOnDisk:
- return string("OnDisk");
+ return "OnDisk"s;
case Status::ENotDownloaded:
- return string("NotDownloaded");
+ return "NotDownloaded"s;
case Status::EDownloadFailed:
- return string("DownloadFailed");
+ return "DownloadFailed"s;
case Status::EDownloading:
- return string("Downloading");
+ return "Downloading"s;
+ case Status::EApplying:
+ return "Applying"s;
case Status::EInQueue:
- return string("InQueue");
+ return "InQueue"s;
case Status::EUnknown:
- return string("Unknown");
+ return "Unknown"s;
case Status::EOnDiskOutOfDate:
- return string("OnDiskOutOfDate");
+ return "OnDiskOutOfDate"s;
case Status::EOutOfMemFailed:
- return string("OutOfMemFailed");
+ return "OutOfMemFailed"s;
}
}
@@ -34,21 +39,23 @@ string DebugPrint(NodeStatus status)
switch (status)
{
case NodeStatus::Undefined:
- return string("Undefined");
+ return "Undefined"s;
case NodeStatus::Error:
- return string("Error");
+ return "Error"s;
case NodeStatus::OnDisk:
- return string("OnDisk");
+ return "OnDisk"s;
case NodeStatus::NotDownloaded:
- return string("NotDownloaded");
+ return "NotDownloaded"s;
case NodeStatus::Downloading:
- return string("Downloading");
+ return "Downloading"s;
+ case NodeStatus::Applying:
+ return "Applying"s;
case NodeStatus::InQueue:
- return string("InQueue");
+ return "InQueue"s;
case NodeStatus::OnDiskOutOfDate:
- return string("OnDiskOutOfDate");
+ return "OnDiskOutOfDate"s;
case NodeStatus::Partly:
- return string("Partly");
+ return "Partly"s;
}
}
@@ -57,13 +64,13 @@ string DebugPrint(NodeErrorCode status)
switch (status)
{
case NodeErrorCode::NoError:
- return string("NoError");
+ return "NoError"s;
case NodeErrorCode::UnknownError:
- return string("UnknownError");
+ return "UnknownError"s;
case NodeErrorCode::OutOfMemFailed:
- return string("OutOfMemFailed");
+ return "OutOfMemFailed"s;
case NodeErrorCode::NoInetConnection:
- return string("NoInetConnection");
+ return "NoInetConnection"s;
}
}
@@ -81,6 +88,8 @@ StatusAndError ParseStatus(Status innerStatus)
return StatusAndError(NodeStatus::Error, NodeErrorCode::NoInetConnection);
case Status::EDownloading:
return StatusAndError(NodeStatus::Downloading, NodeErrorCode::NoError);
+ case Status::EApplying:
+ return StatusAndError(NodeStatus::Applying, NodeErrorCode::NoError);
case Status::EInQueue:
return StatusAndError(NodeStatus::InQueue, NodeErrorCode::NoError);
case Status::EUnknown:
diff --git a/storage/storage_defines.hpp b/storage/storage_defines.hpp
index ee2c6361d6..052357e7d2 100644
--- a/storage/storage_defines.hpp
+++ b/storage/storage_defines.hpp
@@ -2,10 +2,10 @@
#include "storage/index.hpp"
-#include "std/cstdint.hpp"
-#include "std/function.hpp"
-#include "std/string.hpp"
-#include "std/utility.hpp"
+#include <cstdint>
+#include <functional>
+#include <string>
+#include <utility>
namespace storage
{
@@ -17,12 +17,13 @@ namespace storage
ENotDownloaded, /**< Mwm can be download but not downloaded yet. */
EDownloadFailed, /**< Downloading failed because no internet connection. */
EDownloading, /**< Downloading a new mwm or updating an old one. */
+ EApplying, /**< Applying downloaded diff for an old mwm. */
EInQueue, /**< A mwm is waiting for downloading in the queue. */
EUnknown, /**< Downloading failed because of unknown error. */
EOnDiskOutOfDate, /**< An update for a downloaded mwm is ready according to counties.txt. */
EOutOfMemFailed, /**< Downloading failed because it's not enough memory */
};
- string DebugPrint(Status status);
+ std::string DebugPrint(Status status);
/// \note The order of enum items is important. It is used in Storage::NodeStatus method.
/// If it's necessary to add more statuses it's better to add to the end.
@@ -30,6 +31,7 @@ namespace storage
{
Undefined,
Downloading, /**< Downloading a new mwm or updating an old one. */
+ Applying, /**< Applying downloaded diff for an old mwm. */
InQueue, /**< An mwm is waiting for downloading in the queue. */
Error, /**< An error happened while downloading */
OnDiskOutOfDate, /**< An update for a downloaded mwm is ready according to counties.txt. */
@@ -37,7 +39,7 @@ namespace storage
NotDownloaded, /**< An mwm can be downloaded but not downloaded yet. */
Partly, /**< Leafs of group node has a mix of NotDownloaded and OnDisk status. */
};
- string DebugPrint(NodeStatus status);
+ std::string DebugPrint(NodeStatus status);
enum class NodeErrorCode
{
@@ -46,7 +48,7 @@ namespace storage
OutOfMemFailed, /**< Downloading failed because it's not enough memory */
NoInetConnection, /**< Downloading failed because internet connection was interrupted */
};
- string DebugPrint(NodeErrorCode status);
+ std::string DebugPrint(NodeErrorCode status);
struct StatusAndError
{
@@ -61,9 +63,9 @@ namespace storage
NodeStatus status;
NodeErrorCode error;
};
- string DebugPrint(StatusAndError statusAndError);
+ std::string DebugPrint(StatusAndError statusAndError);
StatusAndError ParseStatus(Status innerStatus);
} // namespace storage
-using TDownloadFn = function<void (storage::TCountryId const &)>;
+using TDownloadFn = std::function<void(storage::TCountryId const &)>;