diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2019-06-13 18:56:35 +0300 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2019-06-25 20:10:21 +0300 |
commit | 1a9e07e4ed930f33a28d0eac800bccaa2a84570e (patch) | |
tree | da680c8cb603e4427c42ac90ad54480011ffeec2 /platform | |
parent | 8367c2ed5c32eae1364e5fc27e734631cf69aae3 (diff) | |
download | qtlocation-mapboxgl-1a9e07e4ed930f33a28d0eac800bccaa2a84570e.tar.gz |
[core] DefaultFileSource dynamic support for cache-only requests
Diffstat (limited to 'platform')
-rw-r--r-- | platform/default/src/mbgl/storage/default_file_source.cpp | 13 | ||||
-rw-r--r-- | platform/default/src/mbgl/storage/file_source.cpp | 2 |
2 files changed, 10 insertions, 5 deletions
diff --git a/platform/default/src/mbgl/storage/default_file_source.cpp b/platform/default/src/mbgl/storage/default_file_source.cpp index 19932d8d00..dc4b2908a8 100644 --- a/platform/default/src/mbgl/storage/default_file_source.cpp +++ b/platform/default/src/mbgl/storage/default_file_source.cpp @@ -224,17 +224,22 @@ private: std::unordered_map<int64_t, std::unique_ptr<OfflineDownload>> downloads; }; -DefaultFileSource::DefaultFileSource(const std::string& cachePath, const std::string& assetPath) - : DefaultFileSource(cachePath, std::make_unique<AssetFileSource>(assetPath)) { +DefaultFileSource::DefaultFileSource(const std::string& cachePath, const std::string& assetPath, bool supportCacheOnlyRequests_) + : DefaultFileSource(cachePath, std::make_unique<AssetFileSource>(assetPath), supportCacheOnlyRequests_) { } -DefaultFileSource::DefaultFileSource(const std::string& cachePath, std::unique_ptr<FileSource>&& assetFileSource_) +DefaultFileSource::DefaultFileSource(const std::string& cachePath, std::unique_ptr<FileSource>&& assetFileSource_, bool supportCacheOnlyRequests_) : assetFileSource(std::move(assetFileSource_)) - , impl(std::make_unique<util::Thread<Impl>>("DefaultFileSource", assetFileSource, cachePath)) { + , impl(std::make_unique<util::Thread<Impl>>("DefaultFileSource", assetFileSource, cachePath)) + , supportCacheOnlyRequests(supportCacheOnlyRequests_) { } DefaultFileSource::~DefaultFileSource() = default; +bool DefaultFileSource::supportsCacheOnlyRequests() const { + return supportCacheOnlyRequests; +} + void DefaultFileSource::setAPIBaseURL(const std::string& baseURL) { impl->actor().invoke(&Impl::setAPIBaseURL, baseURL); diff --git a/platform/default/src/mbgl/storage/file_source.cpp b/platform/default/src/mbgl/storage/file_source.cpp index a7bbe82f5a..4e800cc8f4 100644 --- a/platform/default/src/mbgl/storage/file_source.cpp +++ b/platform/default/src/mbgl/storage/file_source.cpp @@ -6,7 +6,7 @@ namespace mbgl { std::shared_ptr<FileSource> FileSource::createPlatformFileSource(const ResourceOptions& options) { - auto fileSource = std::make_shared<DefaultFileSource>(options.cachePath(), options.assetPath()); + auto fileSource = std::make_shared<DefaultFileSource>(options.cachePath(), options.assetPath(), options.supportsCacheOnlyRequests()); fileSource->setAccessToken(options.accessToken()); fileSource->setAPIBaseURL(options.baseURL()); return fileSource; |