From 91895b9aecedc9c080e18b2e7304f5d2a8da340a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Fri, 27 May 2016 13:37:41 +0200 Subject: [core] only perform optional requests if the FileSource supports it --- include/mbgl/storage/default_file_source.hpp | 4 ++++ include/mbgl/storage/file_source.hpp | 8 ++++++++ 2 files changed, 12 insertions(+) (limited to 'include') diff --git a/include/mbgl/storage/default_file_source.hpp b/include/mbgl/storage/default_file_source.hpp index e77befda1b..235e738254 100644 --- a/include/mbgl/storage/default_file_source.hpp +++ b/include/mbgl/storage/default_file_source.hpp @@ -26,6 +26,10 @@ public: uint64_t maximumCacheSize = util::DEFAULT_MAX_CACHE_SIZE); ~DefaultFileSource() override; + bool supportsOptionalRequests() const override { + return true; + } + void setAccessToken(const std::string&); std::string getAccessToken() const; diff --git a/include/mbgl/storage/file_source.hpp b/include/mbgl/storage/file_source.hpp index 88e0336187..404c683fdb 100644 --- a/include/mbgl/storage/file_source.hpp +++ b/include/mbgl/storage/file_source.hpp @@ -23,6 +23,14 @@ public: // If the request is cancelled before the callback is executed, the callback will // not be executed. virtual std::unique_ptr request(const Resource&, Callback) = 0; + + // When a file source supports optional requests, it must return true. + // Optional requests are requests that aren't as urgent, but could be useful, e.g. + // to cover part of the map while loading. The FileSource should only do cheap actions to + // retrieve the data, e.g. load it from a cache, but not from the internet. + virtual bool supportsOptionalRequests() const { + return false; + } }; } // namespace mbgl -- cgit v1.2.1