summaryrefslogtreecommitdiff
path: root/include/mbgl/storage/default_file_source.hpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-02-05 17:10:13 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-02-10 15:40:20 -0800
commitc3c4c7b9a695ad1dbebe57242ba071103fe9a567 (patch)
treee205ecdc6a2f6318c6ba6308b5aa8baacc42f481 /include/mbgl/storage/default_file_source.hpp
parente9302c797f68c7e48b908b87b126045c8c5e5209 (diff)
downloadqtlocation-mapboxgl-c3c4c7b9a695ad1dbebe57242ba071103fe9a567.tar.gz
[core] Interface and implementation for offline
Diffstat (limited to 'include/mbgl/storage/default_file_source.hpp')
-rw-r--r--include/mbgl/storage/default_file_source.hpp77
1 files changed, 77 insertions, 0 deletions
diff --git a/include/mbgl/storage/default_file_source.hpp b/include/mbgl/storage/default_file_source.hpp
index d8fc4b98a3..e7ffe125b1 100644
--- a/include/mbgl/storage/default_file_source.hpp
+++ b/include/mbgl/storage/default_file_source.hpp
@@ -2,6 +2,9 @@
#define MBGL_STORAGE_DEFAULT_FILE_SOURCE
#include <mbgl/storage/file_source.hpp>
+#include <mbgl/storage/offline.hpp>
+
+#include <vector>
namespace mbgl {
@@ -22,6 +25,80 @@ public:
std::unique_ptr<FileRequest> request(const Resource&, Callback) override;
+ /*
+ * Retrieve all regions in the offline database.
+ *
+ * The query will be executed asynchronously and the results passed to the given
+ * callback, which will be executed on the database thread; it is the responsibility
+ * of the SDK bindings to re-execute a user-provided callback on the main thread.
+ */
+ void listOfflineRegions(std::function<void (std::exception_ptr,
+ optional<std::vector<OfflineRegion>>)>);
+
+ /*
+ * Create an offline region in the database.
+ *
+ * When the initial database queries have completed, the provided callback will be
+ * executed on the database thread; it is the responsibility of the SDK bindings
+ * to re-execute a user-provided callback on the main thread.
+ *
+ * Note that the resulting region will be in an inactive download state; to begin
+ * downloading resources, call `setOfflineRegionDownloadState(OfflineRegionDownloadState::Active)`,
+ * optionally registering an `OfflineRegionObserver` beforehand.
+ */
+ void createOfflineRegion(const OfflineRegionDefinition& definition,
+ const OfflineRegionMetadata& metadata,
+ std::function<void (std::exception_ptr,
+ optional<OfflineRegion>)>);
+
+ /*
+ * Register an observer to be notified when the state of the region changes.
+ */
+ void setOfflineRegionObserver(OfflineRegion&, std::unique_ptr<OfflineRegionObserver>);
+
+ /*
+ * Pause or resume downloading of regional resources.
+ */
+ void setOfflineRegionDownloadState(OfflineRegion&, OfflineRegionDownloadState);
+
+ /*
+ * Retrieve the current status of the region. The query will be executed
+ * asynchronously and the results passed to the given callback, which will be
+ * executed on the database thread; it is the responsibility of the SDK bindings
+ * to re-execute a user-provided callback on the main thread.
+ */
+ void getOfflineRegionStatus(OfflineRegion&, std::function<void (std::exception_ptr,
+ optional<OfflineRegionStatus>)>) const;
+
+ /*
+ * Initiate the removal of offline region from the database.
+ *
+ * All resources required by the region, but not also required by other regions, will
+ * become eligible for removal for space-optimization. Because the offline database is
+ * also used for ambient usage-based caching, and offline resources may still be useful
+ * for ambient usage, they are not immediately removed. To immediately remove resources
+ * not used by any extant region, call removeUnusedOfflineResources().
+ *
+ * Note that this method takes ownership of the input, reflecting the fact that once
+ * region deletion is initiated, it is not legal to perform further actions with the
+ * region.
+ *
+ * When the operation is complete or encounters an error, the given callback will be
+ * executed on the database thread; it is the responsibility of the SDK bindings
+ * to re-execute a user-provided callback on the main thread.
+ */
+ void deleteOfflineRegion(OfflineRegion&&, std::function<void (std::exception_ptr)>);
+
+ /*
+ * Remove all resources in the database that are not required by any region, thus
+ * optimizing the disk space used by the offline database.
+ *
+ * When the operation is complete or encounters an error, the given callback will be
+ * executed on the database thread; it is the responsibility of the SDK bindings
+ * to re-execute a user-provided callback on the main thread.
+ */
+ void removeUnusedOfflineResources(std::function<void (std::exception_ptr)>);
+
// For testing only.
void put(const Resource&, const Response&);
void goOffline();