summaryrefslogtreecommitdiff
path: root/include/mbgl/platform/request.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/mbgl/platform/request.hpp')
-rw-r--r--include/mbgl/platform/request.hpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/include/mbgl/platform/request.hpp b/include/mbgl/platform/request.hpp
new file mode 100644
index 0000000000..7d2da8888c
--- /dev/null
+++ b/include/mbgl/platform/request.hpp
@@ -0,0 +1,48 @@
+#ifndef MBGL_PLATFORM_REQUEST
+#define MBGL_PLATFORM_REQUEST
+
+#include <string>
+#include <functional>
+#include <memory>
+#include <atomic>
+
+#include <mbgl/util/noncopyable.hpp>
+
+// Forward definition.
+typedef struct uv_loop_s uv_loop_t;
+typedef struct uv_async_s uv_async_t;
+
+namespace uv {
+class loop;
+}
+
+namespace mbgl {
+namespace platform {
+
+struct Response;
+
+class Request : public std::enable_shared_from_this<Request>, private util::noncopyable {
+public:
+ Request(const std::string &url,
+ std::function<void(Response *)> callback,
+ std::shared_ptr<uv::loop> loop);
+ ~Request();
+
+ void complete();
+
+private:
+ static void complete(uv_async_t *async);
+
+public:
+ const std::string url;
+ std::unique_ptr<Response> res;
+ std::atomic<bool> cancelled;
+
+public:
+ uv_async_t *async = nullptr;
+ std::shared_ptr<uv::loop> loop;
+};
+}
+}
+
+#endif