summaryrefslogtreecommitdiff
path: root/src/mbgl/storage
diff options
context:
space:
mode:
authorHuyen Chau Nguyen <hello@chau-nguyen.de>2018-10-17 20:12:28 +0200
committerHuyen Chau Nguyen <hello@chau-nguyen.de>2018-10-23 12:47:10 +0200
commit1e3a744d2296feb2fd6b5d7da324bb31b6ee17c6 (patch)
tree1d3f1975ba993fc4b03caf649190d501eb9e5d41 /src/mbgl/storage
parent9afe75aa76c02db21209e8f92b09be4b596a3983 (diff)
downloadqtlocation-mapboxgl-1e3a744d2296feb2fd6b5d7da324bb31b6ee17c6.tar.gz
[core] add priorities to resources
- priorities can be low or regular - offline downloads should have low priority to not throttle "regular requests"
Diffstat (limited to 'src/mbgl/storage')
-rw-r--r--src/mbgl/storage/resource.cpp32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/mbgl/storage/resource.cpp b/src/mbgl/storage/resource.cpp
index c51db44548..aca53138ff 100644
--- a/src/mbgl/storage/resource.cpp
+++ b/src/mbgl/storage/resource.cpp
@@ -39,44 +39,49 @@ static std::string getTileBBox(int32_t x, int32_t y, int8_t z) {
util::toString(max.x) + "," + util::toString(max.y));
}
-Resource Resource::style(const std::string& url) {
+Resource Resource::style(const std::string& url, const Priority priority) {
return Resource {
Resource::Kind::Style,
- url
+ url,
+ priority
};
}
-Resource Resource::source(const std::string& url) {
+Resource Resource::source(const std::string& url, const Priority priority) {
return Resource {
Resource::Kind::Source,
- url
+ url,
+ priority
};
}
-Resource Resource::image(const std::string& url) {
+Resource Resource::image(const std::string& url, const Priority priority) {
return Resource {
Resource::Kind::Image,
- url
+ url,
+ priority
};
}
-Resource Resource::spriteImage(const std::string& base, float pixelRatio) {
+Resource Resource::spriteImage(const std::string& base, float pixelRatio, const Priority priority) {
util::URL url(base);
return Resource{ Resource::Kind::SpriteImage,
base.substr(0, url.path.first + url.path.second) +
(pixelRatio > 1 ? "@2x" : "") + ".png" +
- base.substr(url.query.first, url.query.second) };
+ base.substr(url.query.first, url.query.second),
+ priority };
}
-Resource Resource::spriteJSON(const std::string& base, float pixelRatio) {
+Resource Resource::spriteJSON(const std::string& base, float pixelRatio, const Priority priority) {
util::URL url(base);
return Resource{ Resource::Kind::SpriteJSON,
base.substr(0, url.path.first + url.path.second) +
(pixelRatio > 1 ? "@2x" : "") + ".json" +
- base.substr(url.query.first, url.query.second) };
+ base.substr(url.query.first, url.query.second),
+ priority };
}
-Resource Resource::glyphs(const std::string& urlTemplate, const FontStack& fontStack, const std::pair<uint16_t, uint16_t>& glyphRange) {
+Resource Resource::glyphs(const std::string& urlTemplate, const FontStack& fontStack, const std::pair<uint16_t, uint16_t>& glyphRange, const Priority priority) {
return Resource {
Resource::Kind::Glyphs,
util::replaceTokens(urlTemplate, [&](const std::string& token) -> optional<std::string> {
@@ -87,7 +92,8 @@ Resource Resource::glyphs(const std::string& urlTemplate, const FontStack& fontS
} else {
return {};
}
- })
+ }),
+ priority
};
}
@@ -97,6 +103,7 @@ Resource Resource::tile(const std::string& urlTemplate,
int32_t y,
int8_t z,
Tileset::Scheme scheme,
+ const Priority priority,
LoadingMethod loadingMethod) {
bool supportsRatio = urlTemplate.find("{ratio}") != std::string::npos;
if (scheme == Tileset::Scheme::TMS) {
@@ -126,6 +133,7 @@ Resource Resource::tile(const std::string& urlTemplate,
return {};
}
}),
+ priority,
Resource::TileData {
urlTemplate,
uint8_t(supportsRatio && pixelRatio > 1.0 ? 2 : 1),