summaryrefslogtreecommitdiff
path: root/src/mbgl/storage
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-01-11 12:52:41 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-01-13 13:40:31 -0800
commit86c8446d3a4390ff6577d070ac8b5fa3ad3c5cd1 (patch)
treeef10190d3fca34ff72b2473816901088b0b85ac2 /src/mbgl/storage
parent2126e34e52dc5dd94c5a3907b240e62ee17d1e70 (diff)
downloadqtlocation-mapboxgl-86c8446d3a4390ff6577d070ac8b5fa3ad3c5cd1.tar.gz
[core] Simplify asset:// implementation
* Move asset:// URL handling to DefaultFileSource. * AssetFileSource implements FileSource interface and follows familiar implementation patterns. * Move default implementation to platform/default, zip implementation to platform/android. * Don't bother with modified / expires / etag -- assets are not cached so it doesn't matter. * Don't bother with interleaving individual IO calls on the implementation thread. That adds a lot of complexity for very little benefit.
Diffstat (limited to 'src/mbgl/storage')
-rw-r--r--src/mbgl/storage/asset_context_base.hpp20
-rw-r--r--src/mbgl/storage/asset_file_source.hpp26
2 files changed, 26 insertions, 20 deletions
diff --git a/src/mbgl/storage/asset_context_base.hpp b/src/mbgl/storage/asset_context_base.hpp
deleted file mode 100644
index 92138615b5..0000000000
--- a/src/mbgl/storage/asset_context_base.hpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef MBGL_STORAGE_ASSET_CONTEXT_BASE
-#define MBGL_STORAGE_ASSET_CONTEXT_BASE
-
-#include <mbgl/storage/request_base.hpp>
-
-namespace mbgl {
-
-class AssetContextBase {
-public:
- static std::unique_ptr<AssetContextBase> createContext();
-
- virtual ~AssetContextBase() = default;
- virtual RequestBase* createRequest(const std::string& url,
- RequestBase::Callback,
- const std::string& assetRoot) = 0;
-};
-
-} // namespace mbgl
-
-#endif // MBGL_STORAGE_ASSET_CONTEXT_BASE
diff --git a/src/mbgl/storage/asset_file_source.hpp b/src/mbgl/storage/asset_file_source.hpp
new file mode 100644
index 0000000000..11a430e124
--- /dev/null
+++ b/src/mbgl/storage/asset_file_source.hpp
@@ -0,0 +1,26 @@
+#ifndef MBGL_STORAGE_ASSET_FILE_SOURCE
+#define MBGL_STORAGE_ASSET_FILE_SOURCE
+
+#include <mbgl/storage/file_source.hpp>
+
+namespace mbgl {
+
+namespace util {
+template <typename T> class Thread;
+} // namespace util
+
+class AssetFileSource : public FileSource {
+public:
+ AssetFileSource(const std::string& assetRoot);
+ ~AssetFileSource() override;
+
+ std::unique_ptr<FileRequest> request(const Resource&, Callback) override;
+
+private:
+ class Impl;
+ std::unique_ptr<util::Thread<Impl>> thread;
+};
+
+} // namespace mbgl
+
+#endif // MBGL_STORAGE_ASSET_FILE_SOURCE