summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin/offline.cpp2
-rw-r--r--include/mbgl/storage/offline.hpp13
-rw-r--r--platform/default/mbgl/storage/offline_download.cpp10
-rw-r--r--test/storage/offline_download.cpp14
4 files changed, 20 insertions, 19 deletions
diff --git a/bin/offline.cpp b/bin/offline.cpp
index a0adb6c2aa..7d69273b51 100644
--- a/bin/offline.cpp
+++ b/bin/offline.cpp
@@ -40,7 +40,7 @@ int main(int, char * []) {
std::cout << status.completedResourceCount << " / " << status.requiredResourceCount
<< " resources"
- << (status.requiredResourceCountIsIndeterminate ? " (indeterminate); " : "; ")
+ << (status.requiredResourceCountIsPrecise ? "; " : " (indeterminate); ")
<< status.completedResourceSize << " bytes downloaded"
<< " (" << bytesPerSecond << " bytes/sec)"
<< std::endl;
diff --git a/include/mbgl/storage/offline.hpp b/include/mbgl/storage/offline.hpp
index dd63cf968f..2bc286dbab 100644
--- a/include/mbgl/storage/offline.hpp
+++ b/include/mbgl/storage/offline.hpp
@@ -99,20 +99,21 @@ public:
/**
* The number of resources that are known to be required for this region. See the
- * documentation for `requiredResourceCountIsIndeterminate` for an important caveat
+ * documentation for `requiredResourceCountIsPrecise` for an important caveat
* about this number.
*/
uint64_t requiredResourceCount = 0;
/**
- * This property is true during early phases of an offline download, when the total
- * required resource count is unknown and requiredResourceCount is merely a lower
+ * This property is true when the value of requiredResourceCount is a precise
+ * count of the number of required resources, and false when it is merely a lower
* bound.
*
- * Specifically, it is true before until the style and tile sources have been
- * downloaded, and false thereafter.
+ * Specifically, it is false during early phases of an offline download. Once
+ * style and tile sources have been downloaded, it is possible to calculate the
+ * precise number of required resources, at which point it is set to true.
*/
- bool requiredResourceCountIsIndeterminate = true;
+ bool requiredResourceCountIsPrecise = false;
bool complete() const {
return completedResourceCount == requiredResourceCount;
diff --git a/platform/default/mbgl/storage/offline_download.cpp b/platform/default/mbgl/storage/offline_download.cpp
index 27bf3b8c5b..228942f1f0 100644
--- a/platform/default/mbgl/storage/offline_download.cpp
+++ b/platform/default/mbgl/storage/offline_download.cpp
@@ -94,7 +94,7 @@ OfflineRegionStatus OfflineDownload::getStatus() const {
StyleParser parser;
parser.parse(*styleResponse->data);
- result.requiredResourceCountIsIndeterminate = false;
+ result.requiredResourceCountIsPrecise = true;
for (const auto& source : parser.sources) {
switch (source->type) {
@@ -109,7 +109,7 @@ OfflineRegionStatus OfflineDownload::getStatus() const {
result.requiredResourceCount += tileResources(source->type, source->tileSize,
*StyleParser::parseTileJSON(*sourceResponse->data, source->url, source->type, source->tileSize)).size();
} else {
- result.requiredResourceCountIsIndeterminate = true;
+ result.requiredResourceCountIsPrecise = false;
}
}
break;
@@ -137,7 +137,7 @@ void OfflineDownload::activateDownload() {
requiredSourceURLs.clear();
ensureResource(Resource::style(definition.styleURL), [&] (Response styleResponse) {
- status.requiredResourceCountIsIndeterminate = false;
+ status.requiredResourceCountIsPrecise = true;
StyleParser parser;
parser.parse(*styleResponse.data);
@@ -153,7 +153,7 @@ void OfflineDownload::activateDownload() {
if (source->getInfo()) {
ensureTiles(type, tileSize, *source->getInfo());
} else {
- status.requiredResourceCountIsIndeterminate = true;
+ status.requiredResourceCountIsPrecise = false;
requiredSourceURLs.insert(url);
ensureResource(Resource::source(url), [=] (Response sourceResponse) {
@@ -161,7 +161,7 @@ void OfflineDownload::activateDownload() {
requiredSourceURLs.erase(url);
if (requiredSourceURLs.empty()) {
- status.requiredResourceCountIsIndeterminate = false;
+ status.requiredResourceCountIsPrecise = true;
}
});
}
diff --git a/test/storage/offline_download.cpp b/test/storage/offline_download.cpp
index 6de14d37b2..33c9c5a95d 100644
--- a/test/storage/offline_download.cpp
+++ b/test/storage/offline_download.cpp
@@ -63,7 +63,7 @@ TEST(OfflineDownload, NoSubresources) {
if (status.complete()) {
EXPECT_EQ(1, status.completedResourceCount);
EXPECT_EQ(test.size, status.completedResourceSize);
- EXPECT_FALSE(status.requiredResourceCountIsIndeterminate);
+ EXPECT_TRUE(status.requiredResourceCountIsPrecise);
test.loop.stop();
}
};
@@ -102,7 +102,7 @@ TEST(OfflineDownload, InlineSource) {
if (status.complete()) {
EXPECT_EQ(2, status.completedResourceCount);
EXPECT_EQ(test.size, status.completedResourceSize);
- EXPECT_FALSE(status.requiredResourceCountIsIndeterminate);
+ EXPECT_TRUE(status.requiredResourceCountIsPrecise);
test.loop.stop();
}
};
@@ -136,7 +136,7 @@ TEST(OfflineDownload, GeoJSONSource) {
if (status.complete()) {
EXPECT_EQ(2, status.completedResourceCount);
EXPECT_EQ(test.size, status.completedResourceSize);
- EXPECT_FALSE(status.requiredResourceCountIsIndeterminate);
+ EXPECT_TRUE(status.requiredResourceCountIsPrecise);
test.loop.stop();
}
};
@@ -200,7 +200,7 @@ TEST(OfflineDownload, Activate) {
EXPECT_EQ(status.requiredResourceCount, computedStatus.requiredResourceCount);
EXPECT_EQ(status.completedResourceCount, computedStatus.completedResourceCount);
EXPECT_EQ(status.completedResourceSize, computedStatus.completedResourceSize);
- EXPECT_FALSE(status.requiredResourceCountIsIndeterminate);
+ EXPECT_TRUE(status.requiredResourceCountIsPrecise);
test.loop.stop();
}
@@ -224,7 +224,7 @@ TEST(OfflineDownload, GetStatusNoResources) {
EXPECT_EQ(0, status.completedResourceCount);
EXPECT_EQ(0, status.completedResourceSize);
EXPECT_EQ(1, status.requiredResourceCount);
- EXPECT_TRUE(status.requiredResourceCountIsIndeterminate);
+ EXPECT_FALSE(status.requiredResourceCountIsPrecise);
EXPECT_FALSE(status.complete());
}
@@ -245,7 +245,7 @@ TEST(OfflineDownload, GetStatusStyleComplete) {
EXPECT_EQ(1, status.completedResourceCount);
EXPECT_EQ(test.size, status.completedResourceSize);
EXPECT_EQ(260, status.requiredResourceCount);
- EXPECT_TRUE(status.requiredResourceCountIsIndeterminate);
+ EXPECT_FALSE(status.requiredResourceCountIsPrecise);
EXPECT_FALSE(status.complete());
}
@@ -270,7 +270,7 @@ TEST(OfflineDownload, GetStatusStyleAndSourceComplete) {
EXPECT_EQ(2, status.completedResourceCount);
EXPECT_EQ(test.size, status.completedResourceSize);
EXPECT_EQ(261, status.requiredResourceCount);
- EXPECT_FALSE(status.requiredResourceCountIsIndeterminate);
+ EXPECT_TRUE(status.requiredResourceCountIsPrecise);
EXPECT_FALSE(status.complete());
}