summaryrefslogtreecommitdiff
path: root/include/mbgl/storage/file_source.hpp
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-01-16 14:04:41 +0100
committerKonstantin Käfer <mail@kkaefer.com>2015-02-04 10:46:37 +0100
commitb9bf66e67ed1d0d1b1d3163255cab099a6ba4a95 (patch)
tree93ad6df882442e18d9a9771d4b4f06a0a764a0a9 /include/mbgl/storage/file_source.hpp
parent3bfea8bf30c978173f1ec2fab6f89d6b33afea86 (diff)
downloadqtlocation-mapboxgl-b9bf66e67ed1d0d1b1d3163255cab099a6ba4a95.tar.gz
rewrite storage layer to be independent of the Map's event loop
Diffstat (limited to 'include/mbgl/storage/file_source.hpp')
-rw-r--r--include/mbgl/storage/file_source.hpp31
1 files changed, 20 insertions, 11 deletions
diff --git a/include/mbgl/storage/file_source.hpp b/include/mbgl/storage/file_source.hpp
index 23a1462ae8..8517d6e4a6 100644
--- a/include/mbgl/storage/file_source.hpp
+++ b/include/mbgl/storage/file_source.hpp
@@ -1,29 +1,38 @@
#ifndef MBGL_STORAGE_FILE_SOURCE
#define MBGL_STORAGE_FILE_SOURCE
+#include "response.hpp"
+#include "resource.hpp"
+
#include <mbgl/util/noncopyable.hpp>
-#include <mbgl/storage/resource_type.hpp>
-#include <mbgl/storage/request.hpp>
+#include <mbgl/util/std.hpp>
+#include <mbgl/util/util.hpp>
-#include <string>
#include <functional>
typedef struct uv_loop_s uv_loop_t;
-
namespace mbgl {
-class FileSource : public util::noncopyable {
+class Request;
+
+class FileSource : private util::noncopyable {
+protected:
+ MBGL_STORE_THREAD(tid)
+
public:
virtual ~FileSource() = default;
- virtual void setLoop(uv_loop_t*) = 0;
- virtual bool hasLoop() = 0;
- virtual void clearLoop() = 0;
+ using Callback = std::function<void(const Response &)>;
+
+ // These can be called from any thread. The callback will be invoked in the loop.
+ // You can only cancel a request from the same thread it was created in.
+ virtual Request *request(const Resource &resource, uv_loop_t *loop, Callback callback) = 0;
+ virtual void cancel(Request *request) = 0;
- virtual void setBase(std::string) = 0;
- virtual std::unique_ptr<Request> request(ResourceType type, const std::string &url) = 0;
- virtual void prepare(std::function<void()> fn) = 0;
+ // These can be called from any thread. The callback will be invoked in an arbitrary other thread.
+ // You cannot cancel these requests.
+ virtual void request(const Resource &resource, Callback callback) = 0;
};
}