Skip to content

Commit

Permalink
[new downloader] Renaming node status getter. Other review fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
bykoianko authored and syershov committed Mar 23, 2016
1 parent 4a323d1 commit 29086ff
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 23 deletions.
14 changes: 8 additions & 6 deletions android/src/com/mapswithme/maps/downloader/CountryItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ public final class CountryItem implements Comparable<CountryItem>

// Must correspond to NodeStatus in storage_defines.hpp
public static final int STATUS_UNKNOWN = 0;
public static final int STATUS_FAILED = 1;
public static final int STATUS_DONE = 2;
public static final int STATUS_DOWNLOADABLE = 3;
public static final int STATUS_PROGRESS = 4;
public static final int STATUS_ENQUEUED = 5;
public static final int STATUS_UPDATABLE = 6;

public static final int STATUS_PROGRESS = 1; // Downloading a new mwm or updating an old one.
public static final int STATUS_ENQUEUED = 2; // An mwm is waiting for downloading in the queue.
public static final int STATUS_FAILED = 3; // An error happened while downloading
public static final int STATUS_UPDATABLE = 4; // An update for a downloaded mwm is ready according to counties.txt.
public static final int STATUS_DONE = 5; // Downloaded mwm(s) is up to date. No need to update it.
public static final int STATUS_DOWNLOADABLE = 6; // An mwm can be downloaded but not downloaded yet.
public static final int STATUS_PARTLY = 7; // Leafs of group node has a mix of NotDownloaded and OnDisk status.

// Must correspond to NodeErrorCode in storage_defines.hpp
public static final int ERROR_NONE = 0;
Expand Down
10 changes: 5 additions & 5 deletions storage/storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1228,14 +1228,14 @@ void Storage::DeleteNode(TCountryId const & countryId)
node->ForEachInSubtree(deleteAction);
}

StatusAndError Storage::NodeStatus(TCountryTreeNode const & node) const
StatusAndError Storage::GetNodeStatus(TCountryTreeNode const & node) const
{
// Leaf node status.
if (node.ChildrenCount() == 0)
return ParseStatus(CountryStatusEx(node.Value().Name()));

// Group node status.
enum NodeStatus result = NodeStatus::NotDownloaded;
NodeStatus result = NodeStatus::NotDownloaded;
bool allOnDisk = true;

auto groupStatusCalculator = [&result, &allOnDisk, this](TCountryTreeNode const & nodeInSubtree)
Expand All @@ -1254,8 +1254,8 @@ StatusAndError Storage::NodeStatus(TCountryTreeNode const & node) const
node.ForEachDescendant(groupStatusCalculator);
if (allOnDisk)
return ParseStatus(Status::EOnDisk);
if (!allOnDisk && result == NodeStatus::OnDisk)
return { NodeStatus::Mixed, NodeErrorCode::NoError };
if (result == NodeStatus::OnDisk)
return { NodeStatus::Partly, NodeErrorCode::NoError };

ASSERT_NOT_EQUAL(result, NodeStatus::Undefined, ());
return { result, NodeErrorCode::NoError };
Expand All @@ -1276,7 +1276,7 @@ void Storage::GetNodeAttrs(TCountryId const & countryId, NodeAttrs & nodeAttrs)
Country const & nodeValue = node->Value();
nodeAttrs.m_mwmCounter = nodeValue.GetSubtreeMwmCounter();
nodeAttrs.m_mwmSize = nodeValue.GetSubtreeMwmSizeBytes();
StatusAndError statusAndErr = NodeStatus(*node);
StatusAndError statusAndErr = GetNodeStatus(*node);
nodeAttrs.m_status = statusAndErr.status;
nodeAttrs.m_error = statusAndErr.error;
nodeAttrs.m_nodeLocalName = m_countryNameGetter(countryId);
Expand Down
14 changes: 7 additions & 7 deletions storage/storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ struct NodeAttrs
/// Status of group and leaf node.
/// For group nodes it's defined in the following way:
/// If an mwm in a group has Downloading status the group has Downloading status
/// If not and if an mwm in the group has InQueue status the group has InQueue status
/// If not and if an mwm in the group has Error status the group has Error status
/// If not and if an mwm in the group has OnDiskOutOfDate the group has OnDiskOutOfDate status
/// If not and if all the mwms in the group have OnDisk status the group has OnDisk status
/// If not and if all the mwms in the group have NotDownloaded status the group has NotDownloaded status
/// If not (that means a part of mwms in the group has OnDisk and the other part has NotDownloaded status)
/// Otherwise if an mwm in the group has InQueue status the group has InQueue status
/// Otherwise if an mwm in the group has Error status the group has Error status
/// Otherwise if an mwm in the group has OnDiskOutOfDate the group has OnDiskOutOfDate status
/// Otherwise if all the mwms in the group have OnDisk status the group has OnDisk status
/// Otherwise if all the mwms in the group have NotDownloaded status the group has NotDownloaded status
/// Otherwise (that means a part of mwms in the group has OnDisk and the other part has NotDownloaded status)
/// the group has Mixed status
NodeStatus m_status;
/// Error code of leaf node. In case of group node |m_error| == NodeErrorCode::NoError.
Expand Down Expand Up @@ -503,7 +503,7 @@ class Storage
Status CountryStatus(TCountryId const & countryId) const;

/// Returns status for a node (group node or not)
StatusAndError NodeStatus(TCountryTreeNode const & node) const;
StatusAndError GetNodeStatus(TCountryTreeNode const & node) const;

void NotifyStatusChanged(TCountryId const & countryId);
void NotifyStatusChangedForHierarchy(TCountryId const & countryId);
Expand Down
4 changes: 2 additions & 2 deletions storage/storage_defines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ string DebugPrint(NodeStatus status)
return string("InQueue");
case NodeStatus::OnDiskOutOfDate:
return string("OnDiskOutOfDate");
case NodeStatus::Mixed:
return string("Mixed");
case NodeStatus::Partly:
return string("Partly");
}
}

Expand Down
6 changes: 3 additions & 3 deletions storage/storage_defines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ namespace storage
{
Undefined,
Downloading, /**< Downloading a new mwm or updating an old one. */
InQueue, /**< A mwm is waiting for downloading in the queue. */
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. */
OnDisk, /**< Downloaded mwm(s) is up to date. No need to update it. */
NotDownloaded, /**< Mwm can be download but not downloaded yet. */
Mixed, /**< Leafs of group node has a mix of NotDownloaded and OnDisk status. */
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);

Expand Down

0 comments on commit 29086ff

Please sign in to comment.