summaryrefslogtreecommitdiff
path: root/include/mbgl/storage
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <tmpsantos@gmail.com>2019-06-14 15:11:32 +0300
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2019-06-18 16:26:51 +0300
commit68e3cbacbc35ae6cd6c1e0fe2ab59ed262c32786 (patch)
treea8eb342508e1b089d05eb4c35bb1ce424ecee088 /include/mbgl/storage
parent78eeffe1717a37a91e6c59681421a20c52a4d003 (diff)
downloadqtlocation-mapboxgl-68e3cbacbc35ae6cd6c1e0fe2ab59ed262c32786.tar.gz
[core] Add method for setting a maximum size for the ambient cache
- Removed this parameter from the constructor, now that we have a method to set it. - Add the method and enforce the limits if the ambient cache exceeds the size.
Diffstat (limited to 'include/mbgl/storage')
-rw-r--r--include/mbgl/storage/default_file_source.hpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/include/mbgl/storage/default_file_source.hpp b/include/mbgl/storage/default_file_source.hpp
index ddbdab8cf3..f46f41771e 100644
--- a/include/mbgl/storage/default_file_source.hpp
+++ b/include/mbgl/storage/default_file_source.hpp
@@ -30,12 +30,8 @@ public:
* regions, we want the database to remain fairly small (order tens or low hundreds
* of megabytes).
*/
- DefaultFileSource(const std::string& cachePath,
- const std::string& assetPath,
- uint64_t maximumCacheSize = util::DEFAULT_MAX_CACHE_SIZE);
- DefaultFileSource(const std::string& cachePath,
- std::unique_ptr<FileSource>&& assetFileSource,
- uint64_t maximumCacheSize = util::DEFAULT_MAX_CACHE_SIZE);
+ DefaultFileSource(const std::string& cachePath, const std::string& assetPath);
+ DefaultFileSource(const std::string& cachePath, std::unique_ptr<FileSource>&& assetFileSource);
~DefaultFileSource() override;
bool supportsCacheOnlyRequests() const override {
@@ -220,6 +216,28 @@ public:
*/
void clearAmbientCache(std::function<void (std::exception_ptr)>);
+ /*
+ * Sets the maximum size in bytes for the ambient cache.
+ *
+ * This call is potentially expensive because it will try
+ * to trim the data in case the database is larger than the
+ * size defined. The size of offline regions are not affected
+ * by this settings, but the ambient cache will always try
+ * to not exceed the maximum size defined, taking into account
+ * the current size for the offline regions.
+ *
+ * If the maximum size is set to 50 MB and 40 MB are already
+ * used by offline regions, the cache size will be effectively
+ * 10 MB.
+ *
+ * Setting the size to 0 will disable the cache if there is no
+ * offline region on the database.
+ *
+ * This method should always be called before using the database,
+ * otherwise the default maximum size will be used.
+ */
+ void setMaximumAmbientCacheSize(uint64_t size, std::function<void (std::exception_ptr)> callback);
+
// For testing only.
void setOnlineStatus(bool);