summaryrefslogtreecommitdiff
path: root/include/mbgl/storage/file_source.hpp
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-03-04 12:32:14 +0100
committerKonstantin Käfer <mail@kkaefer.com>2015-03-06 08:21:47 -0800
commit9781785ab73e8394e8b92625cc4741952f47955d (patch)
tree1b9e6b86c1c9ca19bb1bf1c52bcd0e41410ced66 /include/mbgl/storage/file_source.hpp
parent8c0acecbe362be4a40638491b67ee5fe3d23a65e (diff)
downloadqtlocation-mapboxgl-9781785ab73e8394e8b92625cc4741952f47955d.tar.gz
scope Requests to an Environment object for easier cancelation
we are now scoping all file requests to an environment object. The FileSource implementation treats this as an opaque pointer, but allows canceling all Requests that are associated with that pointer. This is necessary to abort all file requests that originated from a particular Map object. Aborting a file request is different from canceling a file request: A canceled request doesn't have its callback called, while an aborted request will have its callback called with an error, indicating that the environment is going to be shut down.
Diffstat (limited to 'include/mbgl/storage/file_source.hpp')
-rw-r--r--include/mbgl/storage/file_source.hpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/include/mbgl/storage/file_source.hpp b/include/mbgl/storage/file_source.hpp
index 8517d6e4a6..30e88c39f6 100644
--- a/include/mbgl/storage/file_source.hpp
+++ b/include/mbgl/storage/file_source.hpp
@@ -15,6 +15,7 @@ typedef struct uv_loop_s uv_loop_t;
namespace mbgl {
class Request;
+class Environment;
class FileSource : private util::noncopyable {
protected:
@@ -27,12 +28,19 @@ public:
// 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 Request *request(const Resource &resource, uv_loop_t *loop, const Environment &env,
+ Callback callback) = 0;
virtual void cancel(Request *request) = 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;
+ virtual void request(const Resource &resource, const Environment &env, Callback callback) = 0;
+
+ // This can be called from any thread. All requests with the environment pointer env should be
+ // notified as errored. Note that this is /different/ from canceling requests; a canceled
+ // request's callback is never called, while an aborted request's callback is called with
+ // a error message.
+ virtual void abort(const Environment &env) = 0;
};
}