summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mbgl/storage/resource.hpp18
-rw-r--r--src/mbgl/storage/resource.cpp32
-rw-r--r--src/mbgl/tile/tile_loader_impl.hpp1
-rw-r--r--test/storage/default_file_source.test.cpp6
-rw-r--r--test/storage/online_file_source.test.cpp7
5 files changed, 27 insertions, 37 deletions
diff --git a/include/mbgl/storage/resource.hpp b/include/mbgl/storage/resource.hpp
index d828877e10..40c4c836b1 100644
--- a/include/mbgl/storage/resource.hpp
+++ b/include/mbgl/storage/resource.hpp
@@ -54,12 +54,10 @@ public:
Resource(Kind kind_,
std::string url_,
- Priority priority_ = Resource::Priority::Regular,
optional<TileData> tileData_ = {},
LoadingMethod loadingMethod_ = LoadingMethod::All)
: kind(kind_),
loadingMethod(loadingMethod_),
- priority(priority_),
url(std::move(url_)),
tileData(std::move(tileData_)) {
}
@@ -69,28 +67,26 @@ public:
bool hasLoadingMethod(LoadingMethod method);
- static Resource style(const std::string& url, const Priority priority = Resource::Priority::Regular);
- static Resource source(const std::string& url, const Priority priority = Resource::Priority::Regular);
+ static Resource style(const std::string& url);
+ static Resource source(const std::string& url);
static Resource tile(const std::string& urlTemplate,
float pixelRatio,
int32_t x,
int32_t y,
int8_t z,
Tileset::Scheme scheme,
- const Priority priority = Resource::Priority::Regular,
LoadingMethod = LoadingMethod::All);
static Resource glyphs(const std::string& urlTemplate,
const FontStack& fontStack,
- const std::pair<uint16_t, uint16_t>& glyphRange,
- const Priority priority = Resource::Priority::Regular);
- static Resource spriteImage(const std::string& base, float pixelRatio, const Priority priority = Resource::Priority::Regular);
- static Resource spriteJSON(const std::string& base, float pixelRatio, const Priority priority = Resource::Priority::Regular);
- static Resource image(const std::string& url, const Priority priority = Resource::Priority::Regular);
+ const std::pair<uint16_t, uint16_t>& glyphRange);
+ static Resource spriteImage(const std::string& base, float pixelRatio);
+ static Resource spriteJSON(const std::string& base, float pixelRatio);
+ static Resource image(const std::string& url);
Kind kind;
LoadingMethod loadingMethod;
Usage usage{ Usage::Online };
- Priority priority;
+ Priority priority{ Priority::Regular };
std::string url;
// Includes auxiliary data if this is a tile request.
diff --git a/src/mbgl/storage/resource.cpp b/src/mbgl/storage/resource.cpp
index 9ccedb6919..613a09452b 100644
--- a/src/mbgl/storage/resource.cpp
+++ b/src/mbgl/storage/resource.cpp
@@ -39,49 +39,44 @@ 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, const Priority priority) {
+Resource Resource::style(const std::string& url) {
return Resource {
Resource::Kind::Style,
- url,
- priority
+ url
};
}
-Resource Resource::source(const std::string& url, const Priority priority) {
+Resource Resource::source(const std::string& url) {
return Resource {
Resource::Kind::Source,
- url,
- priority
+ url
};
}
-Resource Resource::image(const std::string& url, const Priority priority) {
+Resource Resource::image(const std::string& url) {
return Resource {
Resource::Kind::Image,
- url,
- priority
+ url
};
}
-Resource Resource::spriteImage(const std::string& base, float pixelRatio, const Priority priority) {
+Resource Resource::spriteImage(const std::string& base, float pixelRatio) {
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),
- priority };
+ base.substr(url.query.first, url.query.second)};
}
-Resource Resource::spriteJSON(const std::string& base, float pixelRatio, const Priority priority) {
+Resource Resource::spriteJSON(const std::string& base, float pixelRatio) {
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),
- priority };
+ base.substr(url.query.first, url.query.second)};
}
-Resource Resource::glyphs(const std::string& urlTemplate, const FontStack& fontStack, const std::pair<uint16_t, uint16_t>& glyphRange, const Priority priority) {
+Resource Resource::glyphs(const std::string& urlTemplate, const FontStack& fontStack, const std::pair<uint16_t, uint16_t>& glyphRange) {
return Resource {
Resource::Kind::Glyphs,
util::replaceTokens(urlTemplate, [&](const std::string& token) -> optional<std::string> {
@@ -92,8 +87,7 @@ Resource Resource::glyphs(const std::string& urlTemplate, const FontStack& fontS
} else {
return {};
}
- }),
- priority
+ })
};
}
@@ -103,7 +97,6 @@ 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) {
@@ -133,7 +126,6 @@ Resource Resource::tile(const std::string& urlTemplate,
return {};
}
}),
- priority,
Resource::TileData {
urlTemplate,
uint8_t(supportsRatio && pixelRatio > 1.0 ? 2 : 1),
diff --git a/src/mbgl/tile/tile_loader_impl.hpp b/src/mbgl/tile/tile_loader_impl.hpp
index bbe579ed00..7c02021083 100644
--- a/src/mbgl/tile/tile_loader_impl.hpp
+++ b/src/mbgl/tile/tile_loader_impl.hpp
@@ -23,7 +23,6 @@ TileLoader<T>::TileLoader(T& tile_,
id.canonical.y,
id.canonical.z,
tileset.scheme,
- Resource::Priority::Regular,
Resource::LoadingMethod::CacheOnly)),
fileSource(parameters.fileSource) {
assert(!request);
diff --git a/test/storage/default_file_source.test.cpp b/test/storage/default_file_source.test.cpp
index 64b23e315c..8853b3dd13 100644
--- a/test/storage/default_file_source.test.cpp
+++ b/test/storage/default_file_source.test.cpp
@@ -251,7 +251,7 @@ TEST(DefaultFileSource, OptionalNonExpired) {
util::RunLoop loop;
DefaultFileSource fs(":memory:", ".");
- const Resource optionalResource { Resource::Unknown, "http://127.0.0.1:3000/test", Resource::Priority::Regular, {}, Resource::LoadingMethod::CacheOnly };
+ const Resource optionalResource { Resource::Unknown, "http://127.0.0.1:3000/test", {}, Resource::LoadingMethod::CacheOnly };
using namespace std::chrono_literals;
@@ -281,7 +281,7 @@ TEST(DefaultFileSource, OptionalExpired) {
util::RunLoop loop;
DefaultFileSource fs(":memory:", ".");
- const Resource optionalResource { Resource::Unknown, "http://127.0.0.1:3000/test", Resource::Priority::Regular, {}, Resource::LoadingMethod::CacheOnly };
+ const Resource optionalResource { Resource::Unknown, "http://127.0.0.1:3000/test", {}, Resource::LoadingMethod::CacheOnly };
using namespace std::chrono_literals;
@@ -327,7 +327,7 @@ TEST(DefaultFileSource, OptionalNotFound) {
util::RunLoop loop;
DefaultFileSource fs(":memory:", ".");
- const Resource optionalResource { Resource::Unknown, "http://127.0.0.1:3000/test", Resource::Priority::Regular, {}, Resource::LoadingMethod::CacheOnly };
+ const Resource optionalResource { Resource::Unknown, "http://127.0.0.1:3000/test", {}, Resource::LoadingMethod::CacheOnly };
using namespace std::chrono_literals;
diff --git a/test/storage/online_file_source.test.cpp b/test/storage/online_file_source.test.cpp
index 756a7a92d1..9d4b4fc190 100644
--- a/test/storage/online_file_source.test.cpp
+++ b/test/storage/online_file_source.test.cpp
@@ -481,7 +481,7 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(LowHighPriorityRequestsMany)) {
for (int num_reqs = 0; num_reqs < 20; num_reqs++) {
if (num_reqs % 2 == 0) {
- std::unique_ptr<AsyncRequest> req = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/load/" + std::to_string(num_reqs), Resource::Priority::Regular }, [&](Response) {
+ std::unique_ptr<AsyncRequest> req = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/load/" + std::to_string(num_reqs) }, [&](Response) {
response_counter++;
if (response_counter <= 10) { // count the high priority requests that arrive late correctly
@@ -491,7 +491,10 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(LowHighPriorityRequestsMany)) {
collector.push_back(std::move(req));
}
else {
- std::unique_ptr<AsyncRequest> req = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/load/" + std::to_string(num_reqs), Resource::Priority::Low }, [&](Response) {
+ Resource resource = { Resource::Unknown, "http://127.0.0.1:3000/load/" + std::to_string(num_reqs) };
+ resource.setPriority(Resource::Priority::Low);
+
+ std::unique_ptr<AsyncRequest> req = fs.request(std::move(resource), [&](Response) {
response_counter++;
if (response_counter > 10) { // count the low priority requests that arrive late correctly