summaryrefslogtreecommitdiff
path: root/include/mbgl/storage
diff options
context:
space:
mode:
authorLeith Bade <leith@mapbox.com>2014-12-02 19:40:07 +1100
committerLeith Bade <leith@mapbox.com>2014-12-02 19:41:50 +1100
commit2b865224127c2b5126e089e6384795282c3601cd (patch)
tree2d17d5834b1f48c5d49d0f17a5b914fe875c078d /include/mbgl/storage
parent9a8c018a32c351954f96cfe587c3f108ce4a986b (diff)
downloadqtlocation-mapboxgl-2b865224127c2b5126e089e6384795282c3601cd.tar.gz
Share asset_request between platforms
Diffstat (limited to 'include/mbgl/storage')
-rw-r--r--include/mbgl/storage/asset_request.hpp27
-rw-r--r--include/mbgl/storage/asset_request_baton.hpp35
2 files changed, 62 insertions, 0 deletions
diff --git a/include/mbgl/storage/asset_request.hpp b/include/mbgl/storage/asset_request.hpp
new file mode 100644
index 0000000000..3114d41ad2
--- /dev/null
+++ b/include/mbgl/storage/asset_request.hpp
@@ -0,0 +1,27 @@
+#ifndef MBGL_STORAGE_ASSET_REQUEST
+#define MBGL_STORAGE_ASSET_REQUEST
+
+#include <mbgl/storage/base_request.hpp>
+
+namespace mbgl {
+
+typedef struct uv_loop_s uv_loop_t;
+
+struct AssetRequestBaton;
+
+class AssetRequest : public BaseRequest {
+public:
+ AssetRequest(const std::string &path, uv_loop_t *loop);
+ ~AssetRequest();
+
+ void cancel();
+
+private:
+ AssetRequestBaton *ptr = nullptr;
+
+ friend struct AssetRequestBaton;
+};
+
+}
+
+#endif
diff --git a/include/mbgl/storage/asset_request_baton.hpp b/include/mbgl/storage/asset_request_baton.hpp
new file mode 100644
index 0000000000..b9c3372595
--- /dev/null
+++ b/include/mbgl/storage/asset_request_baton.hpp
@@ -0,0 +1,35 @@
+#ifndef MBGL_STORAGE_ASSET_REQUEST_BATON
+#define MBGL_STORAGE_ASSET_REQUEST_BATON
+
+#include <mbgl/storage/asset_request.hpp>
+
+#include <uv.h>
+
+namespace mbgl {
+
+struct AssetRequestBaton {
+ AssetRequestBaton(AssetRequest *request_, const std::string &path, uv_loop_t *loop);
+ ~AssetRequestBaton();
+
+ const unsigned long thread_id;
+ AssetRequest *request = nullptr;
+ std::unique_ptr<uv_async_t> async_run;
+ std::string path;
+ bool canceled = false;
+
+ void cancel();
+ static void notify_error(uv_async_t *async, const int code, const char *message);
+ static void cleanup(uv_async_t *async);
+
+ // IMPLEMENT THIS PLATFORM SPECIFIC FUNCTION:
+
+ // Called to load the asset. Platform-specific implementation.
+ static void run(uv_async_t *async);
+
+};
+
+
+}
+
+
+#endif