summaryrefslogtreecommitdiff
path: root/include/mbgl/storage/file_source.hpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2015-11-12 15:51:45 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2015-11-16 12:25:47 -0800
commit7137239cbddb13e1c33240d13002973b5a222775 (patch)
tree99ad3ca2d8b5230eba3f5bacefe63098568dbdd4 /include/mbgl/storage/file_source.hpp
parent1caf89c32b80dc300b1fd349a2ece4557890c727 (diff)
downloadqtlocation-mapboxgl-7137239cbddb13e1c33240d13002973b5a222775.tar.gz
[core] Use std::unique_ptr for FileSource request
Diffstat (limited to 'include/mbgl/storage/file_source.hpp')
-rw-r--r--include/mbgl/storage/file_source.hpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/include/mbgl/storage/file_source.hpp b/include/mbgl/storage/file_source.hpp
index 0bb5c0fcaf..0167eccc08 100644
--- a/include/mbgl/storage/file_source.hpp
+++ b/include/mbgl/storage/file_source.hpp
@@ -1,31 +1,33 @@
#ifndef MBGL_STORAGE_FILE_SOURCE
#define MBGL_STORAGE_FILE_SOURCE
-#include "response.hpp"
-#include "resource.hpp"
+#include <mbgl/storage/response.hpp>
+#include <mbgl/storage/resource.hpp>
#include <mbgl/util/noncopyable.hpp>
-#include <mbgl/util/util.hpp>
#include <functional>
+#include <memory>
namespace mbgl {
-class Request;
+class FileRequest : private util::noncopyable {
+public:
+ virtual ~FileRequest() = default;
+};
class FileSource : private util::noncopyable {
-protected:
- MBGL_STORE_THREAD(tid)
-
public:
virtual ~FileSource() = default;
using Callback = std::function<void (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&, Callback) = 0;
- virtual void cancel(Request*) = 0;
+ // Request a resource. The callback will be called asynchronously, in the same
+ // thread as the request was made. This thread must have an active RunLoop. The
+ // request may be cancelled before completion by releasing the returned FileRequest.
+ // If the request is cancelled before the callback is executed, the callback will
+ // not be executed.
+ virtual std::unique_ptr<FileRequest> request(const Resource&, Callback) = 0;
};
}