notifications on request cancellation
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#ifndef MBGL_STORAGE_BASE_REQUEST
|
||||
#define MBGL_STORAGE_BASE_REQUEST
|
||||
|
||||
#include <mbgl/storage/request_callback.hpp>
|
||||
#include <mbgl/util/ptr.hpp>
|
||||
|
||||
#include <string>
|
||||
@@ -15,8 +16,6 @@ namespace mbgl {
|
||||
|
||||
class Response;
|
||||
class Request;
|
||||
using Callback = std::function<void(const Response &)>;
|
||||
|
||||
|
||||
class BaseRequest {
|
||||
private:
|
||||
@@ -43,7 +42,6 @@ private:
|
||||
// This object may hold a shared_ptr to itself. It does this to prevent destruction of this object
|
||||
// while a request is in progress.
|
||||
util::ptr<BaseRequest> self;
|
||||
|
||||
std::forward_list<std::unique_ptr<Callback>> callbacks;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#ifndef MBGL_STORAGE_REQUEST
|
||||
#define MBGL_STORAGE_REQUEST
|
||||
|
||||
#include <mbgl/storage/request_callback.hpp>
|
||||
#include <mbgl/storage/response.hpp>
|
||||
#include <mbgl/util/ptr.hpp>
|
||||
|
||||
#include <functional>
|
||||
#include <forward_list>
|
||||
|
||||
typedef struct uv_loop_s uv_loop_t;
|
||||
@@ -12,7 +12,6 @@ typedef struct uv_loop_s uv_loop_t;
|
||||
namespace mbgl {
|
||||
|
||||
class BaseRequest;
|
||||
using Callback = std::function<void(const Response &)>;
|
||||
|
||||
class Request {
|
||||
private:
|
||||
@@ -25,7 +24,8 @@ public:
|
||||
Request(const util::ptr<BaseRequest> &base);
|
||||
~Request();
|
||||
|
||||
void onload(Callback cb);
|
||||
void onload(CompletedCallback cb);
|
||||
void oncancel(AbortedCallback cb);
|
||||
void cancel();
|
||||
|
||||
private:
|
||||
|
||||
22
include/mbgl/storage/request_callback.hpp
Normal file
22
include/mbgl/storage/request_callback.hpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef MBGL_STORAGE_REQUEST_CALLBACK
|
||||
#define MBGL_STORAGE_REQUEST_CALLBACK
|
||||
|
||||
#include <mbgl/util/variant.hpp>
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class Response;
|
||||
|
||||
using CompletedCallback = std::function<void(const Response &)>;
|
||||
using AbortedCallback = std::function<void()>;
|
||||
|
||||
using Callback = mapbox::util::variant<
|
||||
CompletedCallback,
|
||||
AbortedCallback
|
||||
>;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user