summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-02-25 17:50:12 +0200
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-02-25 23:15:47 +0200
commit7c48611f9ee04e1320e1667ea0dae7c355a9935b (patch)
tree31b46f31184833165ee1d53f137e674fcc3069fb
parent3c05bd984ada9e146e614165f009b9b45fb05992 (diff)
downloadqtlocation-mapboxgl-7c48611f9ee04e1320e1667ea0dae7c355a9935b.tar.gz
[core] Consolidate file source keys in the generic FileSource header
Thus we do not need to include specific headers to use `{set|get}Property` API with key constants.
-rw-r--r--include/mbgl/storage/database_file_source.hpp6
-rw-r--r--include/mbgl/storage/file_source.hpp20
-rw-r--r--include/mbgl/storage/online_file_source.hpp14
-rw-r--r--platform/default/src/mbgl/storage/offline_download.cpp2
-rw-r--r--render-test/file_source.cpp2
-rw-r--r--test/storage/offline_download.test.cpp2
-rw-r--r--test/storage/online_file_source.test.cpp10
7 files changed, 28 insertions, 28 deletions
diff --git a/include/mbgl/storage/database_file_source.hpp b/include/mbgl/storage/database_file_source.hpp
index 9fb9ccdb3e..81e5315fd8 100644
--- a/include/mbgl/storage/database_file_source.hpp
+++ b/include/mbgl/storage/database_file_source.hpp
@@ -7,12 +7,6 @@
namespace mbgl {
-// Properties that may be supported by database file sources.
-
-// Property to set database mode. When set, database opens in read-only mode; database opens in read-write-create mode
-// otherwise. type: bool
-constexpr const char* READ_ONLY_MODE_KEY = "read-only-mode";
-
class ResourceOptions;
// TODO: Split DatabaseFileSource into Ambient cache and Database interfaces.
diff --git a/include/mbgl/storage/file_source.hpp b/include/mbgl/storage/file_source.hpp
index f05f1473e9..baf3fabcfa 100644
--- a/include/mbgl/storage/file_source.hpp
+++ b/include/mbgl/storage/file_source.hpp
@@ -84,4 +84,24 @@ protected:
FileSource() = default;
};
+// Properties that may be supported by online file sources:
+
+// Property name to set / get an access token.
+// type: std::string
+constexpr const char* ACCESS_TOKEN_KEY = "access-token";
+
+// Property name to set / get base url.
+// type: std::string
+constexpr const char* API_BASE_URL_KEY = "api-base-url";
+
+// Property name to set / get maximum number of concurrent requests.
+// type: unsigned
+constexpr const char* MAX_CONCURRENT_REQUESTS_KEY = "max-concurrent-requests";
+
+// Properties that may be supported by database file sources:
+
+// Property to set database mode. When set, database opens in read-only mode; database opens in read-write-create mode
+// otherwise. type: bool
+constexpr const char* READ_ONLY_MODE_KEY = "read-only-mode";
+
} // namespace mbgl
diff --git a/include/mbgl/storage/online_file_source.hpp b/include/mbgl/storage/online_file_source.hpp
index 8969d21871..3c61f20d2e 100644
--- a/include/mbgl/storage/online_file_source.hpp
+++ b/include/mbgl/storage/online_file_source.hpp
@@ -7,20 +7,6 @@ namespace mbgl {
class ResourceTransform;
-// Properties that may be supported by online file sources.
-
-// Property name to set / get an access token.
-// type: std::string
-constexpr const char* ACCESS_TOKEN_KEY = "access-token";
-
-// Property name to set / get base url.
-// type: std::string
-constexpr const char* API_BASE_URL_KEY = "api-base-url";
-
-// Property name to set / get maximum number of concurrent requests.
-// type: unsigned
-constexpr const char* MAX_CONCURRENT_REQUESTS_KEY = "max-concurrent-requests";
-
class OnlineFileSource : public FileSource {
public:
OnlineFileSource();
diff --git a/platform/default/src/mbgl/storage/offline_download.cpp b/platform/default/src/mbgl/storage/offline_download.cpp
index 87927c5b98..89fd100aa7 100644
--- a/platform/default/src/mbgl/storage/offline_download.cpp
+++ b/platform/default/src/mbgl/storage/offline_download.cpp
@@ -373,7 +373,7 @@ void OfflineDownload::continueDownload() {
if (resourcesToBeMarkedAsUsed.size() >= kMarkBatchSize) markPendingUsedResources();
uint32_t maxConcurrentRequests = util::DEFAULT_MAXIMUM_CONCURRENT_REQUESTS;
- auto value = onlineFileSource.getProperty("max-concurrent-requests");
+ auto value = onlineFileSource.getProperty(MAX_CONCURRENT_REQUESTS_KEY);
if (uint64_t* maxRequests = value.getUint()) {
maxConcurrentRequests = static_cast<uint32_t>(*maxRequests);
}
diff --git a/render-test/file_source.cpp b/render-test/file_source.cpp
index f72bc08e37..b93325f901 100644
--- a/render-test/file_source.cpp
+++ b/render-test/file_source.cpp
@@ -20,7 +20,7 @@ ProxyFileSource::ProxyFileSource(std::shared_ptr<FileSource> defaultResourceLoad
assert(defaultResourceLoader);
if (offline) {
auto dbfs = FileSourceManager::get()->getFileSource(FileSourceType::Database, options);
- dbfs->setProperty("read-only-mode", true);
+ dbfs->setProperty(READ_ONLY_MODE_KEY, true);
}
}
diff --git a/test/storage/offline_download.test.cpp b/test/storage/offline_download.test.cpp
index a15c96d391..ff0965039e 100644
--- a/test/storage/offline_download.test.cpp
+++ b/test/storage/offline_download.test.cpp
@@ -385,7 +385,7 @@ TEST(OfflineDownload, DoesNotFloodTheFileSourceWithRequests) {
fileSource.respond(Resource::Kind::Style, test.response("style.json"));
test.loop.runOnce();
- EXPECT_EQ(*fileSource.getProperty("max-concurrent-requests").getUint(), fileSource.requests.size());
+ EXPECT_EQ(*fileSource.getProperty(MAX_CONCURRENT_REQUESTS_KEY).getUint(), fileSource.requests.size());
}
TEST(OfflineDownload, GetStatusNoResources) {
diff --git a/test/storage/online_file_source.test.cpp b/test/storage/online_file_source.test.cpp
index 88dbf519f8..9d8fbfab64 100644
--- a/test/storage/online_file_source.test.cpp
+++ b/test/storage/online_file_source.test.cpp
@@ -449,7 +449,7 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(LowHighPriorityRequests)) {
const std::size_t NUM_REQUESTS = 3;
NetworkStatus::Set(NetworkStatus::Status::Offline);
- fs.setProperty("max-concurrent-requests", 1u);
+ fs.setProperty(MAX_CONCURRENT_REQUESTS_KEY, 1u);
// After DefaultFileSource was split, OnlineFileSource lives on a separate
// thread. Pause OnlineFileSource, so that messages are queued for processing.
fs.pause();
@@ -492,7 +492,7 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(LowHighPriorityRequestsMany)) {
int correct_regular = 0;
NetworkStatus::Set(NetworkStatus::Status::Offline);
- fs.setProperty("max-concurrent-requests", 1u);
+ fs.setProperty(MAX_CONCURRENT_REQUESTS_KEY, 1u);
fs.pause();
std::vector<std::unique_ptr<AsyncRequest>> collector;
@@ -542,10 +542,10 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(MaximumConcurrentRequests)) {
util::RunLoop loop;
OnlineFileSource fs;
- ASSERT_EQ(*fs.getProperty("max-concurrent-requests").getUint(), 20u);
+ ASSERT_EQ(*fs.getProperty(MAX_CONCURRENT_REQUESTS_KEY).getUint(), 20u);
- fs.setProperty("max-concurrent-requests", 10u);
- ASSERT_EQ(*fs.getProperty("max-concurrent-requests").getUint(), 10u);
+ fs.setProperty(MAX_CONCURRENT_REQUESTS_KEY, 10u);
+ ASSERT_EQ(*fs.getProperty(MAX_CONCURRENT_REQUESTS_KEY).getUint(), 10u);
}
TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RequestSameUrlMultipleTimes)) {