summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-03-23 17:31:14 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-03-24 10:54:32 -0700
commit169755e89a72b103fab100ccd101013e8eef1481 (patch)
tree5716e13519fe2b7f5c91cccbdbf14635a1ef117d
parent7ff074889e826f766028ba582beb677b39d16bec (diff)
downloadqtlocation-mapboxgl-169755e89a72b103fab100ccd101013e8eef1481.tar.gz
[core] Unify FileRequest and WorkRequest
-rw-r--r--include/mbgl/storage/default_file_source.hpp2
-rw-r--r--include/mbgl/storage/file_source.hpp10
-rw-r--r--include/mbgl/storage/online_file_source.hpp2
-rw-r--r--include/mbgl/util/async_request.hpp12
-rw-r--r--include/mbgl/util/run_loop.hpp4
-rw-r--r--include/mbgl/util/work_request.hpp6
-rw-r--r--platform/android/src/asset_file_source.cpp6
-rw-r--r--platform/default/asset_file_source.cpp13
-rw-r--r--platform/default/default_file_source.cpp16
-rw-r--r--platform/default/mbgl/storage/offline_download.cpp11
-rw-r--r--platform/default/mbgl/storage/offline_download.hpp6
-rw-r--r--platform/default/online_file_source.cpp28
-rw-r--r--platform/node/src/node_map.cpp13
-rw-r--r--platform/node/src/node_map.hpp2
-rw-r--r--src/mbgl/annotation/annotation_tile.cpp2
-rw-r--r--src/mbgl/annotation/annotation_tile.hpp2
-rw-r--r--src/mbgl/map/map_context.hpp4
-rw-r--r--src/mbgl/source/source.hpp4
-rw-r--r--src/mbgl/sprite/sprite_store.cpp4
-rw-r--r--src/mbgl/storage/asset_file_source.hpp2
-rw-r--r--src/mbgl/text/glyph_pbf.hpp4
-rw-r--r--src/mbgl/tile/geojson_tile.cpp2
-rw-r--r--src/mbgl/tile/geojson_tile.hpp2
-rw-r--r--src/mbgl/tile/geometry_tile.hpp4
-rw-r--r--src/mbgl/tile/raster_tile_data.hpp7
-rw-r--r--src/mbgl/tile/vector_tile.cpp2
-rw-r--r--src/mbgl/tile/vector_tile.hpp2
-rw-r--r--src/mbgl/tile/vector_tile_data.hpp7
-rw-r--r--src/mbgl/util/thread.hpp2
-rw-r--r--src/mbgl/util/work_queue.cpp2
-rw-r--r--src/mbgl/util/work_queue.hpp4
-rw-r--r--src/mbgl/util/worker.cpp8
-rw-r--r--src/mbgl/util/worker.hpp4
-rw-r--r--test/include/mbgl/test/stub_file_source.hpp4
-rw-r--r--test/src/stub_file_source.cpp4
-rw-r--r--test/storage/asset_file_source.cpp14
-rw-r--r--test/storage/default_file_source.cpp16
-rw-r--r--test/storage/http_cancel.cpp4
-rw-r--r--test/storage/http_error.cpp4
-rw-r--r--test/storage/http_expires.cpp10
-rw-r--r--test/storage/http_header_parsing.cpp4
-rw-r--r--test/storage/http_load.cpp2
-rw-r--r--test/storage/http_other_loop.cpp2
-rw-r--r--test/storage/http_reading.cpp12
-rw-r--r--test/storage/http_retry_network_status.cpp6
-rw-r--r--test/storage/http_timeout.cpp2
-rw-r--r--test/util/async_task.cpp2
-rw-r--r--test/util/thread.cpp4
48 files changed, 137 insertions, 152 deletions
diff --git a/include/mbgl/storage/default_file_source.hpp b/include/mbgl/storage/default_file_source.hpp
index dd67cff9b8..76d60fce70 100644
--- a/include/mbgl/storage/default_file_source.hpp
+++ b/include/mbgl/storage/default_file_source.hpp
@@ -30,7 +30,7 @@ public:
void setAccessToken(const std::string&);
std::string getAccessToken() const;
- std::unique_ptr<FileRequest> request(const Resource&, Callback) override;
+ std::unique_ptr<AsyncRequest> request(const Resource&, Callback) override;
/*
* Retrieve all regions in the offline database.
diff --git a/include/mbgl/storage/file_source.hpp b/include/mbgl/storage/file_source.hpp
index 8d08315cd9..e572776af2 100644
--- a/include/mbgl/storage/file_source.hpp
+++ b/include/mbgl/storage/file_source.hpp
@@ -5,17 +5,13 @@
#include <mbgl/storage/resource.hpp>
#include <mbgl/util/noncopyable.hpp>
+#include <mbgl/util/async_request.hpp>
#include <functional>
#include <memory>
namespace mbgl {
-class FileRequest : private util::noncopyable {
-public:
- virtual ~FileRequest() = default;
-};
-
class FileSource : private util::noncopyable {
public:
virtual ~FileSource() = default;
@@ -24,10 +20,10 @@ public:
// 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.
+ // request may be cancelled before completion by releasing the returned AsyncRequest.
// 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;
+ virtual std::unique_ptr<AsyncRequest> request(const Resource&, Callback) = 0;
};
} // namespace mbgl
diff --git a/include/mbgl/storage/online_file_source.hpp b/include/mbgl/storage/online_file_source.hpp
index aceb141fb4..b52dce35f0 100644
--- a/include/mbgl/storage/online_file_source.hpp
+++ b/include/mbgl/storage/online_file_source.hpp
@@ -17,7 +17,7 @@ public:
void setAccessToken(const std::string& t) { accessToken = t; }
std::string getAccessToken() const { return accessToken; }
- std::unique_ptr<FileRequest> request(const Resource&, Callback) override;
+ std::unique_ptr<AsyncRequest> request(const Resource&, Callback) override;
private:
friend class OnlineFileRequestImpl;
diff --git a/include/mbgl/util/async_request.hpp b/include/mbgl/util/async_request.hpp
new file mode 100644
index 0000000000..9e85094966
--- /dev/null
+++ b/include/mbgl/util/async_request.hpp
@@ -0,0 +1,12 @@
+#pragma once
+
+#include <mbgl/util/noncopyable.hpp>
+
+namespace mbgl {
+
+class AsyncRequest : private util::noncopyable {
+public:
+ virtual ~AsyncRequest() = default;
+};
+
+} // namespace mbgl
diff --git a/include/mbgl/util/run_loop.hpp b/include/mbgl/util/run_loop.hpp
index fbc4794940..4e25caf554 100644
--- a/include/mbgl/util/run_loop.hpp
+++ b/include/mbgl/util/run_loop.hpp
@@ -58,7 +58,7 @@ public:
// Post the cancellable work fn(args...) to this RunLoop.
template <class Fn, class... Args>
- std::unique_ptr<WorkRequest>
+ std::unique_ptr<AsyncRequest>
invokeCancellable(Fn&& fn, Args&&... args) {
auto flag = std::make_shared<std::atomic<bool>>();
*flag = false;
@@ -76,7 +76,7 @@ public:
// Invoke fn(args...) on this RunLoop, then invoke callback(results...) on the current RunLoop.
template <class Fn, class Cb, class... Args>
- std::unique_ptr<WorkRequest>
+ std::unique_ptr<AsyncRequest>
invokeWithCallback(Fn&& fn, Cb&& callback, Args&&... args) {
auto flag = std::make_shared<std::atomic<bool>>();
*flag = false;
diff --git a/include/mbgl/util/work_request.hpp b/include/mbgl/util/work_request.hpp
index bd1d97ee70..f24e4b2e9f 100644
--- a/include/mbgl/util/work_request.hpp
+++ b/include/mbgl/util/work_request.hpp
@@ -1,7 +1,7 @@
#ifndef MBGL_UTIL_WORK_REQUEST
#define MBGL_UTIL_WORK_REQUEST
-#include <mbgl/util/noncopyable.hpp>
+#include <mbgl/util/async_request.hpp>
#include <memory>
@@ -9,11 +9,11 @@ namespace mbgl {
class WorkTask;
-class WorkRequest : public util::noncopyable {
+class WorkRequest : public AsyncRequest {
public:
using Task = std::shared_ptr<WorkTask>;
WorkRequest(Task);
- ~WorkRequest();
+ ~WorkRequest() override;
private:
std::shared_ptr<WorkTask> task;
diff --git a/platform/android/src/asset_file_source.cpp b/platform/android/src/asset_file_source.cpp
index d2aab30a52..96a0840ef5 100644
--- a/platform/android/src/asset_file_source.cpp
+++ b/platform/android/src/asset_file_source.cpp
@@ -35,7 +35,7 @@ struct ZipFileHolder {
namespace mbgl {
-class AssetFileRequest : public FileRequest {
+class AssetFileRequest : public AsyncRequest {
public:
AssetFileRequest(std::unique_ptr<WorkRequest> workRequest_)
: workRequest(std::move(workRequest_)) {
@@ -106,8 +106,8 @@ AssetFileSource::AssetFileSource(const std::string& root)
AssetFileSource::~AssetFileSource() = default;
-std::unique_ptr<FileRequest> AssetFileSource::request(const Resource& resource, Callback callback) {
- return std::make_unique<AssetFileRequest>(thread->invokeWithCallback(&Impl::request, callback, resource.url));
+std::unique_ptr<AsyncRequest> AssetFileSource::request(const Resource& resource, Callback callback) {
+ return thread->invokeWithCallback(&Impl::request, callback, resource.url);
}
}
diff --git a/platform/default/asset_file_source.cpp b/platform/default/asset_file_source.cpp
index 2573966c72..b9b52b7b86 100644
--- a/platform/default/asset_file_source.cpp
+++ b/platform/default/asset_file_source.cpp
@@ -12,15 +12,6 @@
namespace mbgl {
-class AssetFileRequest : public FileRequest {
-public:
- AssetFileRequest(std::unique_ptr<WorkRequest> workRequest_)
- : workRequest(std::move(workRequest_)) {
- }
-
- std::unique_ptr<WorkRequest> workRequest;
-};
-
class AssetFileSource::Impl {
public:
Impl(const std::string& root_)
@@ -72,8 +63,8 @@ AssetFileSource::AssetFileSource(const std::string& root)
AssetFileSource::~AssetFileSource() = default;
-std::unique_ptr<FileRequest> AssetFileSource::request(const Resource& resource, Callback callback) {
- return std::make_unique<AssetFileRequest>(thread->invokeWithCallback(&Impl::request, callback, resource.url));
+std::unique_ptr<AsyncRequest> AssetFileSource::request(const Resource& resource, Callback callback) {
+ return thread->invokeWithCallback(&Impl::request, callback, resource.url);
}
} // namespace mbgl
diff --git a/platform/default/default_file_source.cpp b/platform/default/default_file_source.cpp
index e3b785d086..d79d7877d1 100644
--- a/platform/default/default_file_source.cpp
+++ b/platform/default/default_file_source.cpp
@@ -45,7 +45,7 @@ public:
});
}
- std::unique_ptr<FileRequest> onlineRequest;
+ std::unique_ptr<AsyncRequest> onlineRequest;
};
Impl(const std::string& cachePath, uint64_t maximumCacheSize)
@@ -103,11 +103,11 @@ public:
getDownload(regionID).setState(state);
}
- void request(FileRequest* req, Resource resource, Callback callback) {
+ void request(AsyncRequest* req, Resource resource, Callback callback) {
tasks[req] = std::make_unique<Task>(resource, callback, this);
}
- void cancel(FileRequest* req) {
+ void cancel(AsyncRequest* req) {
tasks.erase(req);
}
@@ -131,7 +131,7 @@ private:
OfflineDatabase offlineDatabase;
OnlineFileSource onlineFileSource;
- std::unordered_map<FileRequest*, std::unique_ptr<Task>> tasks;
+ std::unordered_map<AsyncRequest*, std::unique_ptr<Task>> tasks;
std::unordered_map<int64_t, std::unique_ptr<OfflineDownload>> downloads;
};
@@ -153,20 +153,20 @@ std::string DefaultFileSource::getAccessToken() const {
return thread->invokeSync<std::string>(&Impl::getAccessToken);
}
-std::unique_ptr<FileRequest> DefaultFileSource::request(const Resource& resource, Callback callback) {
- class DefaultFileRequest : public FileRequest {
+std::unique_ptr<AsyncRequest> DefaultFileSource::request(const Resource& resource, Callback callback) {
+ class DefaultFileRequest : public AsyncRequest {
public:
DefaultFileRequest(Resource resource_, FileSource::Callback callback_, util::Thread<DefaultFileSource::Impl>& thread_)
: thread(thread_),
workRequest(thread.invokeWithCallback(&DefaultFileSource::Impl::request, callback_, this, resource_)) {
}
- ~DefaultFileRequest() {
+ ~DefaultFileRequest() override {
thread.invoke(&DefaultFileSource::Impl::cancel, this);
}
util::Thread<DefaultFileSource::Impl>& thread;
- std::unique_ptr<WorkRequest> workRequest;
+ std::unique_ptr<AsyncRequest> workRequest;
};
if (isAssetURL(resource.url)) {
diff --git a/platform/default/mbgl/storage/offline_download.cpp b/platform/default/mbgl/storage/offline_download.cpp
index 36b6f5d502..0dcffbd9cb 100644
--- a/platform/default/mbgl/storage/offline_download.cpp
+++ b/platform/default/mbgl/storage/offline_download.cpp
@@ -196,8 +196,7 @@ void OfflineDownload::activateDownload() {
}
void OfflineDownload::deactivateDownload() {
- workRequests.clear();
- fileRequests.clear();
+ requests.clear();
}
void OfflineDownload::ensureTiles(SourceType type, uint16_t tileSize, const SourceInfo& info) {
@@ -209,9 +208,9 @@ void OfflineDownload::ensureTiles(SourceType type, uint16_t tileSize, const Sour
void OfflineDownload::ensureResource(const Resource& resource, std::function<void (Response)> callback) {
status.requiredResourceCount++;
- auto workRequestsIt = workRequests.insert(workRequests.begin(), nullptr);
+ auto workRequestsIt = requests.insert(requests.begin(), nullptr);
*workRequestsIt = util::RunLoop::Get()->invokeCancellable([=] () {
- workRequests.erase(workRequestsIt);
+ requests.erase(workRequestsIt);
optional<std::pair<Response, uint64_t>> offlineResponse = offlineDatabase.getRegionResource(id, resource);
if (offlineResponse) {
@@ -238,14 +237,14 @@ void OfflineDownload::ensureResource(const Resource& resource, std::function<voi
return;
}
- auto fileRequestsIt = fileRequests.insert(fileRequests.begin(), nullptr);
+ auto fileRequestsIt = requests.insert(requests.begin(), nullptr);
*fileRequestsIt = onlineFileSource.request(resource, [=] (Response onlineResponse) {
if (onlineResponse.error) {
observer->responseError(*onlineResponse.error);
return;
}
- fileRequests.erase(fileRequestsIt);
+ requests.erase(fileRequestsIt);
if (callback) {
callback(onlineResponse);
diff --git a/platform/default/mbgl/storage/offline_download.hpp b/platform/default/mbgl/storage/offline_download.hpp
index d5ba801540..70c486d945 100644
--- a/platform/default/mbgl/storage/offline_download.hpp
+++ b/platform/default/mbgl/storage/offline_download.hpp
@@ -11,8 +11,7 @@ namespace mbgl {
class OfflineDatabase;
class FileSource;
-class WorkRequest;
-class FileRequest;
+class AsyncRequest;
class Resource;
class Response;
class SourceInfo;
@@ -56,8 +55,7 @@ private:
FileSource& onlineFileSource;
OfflineRegionStatus status;
std::unique_ptr<OfflineRegionObserver> observer;
- std::list<std::unique_ptr<WorkRequest>> workRequests;
- std::list<std::unique_ptr<FileRequest>> fileRequests;
+ std::list<std::unique_ptr<AsyncRequest>> requests;
std::set<std::string> requiredSourceURLs;
};
diff --git a/platform/default/online_file_source.cpp b/platform/default/online_file_source.cpp
index 944bcd56d5..dcd14add8b 100644
--- a/platform/default/online_file_source.cpp
+++ b/platform/default/online_file_source.cpp
@@ -26,14 +26,14 @@ class OnlineFileRequestImpl : public util::noncopyable {
public:
using Callback = std::function<void (Response)>;
- OnlineFileRequestImpl(FileRequest*, const Resource&, Callback, OnlineFileSource::Impl&);
+ OnlineFileRequestImpl(AsyncRequest*, const Resource&, Callback, OnlineFileSource::Impl&);
~OnlineFileRequestImpl();
void networkIsReachableAgain(OnlineFileSource::Impl&);
void schedule(OnlineFileSource::Impl&, optional<SystemTimePoint> expires);
void completed(OnlineFileSource::Impl&, Response);
- FileRequest* key;
+ AsyncRequest* key;
Resource resource;
HTTPRequestBase* request = nullptr;
util::Timer timer;
@@ -61,11 +61,11 @@ public:
NetworkStatus::Unsubscribe(&reachability);
}
- void request(FileRequest* key, Resource resource, Callback callback) {
+ void request(AsyncRequest* key, Resource resource, Callback callback) {
allRequests[key] = std::make_unique<OnlineFileRequestImpl>(key, resource, callback, *this);
}
- void cancel(FileRequest* key) {
+ void cancel(AsyncRequest* key) {
allRequests.erase(key);
if (activeRequests.erase(key)) {
activatePendingRequest();
@@ -110,7 +110,7 @@ public:
return;
}
- FileRequest* key = pendingRequestsList.front();
+ AsyncRequest* key = pendingRequestsList.front();
pendingRequestsList.pop_front();
pendingRequestsMap.erase(key);
@@ -138,10 +138,10 @@ private:
* Requests in any state are in `allRequests`. Requests in the pending state are in
* `pendingRequests`. Requests in the active state are in `activeRequests`.
*/
- std::unordered_map<FileRequest*, std::unique_ptr<OnlineFileRequestImpl>> allRequests;
- std::list<FileRequest*> pendingRequestsList;
- std::unordered_map<FileRequest*, std::list<FileRequest*>::iterator> pendingRequestsMap;
- std::unordered_set<FileRequest*> activeRequests;
+ std::unordered_map<AsyncRequest*, std::unique_ptr<OnlineFileRequestImpl>> allRequests;
+ std::list<AsyncRequest*> pendingRequestsList;
+ std::unordered_map<AsyncRequest*, std::list<AsyncRequest*>::iterator> pendingRequestsMap;
+ std::unordered_set<AsyncRequest*> activeRequests;
const std::unique_ptr<HTTPContextBase> httpContext { HTTPContextBase::createContext() };
util::AsyncTask reachability { std::bind(&Impl::networkIsReachableAgain, this) };
@@ -154,7 +154,7 @@ OnlineFileSource::OnlineFileSource()
OnlineFileSource::~OnlineFileSource() = default;
-std::unique_ptr<FileRequest> OnlineFileSource::request(const Resource& resource, Callback callback) {
+std::unique_ptr<AsyncRequest> OnlineFileSource::request(const Resource& resource, Callback callback) {
Resource res = resource;
switch (resource.kind) {
@@ -183,25 +183,25 @@ std::unique_ptr<FileRequest> OnlineFileSource::request(const Resource& resource,
break;
}
- class OnlineFileRequest : public FileRequest {
+ class OnlineFileRequest : public AsyncRequest {
public:
OnlineFileRequest(Resource resource_, FileSource::Callback callback_, util::Thread<OnlineFileSource::Impl>& thread_)
: thread(thread_),
workRequest(thread.invokeWithCallback(&OnlineFileSource::Impl::request, callback_, this, resource_)) {
}
- ~OnlineFileRequest() {
+ ~OnlineFileRequest() override {
thread.invoke(&OnlineFileSource::Impl::cancel, this);
}
util::Thread<OnlineFileSource::Impl>& thread;
- std::unique_ptr<WorkRequest> workRequest;
+ std::unique_ptr<AsyncRequest> workRequest;
};
return std::make_unique<OnlineFileRequest>(res, callback, *thread);
}
-OnlineFileRequestImpl::OnlineFileRequestImpl(FileRequest* key_, const Resource& resource_, Callback callback_, OnlineFileSource::Impl& impl)
+OnlineFileRequestImpl::OnlineFileRequestImpl(AsyncRequest* key_, const Resource& resource_, Callback callback_, OnlineFileSource::Impl& impl)
: key(key_),
resource(resource_),
callback(std::move(callback_)) {
diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp
index 5eefe402d6..953e485fe9 100644
--- a/platform/node/src/node_map.cpp
+++ b/platform/node/src/node_map.cpp
@@ -474,17 +474,10 @@ NodeMap::~NodeMap() {
if (valid) release();
}
-class NodeFileSourceRequest : public mbgl::FileRequest {
-public:
- std::unique_ptr<mbgl::WorkRequest> workRequest;
-};
-
-std::unique_ptr<mbgl::FileRequest> NodeMap::request(const mbgl::Resource& resource, Callback cb1) {
- auto req = std::make_unique<NodeFileSourceRequest>();
-
+std::unique_ptr<mbgl::AsyncRequest> NodeMap::request(const mbgl::Resource& resource, Callback cb1) {
// This function can be called from any thread. Make sure we're executing the
// JS implementation in the node event loop.
- req->workRequest = NodeRunLoop().invokeWithCallback([this] (mbgl::Resource res, Callback cb2) {
+ return NodeRunLoop().invokeWithCallback([this] (mbgl::Resource res, Callback cb2) {
Nan::HandleScope scope;
auto requestHandle = NodeRequest::Create(res, cb2)->ToObject();
@@ -493,8 +486,6 @@ std::unique_ptr<mbgl::FileRequest> NodeMap::request(const mbgl::Resource& resour
v8::Local<v8::Value> argv[] = { requestHandle, callbackHandle };
Nan::MakeCallback(handle()->GetInternalField(1)->ToObject(), "request", 2, argv);
}, cb1, resource);
-
- return std::move(req);
}
}
diff --git a/platform/node/src/node_map.hpp b/platform/node/src/node_map.hpp
index fe36ae7ed0..ac01c9b3a7 100644
--- a/platform/node/src/node_map.hpp
+++ b/platform/node/src/node_map.hpp
@@ -42,7 +42,7 @@ public:
NodeMap(v8::Local<v8::Object>);
~NodeMap();
- std::unique_ptr<mbgl::FileRequest> request(const mbgl::Resource&, Callback);
+ std::unique_ptr<mbgl::AsyncRequest> request(const mbgl::Resource&, Callback);
mbgl::HeadlessView view;
std::unique_ptr<mbgl::Map> map;
diff --git a/src/mbgl/annotation/annotation_tile.cpp b/src/mbgl/annotation/annotation_tile.cpp
index 3a038cc6eb..ee468902cb 100644
--- a/src/mbgl/annotation/annotation_tile.cpp
+++ b/src/mbgl/annotation/annotation_tile.cpp
@@ -37,7 +37,7 @@ AnnotationTileMonitor::~AnnotationTileMonitor() {
data.getAnnotationManager()->removeTileMonitor(*this);
}
-std::unique_ptr<FileRequest> AnnotationTileMonitor::monitorTile(const GeometryTileMonitor::Callback& callback_) {
+std::unique_ptr<AsyncRequest> AnnotationTileMonitor::monitorTile(const GeometryTileMonitor::Callback& callback_) {
callback = callback_;
data.getAnnotationManager()->addTileMonitor(*this);
return nullptr;
diff --git a/src/mbgl/annotation/annotation_tile.hpp b/src/mbgl/annotation/annotation_tile.hpp
index 8d0804d7f9..ca6b074c21 100644
--- a/src/mbgl/annotation/annotation_tile.hpp
+++ b/src/mbgl/annotation/annotation_tile.hpp
@@ -47,7 +47,7 @@ public:
~AnnotationTileMonitor();
void update(std::unique_ptr<GeometryTile>);
- std::unique_ptr<FileRequest> monitorTile(const GeometryTileMonitor::Callback&) override;
+ std::unique_ptr<AsyncRequest> monitorTile(const GeometryTileMonitor::Callback&) override;
TileID tileID;
diff --git a/src/mbgl/map/map_context.hpp b/src/mbgl/map/map_context.hpp
index 8570a40935..5e1d5e70ae 100644
--- a/src/mbgl/map/map_context.hpp
+++ b/src/mbgl/map/map_context.hpp
@@ -20,7 +20,7 @@ class View;
class MapData;
class Painter;
class SpriteImage;
-class FileRequest;
+class AsyncRequest;
class PropertyTransition;
namespace gl { class TexturePool; }
@@ -106,7 +106,7 @@ private:
std::string styleURL;
std::string styleJSON;
- std::unique_ptr<FileRequest> styleRequest;
+ std::unique_ptr<AsyncRequest> styleRequest;
Map::StillImageCallback callback;
size_t sourceCacheSize;
diff --git a/src/mbgl/source/source.hpp b/src/mbgl/source/source.hpp
index 52c7d76baf..c85e2ccd2d 100644
--- a/src/mbgl/source/source.hpp
+++ b/src/mbgl/source/source.hpp
@@ -23,7 +23,7 @@ namespace mbgl {
class StyleUpdateParameters;
class Painter;
class FileSource;
-class FileRequest;
+class AsyncRequest;
class TransformState;
class Tile;
struct ClipID;
@@ -107,7 +107,7 @@ private:
std::map<TileID, std::weak_ptr<TileData>> tileDataMap;
TileCache cache;
- std::unique_ptr<FileRequest> req;
+ std::unique_ptr<AsyncRequest> req;
Observer nullObserver;
Observer* observer = &nullObserver;
diff --git a/src/mbgl/sprite/sprite_store.cpp b/src/mbgl/sprite/sprite_store.cpp
index 869abab39f..ae8835534a 100644
--- a/src/mbgl/sprite/sprite_store.cpp
+++ b/src/mbgl/sprite/sprite_store.cpp
@@ -14,8 +14,8 @@ namespace mbgl {
struct SpriteStore::Loader {
std::shared_ptr<const std::string> image;
std::shared_ptr<const std::string> json;
- std::unique_ptr<FileRequest> jsonRequest;
- std::unique_ptr<FileRequest> spriteRequest;
+ std::unique_ptr<AsyncRequest> jsonRequest;
+ std::unique_ptr<AsyncRequest> spriteRequest;
};
SpriteStore::SpriteStore(float pixelRatio_)
diff --git a/src/mbgl/storage/asset_file_source.hpp b/src/mbgl/storage/asset_file_source.hpp
index 11a430e124..f6c11c1768 100644
--- a/src/mbgl/storage/asset_file_source.hpp
+++ b/src/mbgl/storage/asset_file_source.hpp
@@ -14,7 +14,7 @@ public:
AssetFileSource(const std::string& assetRoot);
~AssetFileSource() override;
- std::unique_ptr<FileRequest> request(const Resource&, Callback) override;
+ std::unique_ptr<AsyncRequest> request(const Resource&, Callback) override;
private:
class Impl;
diff --git a/src/mbgl/text/glyph_pbf.hpp b/src/mbgl/text/glyph_pbf.hpp
index 016792aae8..93b7c9db76 100644
--- a/src/mbgl/text/glyph_pbf.hpp
+++ b/src/mbgl/text/glyph_pbf.hpp
@@ -13,7 +13,7 @@
namespace mbgl {
class FontStack;
-class FileRequest;
+class AsyncRequest;
class FileSource;
class GlyphPBF : private util::noncopyable {
@@ -31,7 +31,7 @@ public:
private:
std::atomic<bool> parsed;
- std::unique_ptr<FileRequest> req;
+ std::unique_ptr<AsyncRequest> req;
GlyphStore::Observer* observer = nullptr;
};
diff --git a/src/mbgl/tile/geojson_tile.cpp b/src/mbgl/tile/geojson_tile.cpp
index fceae19619..31f2443ced 100644
--- a/src/mbgl/tile/geojson_tile.cpp
+++ b/src/mbgl/tile/geojson_tile.cpp
@@ -124,7 +124,7 @@ void GeoJSONTileMonitor::update() {
}
}
-std::unique_ptr<FileRequest>
+std::unique_ptr<AsyncRequest>
GeoJSONTileMonitor::monitorTile(const GeometryTileMonitor::Callback& cb) {
callback = cb;
update();
diff --git a/src/mbgl/tile/geojson_tile.hpp b/src/mbgl/tile/geojson_tile.hpp
index ce9c643de2..340d1053c6 100644
--- a/src/mbgl/tile/geojson_tile.hpp
+++ b/src/mbgl/tile/geojson_tile.hpp
@@ -58,7 +58,7 @@ public:
GeoJSONTileMonitor(mapbox::geojsonvt::GeoJSONVT*, const TileID&);
virtual ~GeoJSONTileMonitor();
- std::unique_ptr<FileRequest> monitorTile(const GeometryTileMonitor::Callback&) override;
+ std::unique_ptr<AsyncRequest> monitorTile(const GeometryTileMonitor::Callback&) override;
void setGeoJSONVT(mapbox::geojsonvt::GeoJSONVT*);
diff --git a/src/mbgl/tile/geometry_tile.hpp b/src/mbgl/tile/geometry_tile.hpp
index 6236e4e889..f1930ef3de 100644
--- a/src/mbgl/tile/geometry_tile.hpp
+++ b/src/mbgl/tile/geometry_tile.hpp
@@ -55,7 +55,7 @@ public:
virtual util::ptr<GeometryTileLayer> getLayer(const std::string&) const = 0;
};
-class FileRequest;
+class AsyncRequest;
class GeometryTileMonitor : private util::noncopyable {
public:
@@ -73,7 +73,7 @@ public:
*
* To cease monitoring, release the returned Request.
*/
- virtual std::unique_ptr<FileRequest> monitorTile(const Callback&) = 0;
+ virtual std::unique_ptr<AsyncRequest> monitorTile(const Callback&) = 0;
};
class GeometryTileFeatureExtractor {
diff --git a/src/mbgl/tile/raster_tile_data.hpp b/src/mbgl/tile/raster_tile_data.hpp
index 59eee88496..48af2fa5c2 100644
--- a/src/mbgl/tile/raster_tile_data.hpp
+++ b/src/mbgl/tile/raster_tile_data.hpp
@@ -7,9 +7,8 @@
namespace mbgl {
class FileSource;
-class FileRequest;
+class AsyncRequest;
class StyleLayer;
-class WorkRequest;
namespace gl { class TexturePool; }
class RasterTileData : public TileData {
@@ -29,9 +28,9 @@ public:
private:
gl::TexturePool& texturePool;
Worker& worker;
- std::unique_ptr<FileRequest> req;
+ std::unique_ptr<AsyncRequest> req;
std::unique_ptr<Bucket> bucket;
- std::unique_ptr<WorkRequest> workRequest;
+ std::unique_ptr<AsyncRequest> workRequest;
};
} // namespace mbgl
diff --git a/src/mbgl/tile/vector_tile.cpp b/src/mbgl/tile/vector_tile.cpp
index 8b58ade169..4c6027d36c 100644
--- a/src/mbgl/tile/vector_tile.cpp
+++ b/src/mbgl/tile/vector_tile.cpp
@@ -188,7 +188,7 @@ VectorTileMonitor::VectorTileMonitor(const TileID& tileID_, float pixelRatio_, c
fileSource(fileSource_) {
}
-std::unique_ptr<FileRequest> VectorTileMonitor::monitorTile(const GeometryTileMonitor::Callback& callback) {
+std::unique_ptr<AsyncRequest> VectorTileMonitor::monitorTile(const GeometryTileMonitor::Callback& callback) {
const Resource resource = Resource::tile(urlTemplate, pixelRatio, tileID.x, tileID.y, tileID.sourceZ);
return fileSource.request(resource, [callback, this](Response res) {
if (res.error) {
diff --git a/src/mbgl/tile/vector_tile.hpp b/src/mbgl/tile/vector_tile.hpp
index 48e501cbd7..4d330f17f2 100644
--- a/src/mbgl/tile/vector_tile.hpp
+++ b/src/mbgl/tile/vector_tile.hpp
@@ -65,7 +65,7 @@ class VectorTileMonitor : public GeometryTileMonitor {
public:
VectorTileMonitor(const TileID&, float pixelRatio, const std::string& urlTemplate, FileSource&);
- std::unique_ptr<FileRequest> monitorTile(const GeometryTileMonitor::Callback&) override;
+ std::unique_ptr<AsyncRequest> monitorTile(const GeometryTileMonitor::Callback&) override;
private:
TileID tileID;
diff --git a/src/mbgl/tile/vector_tile_data.hpp b/src/mbgl/tile/vector_tile_data.hpp
index d0b599c4cf..922ad35bcd 100644
--- a/src/mbgl/tile/vector_tile_data.hpp
+++ b/src/mbgl/tile/vector_tile_data.hpp
@@ -12,8 +12,7 @@
namespace mbgl {
class Style;
-class WorkRequest;
-class FileRequest;
+class AsyncRequest;
class GeometryTileMonitor;
class VectorTileData : public TileData {
@@ -42,8 +41,8 @@ private:
TileWorker tileWorker;
std::unique_ptr<GeometryTileMonitor> monitor;
- std::unique_ptr<FileRequest> tileRequest;
- std::unique_ptr<WorkRequest> workRequest;
+ std::unique_ptr<AsyncRequest> tileRequest;
+ std::unique_ptr<AsyncRequest> workRequest;
// Contains all the Bucket objects for the tile. Buckets are render
// objects and they get added by tile parsing operations.
diff --git a/src/mbgl/util/thread.hpp b/src/mbgl/util/thread.hpp
index d05748a003..33ca5aba6b 100644
--- a/src/mbgl/util/thread.hpp
+++ b/src/mbgl/util/thread.hpp
@@ -37,7 +37,7 @@ public:
// Invoke object->fn(args...) in the runloop thread, then invoke callback(result) in the current thread.
template <typename Fn, class Cb, class... Args>
- std::unique_ptr<WorkRequest>
+ std::unique_ptr<AsyncRequest>
invokeWithCallback(Fn fn, Cb&& callback, Args&&... args) {
return loop->invokeWithCallback(bind(fn), callback, std::forward<Args>(args)...);
}
diff --git a/src/mbgl/util/work_queue.cpp b/src/mbgl/util/work_queue.cpp
index 80c4af8778..d0033e3ca2 100644
--- a/src/mbgl/util/work_queue.cpp
+++ b/src/mbgl/util/work_queue.cpp
@@ -12,7 +12,7 @@ WorkQueue::WorkQueue() : runLoop(RunLoop::Get()) {
WorkQueue::~WorkQueue() {
assert(runLoop == RunLoop::Get());
- // Cancel all pending WorkRequests.
+ // Cancel all pending AsyncRequests.
while (!queue.empty()) {
queue.pop();
}
diff --git a/src/mbgl/util/work_queue.hpp b/src/mbgl/util/work_queue.hpp
index 6694352918..788cfb4d2d 100644
--- a/src/mbgl/util/work_queue.hpp
+++ b/src/mbgl/util/work_queue.hpp
@@ -2,7 +2,7 @@
#define MBGL_UTIL_WORK_QUEUE
#include <mbgl/util/noncopyable.hpp>
-#include <mbgl/util/work_request.hpp>
+#include <mbgl/util/async_request.hpp>
#include <functional>
#include <memory>
@@ -31,7 +31,7 @@ public:
private:
void pop(const std::function<void()>&);
- std::queue<std::unique_ptr<WorkRequest>> queue;
+ std::queue<std::unique_ptr<AsyncRequest>> queue;
std::mutex queueMutex;
RunLoop* runLoop;
diff --git a/src/mbgl/util/worker.cpp b/src/mbgl/util/worker.cpp
index bc6e4be3db..ec9d02573d 100644
--- a/src/mbgl/util/worker.cpp
+++ b/src/mbgl/util/worker.cpp
@@ -68,7 +68,7 @@ Worker::Worker(std::size_t count) {
Worker::~Worker() = default;
-std::unique_ptr<WorkRequest>
+std::unique_ptr<AsyncRequest>
Worker::parseRasterTile(std::unique_ptr<RasterBucket> bucket,
const std::shared_ptr<const std::string> data,
std::function<void(RasterTileParseResult)> callback) {
@@ -77,7 +77,7 @@ Worker::parseRasterTile(std::unique_ptr<RasterBucket> bucket,
data);
}
-std::unique_ptr<WorkRequest>
+std::unique_ptr<AsyncRequest>
Worker::parseGeometryTile(TileWorker& worker,
std::vector<std::unique_ptr<StyleLayer>> layers,
std::unique_ptr<GeometryTile> tile,
@@ -88,7 +88,7 @@ Worker::parseGeometryTile(TileWorker& worker,
std::move(layers), std::move(tile), config);
}
-std::unique_ptr<WorkRequest>
+std::unique_ptr<AsyncRequest>
Worker::parsePendingGeometryTileLayers(TileWorker& worker,
PlacementConfig config,
std::function<void(TileParseResult)> callback) {
@@ -97,7 +97,7 @@ Worker::parsePendingGeometryTileLayers(TileWorker& worker,
callback, &worker, config);
}
-std::unique_ptr<WorkRequest>
+std::unique_ptr<AsyncRequest>
Worker::redoPlacement(TileWorker& worker,
const std::unordered_map<std::string, std::unique_ptr<Bucket>>& buckets,
PlacementConfig config,
diff --git a/src/mbgl/util/worker.hpp b/src/mbgl/util/worker.hpp
index 96a7b27885..6630465631 100644
--- a/src/mbgl/util/worker.hpp
+++ b/src/mbgl/util/worker.hpp
@@ -10,7 +10,7 @@
namespace mbgl {
-class WorkRequest;
+class AsyncRequest;
class RasterBucket;
class GeometryTileLoader;
@@ -33,7 +33,7 @@ public:
// bind references to itself, and if and when those lambdas execute, the references
// will still be valid.
- using Request = std::unique_ptr<WorkRequest>;
+ using Request = std::unique_ptr<AsyncRequest>;
Request parseRasterTile(std::unique_ptr<RasterBucket> bucket,
std::shared_ptr<const std::string> data,
diff --git a/test/include/mbgl/test/stub_file_source.hpp b/test/include/mbgl/test/stub_file_source.hpp
index dbb584fdcc..477f72ed42 100644
--- a/test/include/mbgl/test/stub_file_source.hpp
+++ b/test/include/mbgl/test/stub_file_source.hpp
@@ -13,7 +13,7 @@ public:
StubFileSource();
~StubFileSource() override;
- std::unique_ptr<FileRequest> request(const Resource&, Callback) override;
+ std::unique_ptr<AsyncRequest> request(const Resource&, Callback) override;
using ResponseFunction = std::function<optional<Response> (const Resource&)>;
@@ -36,7 +36,7 @@ private:
// The default behavior is to throw if no per-kind callback has been set.
optional<Response> defaultResponse(const Resource&);
- std::unordered_map<FileRequest*, std::tuple<Resource, ResponseFunction, Callback>> pending;
+ std::unordered_map<AsyncRequest*, std::tuple<Resource, ResponseFunction, Callback>> pending;
util::Timer timer;
};
diff --git a/test/src/stub_file_source.cpp b/test/src/stub_file_source.cpp
index 5a062672bb..89ccb3b335 100644
--- a/test/src/stub_file_source.cpp
+++ b/test/src/stub_file_source.cpp
@@ -4,7 +4,7 @@ namespace mbgl {
using namespace std::chrono_literals;
-class StubFileRequest : public FileRequest {
+class StubFileRequest : public AsyncRequest {
public:
StubFileRequest(StubFileSource& fileSource_)
: fileSource(fileSource_) {
@@ -32,7 +32,7 @@ StubFileSource::StubFileSource() {
StubFileSource::~StubFileSource() = default;
-std::unique_ptr<FileRequest> StubFileSource::request(const Resource& resource, Callback callback) {
+std::unique_ptr<AsyncRequest> StubFileSource::request(const Resource& resource, Callback callback) {
auto req = std::make_unique<StubFileRequest>(*this);
pending.emplace(req.get(), std::make_tuple(resource, response, callback));
return std::move(req);
diff --git a/test/storage/asset_file_source.cpp b/test/storage/asset_file_source.cpp
index 2ff179f90e..c6a25f83dd 100644
--- a/test/storage/asset_file_source.cpp
+++ b/test/storage/asset_file_source.cpp
@@ -44,7 +44,7 @@ private:
unsigned numRequests = 1000;
mbgl::AssetFileSource* fs;
- std::unique_ptr<mbgl::FileRequest> request;
+ std::unique_ptr<mbgl::AsyncRequest> request;
std::function<void(mbgl::Response)> requestCallback;
};
@@ -74,7 +74,7 @@ TEST_F(Storage, AssetStress) {
};
std::vector<std::unique_ptr<util::Thread<TestWorker>>> threads;
- std::vector<std::unique_ptr<mbgl::WorkRequest>> requests;
+ std::vector<std::unique_ptr<mbgl::AsyncRequest>> requests;
util::ThreadContext context = { "Test", util::ThreadType::Map, util::ThreadPriority::Regular };
for (unsigned i = 0; i < numThreads; ++i) {
@@ -101,7 +101,7 @@ TEST_F(Storage, AssetEmptyFile) {
AssetFileSource fs(getFileSourceRoot());
- std::unique_ptr<FileRequest> req = fs.request({ Resource::Unknown, "asset://empty" }, [&](Response res) {
+ std::unique_ptr<AsyncRequest> req = fs.request({ Resource::Unknown, "asset://empty" }, [&](Response res) {
req.reset();
EXPECT_EQ(nullptr, res.error);
ASSERT_TRUE(res.data.get());
@@ -122,7 +122,7 @@ TEST_F(Storage, AssetNonEmptyFile) {
AssetFileSource fs(getFileSourceRoot());
- std::unique_ptr<FileRequest> req = fs.request({ Resource::Unknown, "asset://nonempty" }, [&](Response res) {
+ std::unique_ptr<AsyncRequest> req = fs.request({ Resource::Unknown, "asset://nonempty" }, [&](Response res) {
req.reset();
EXPECT_EQ(nullptr, res.error);
ASSERT_TRUE(res.data.get());
@@ -143,7 +143,7 @@ TEST_F(Storage, AssetNonExistentFile) {
AssetFileSource fs(getFileSourceRoot());
- std::unique_ptr<FileRequest> req = fs.request({ Resource::Unknown, "asset://does_not_exist" }, [&](Response res) {
+ std::unique_ptr<AsyncRequest> req = fs.request({ Resource::Unknown, "asset://does_not_exist" }, [&](Response res) {
req.reset();
ASSERT_NE(nullptr, res.error);
EXPECT_EQ(Response::Error::Reason::NotFound, res.error->reason);
@@ -165,7 +165,7 @@ TEST_F(Storage, AssetReadDirectory) {
AssetFileSource fs(getFileSourceRoot());
- std::unique_ptr<FileRequest> req = fs.request({ Resource::Unknown, "asset://directory" }, [&](Response res) {
+ std::unique_ptr<AsyncRequest> req = fs.request({ Resource::Unknown, "asset://directory" }, [&](Response res) {
req.reset();
ASSERT_NE(nullptr, res.error);
EXPECT_EQ(Response::Error::Reason::NotFound, res.error->reason);
@@ -187,7 +187,7 @@ TEST_F(Storage, AssetURLEncoding) {
AssetFileSource fs(getFileSourceRoot());
- std::unique_ptr<FileRequest> req = fs.request({ Resource::Unknown, "asset://%6eonempty" }, [&](Response res) {
+ std::unique_ptr<AsyncRequest> req = fs.request({ Resource::Unknown, "asset://%6eonempty" }, [&](Response res) {
req.reset();
EXPECT_EQ(nullptr, res.error);
ASSERT_TRUE(res.data.get());
diff --git a/test/storage/default_file_source.cpp b/test/storage/default_file_source.cpp
index 57eb045660..a3453a83bc 100644
--- a/test/storage/default_file_source.cpp
+++ b/test/storage/default_file_source.cpp
@@ -16,8 +16,8 @@ TEST_F(DefaultFileSourceTest, TEST_REQUIRES_SERVER(CacheResponse)) {
const Resource resource { Resource::Unknown, "http://127.0.0.1:3000/cache" };
Response response;
- std::unique_ptr<FileRequest> req1;
- std::unique_ptr<FileRequest> req2;
+ std::unique_ptr<AsyncRequest> req1;
+ std::unique_ptr<AsyncRequest> req2;
req1 = fs.request(resource, [&](Response res) {
req1.reset();
@@ -57,8 +57,8 @@ TEST_F(DefaultFileSourceTest, TEST_REQUIRES_SERVER(CacheRevalidateSame)) {
DefaultFileSource fs(":memory:", ".");
const Resource revalidateSame { Resource::Unknown, "http://127.0.0.1:3000/revalidate-same" };
- std::unique_ptr<FileRequest> req1;
- std::unique_ptr<FileRequest> req2;
+ std::unique_ptr<AsyncRequest> req1;
+ std::unique_ptr<AsyncRequest> req2;
uint16_t counter = 0;
// First request causes the response to get cached.
@@ -107,8 +107,8 @@ TEST_F(DefaultFileSourceTest, TEST_REQUIRES_SERVER(CacheRevalidateModified)) {
const Resource revalidateModified{ Resource::Unknown,
"http://127.0.0.1:3000/revalidate-modified" };
- std::unique_ptr<FileRequest> req1;
- std::unique_ptr<FileRequest> req2;
+ std::unique_ptr<AsyncRequest> req1;
+ std::unique_ptr<AsyncRequest> req2;
uint16_t counter = 0;
// First request causes the response to get cached.
@@ -155,8 +155,8 @@ TEST_F(DefaultFileSourceTest, TEST_REQUIRES_SERVER(CacheRevalidateEtag)) {
DefaultFileSource fs(":memory:", ".");
const Resource revalidateEtag { Resource::Unknown, "http://127.0.0.1:3000/revalidate-etag" };
- std::unique_ptr<FileRequest> req1;
- std::unique_ptr<FileRequest> req2;
+ std::unique_ptr<AsyncRequest> req1;
+ std::unique_ptr<AsyncRequest> req2;
uint16_t counter = 0;
// First request causes the response to get cached.
diff --git a/test/storage/http_cancel.cpp b/test/storage/http_cancel.cpp
index 3b4db35940..bda274c547 100644
--- a/test/storage/http_cancel.cpp
+++ b/test/storage/http_cancel.cpp
@@ -35,10 +35,10 @@ TEST_F(Storage, TEST_REQUIRES_SERVER(HTTPCancelMultiple)) {
const Resource resource { Resource::Unknown, "http://127.0.0.1:3000/test" };
- std::unique_ptr<FileRequest> req2 = fs.request(resource, [&](Response) {
+ std::unique_ptr<AsyncRequest> req2 = fs.request(resource, [&](Response) {
ADD_FAILURE() << "Callback should not be called";
});
- std::unique_ptr<FileRequest> req = fs.request(resource, [&](Response res) {
+ std::unique_ptr<AsyncRequest> req = fs.request(resource, [&](Response res) {
req.reset();
EXPECT_EQ(nullptr, res.error);
ASSERT_TRUE(res.data.get());
diff --git a/test/storage/http_error.cpp b/test/storage/http_error.cpp
index 1600178411..073f48b1b1 100644
--- a/test/storage/http_error.cpp
+++ b/test/storage/http_error.cpp
@@ -17,7 +17,7 @@ TEST_F(Storage, TEST_REQUIRES_SERVER(HTTPTemporaryError)) {
const auto start = Clock::now();
- std::unique_ptr<FileRequest> req1 = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/temporary-error" }, [&](Response res) {
+ std::unique_ptr<AsyncRequest> req1 = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/temporary-error" }, [&](Response res) {
static int counter = 0;
switch (counter++) {
case 0: {
@@ -61,7 +61,7 @@ TEST_F(Storage, TEST_REQUIRES_SERVER(HTTPConnectionError)) {
const auto start = Clock::now();
- std::unique_ptr<FileRequest> req2 = fs.request({ Resource::Unknown, "http://127.0.0.1:3001/" }, [&](Response res) {
+ std::unique_ptr<AsyncRequest> req2 = fs.request({ Resource::Unknown, "http://127.0.0.1:3001/" }, [&](Response res) {
static int counter = 0;
static int wait = 0;
const auto duration = std::chrono::duration<const double>(Clock::now() - start).count();
diff --git a/test/storage/http_expires.cpp b/test/storage/http_expires.cpp
index 0d64d31049..787d3e540b 100644
--- a/test/storage/http_expires.cpp
+++ b/test/storage/http_expires.cpp
@@ -17,7 +17,7 @@ TEST_F(Storage, TEST_REQUIRES_SERVER(HTTPRetryDelayOnExpiredTile)) {
int counter = 0;
const Resource resource { Resource::Unknown, "http://127.0.0.1:3000/test?expires=10000" };
- std::unique_ptr<FileRequest> req = fs.request(resource, [&](Response res) {
+ std::unique_ptr<AsyncRequest> req = fs.request(resource, [&](Response res) {
counter++;
EXPECT_EQ(nullptr, res.error);
EXPECT_GT(SystemClock::now(), res.expires);
@@ -46,7 +46,7 @@ TEST_F(Storage, TEST_REQUIRES_SERVER(HTTPRetryOnClockSkew)) {
int counter = 0;
const Resource resource { Resource::Unknown, "http://127.0.0.1:3000/clockskew" };
- std::unique_ptr<FileRequest> req1 = fs.request(resource, [&](Response res) {
+ std::unique_ptr<AsyncRequest> req1 = fs.request(resource, [&](Response res) {
switch (counter++) {
case 0: {
EXPECT_EQ(nullptr, res.error);
@@ -81,14 +81,14 @@ TEST_F(Storage, TEST_REQUIRES_SERVER(HTTPRespectPriorExpires)) {
Resource resource1{ Resource::Unknown, "http://127.0.0.1:3000/test" };
resource1.priorExpires = SystemClock::now() + Seconds(100000);
- std::unique_ptr<FileRequest> req1 = fs.request(resource1, [&](Response) {
+ std::unique_ptr<AsyncRequest> req1 = fs.request(resource1, [&](Response) {
FAIL() << "Should never be called";
});
// No expiration time, should be requested immediately.
Resource resource2{ Resource::Unknown, "http://127.0.0.1:3000/test" };
- std::unique_ptr<FileRequest> req2 = fs.request(resource2, [&](Response) {
+ std::unique_ptr<AsyncRequest> req2 = fs.request(resource2, [&](Response) {
HTTPRespectPriorExpires.finish();
loop.stop();
});
@@ -97,7 +97,7 @@ TEST_F(Storage, TEST_REQUIRES_SERVER(HTTPRespectPriorExpires)) {
Resource resource3{ Resource::Unknown, "http://127.0.0.1:3000/test" };
resource3.priorExpires = SystemClock::now() + Seconds(100000);
- std::unique_ptr<FileRequest> req3 = fs.request(resource3, [&](Response) {
+ std::unique_ptr<AsyncRequest> req3 = fs.request(resource3, [&](Response) {
FAIL() << "Should never be called";
});
diff --git a/test/storage/http_header_parsing.cpp b/test/storage/http_header_parsing.cpp
index 163ef71899..cdebe8db5d 100644
--- a/test/storage/http_header_parsing.cpp
+++ b/test/storage/http_header_parsing.cpp
@@ -14,7 +14,7 @@ TEST_F(Storage, TEST_REQUIRES_SERVER(HTTPExpiresParsing)) {
util::RunLoop loop;
OnlineFileSource fs;
- std::unique_ptr<FileRequest> req1 = fs.request({ Resource::Unknown,
+ std::unique_ptr<AsyncRequest> req1 = fs.request({ Resource::Unknown,
"http://127.0.0.1:3000/test?modified=1420794326&expires=1420797926&etag=foo" },
[&](Response res) {
req1.reset();
@@ -39,7 +39,7 @@ TEST_F(Storage, TEST_REQUIRES_SERVER(HTTPCacheControlParsing)) {
util::RunLoop loop;
OnlineFileSource fs;
- std::unique_ptr<FileRequest> req2 = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/test?cachecontrol=max-age=120" },
+ std::unique_ptr<AsyncRequest> req2 = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/test?cachecontrol=max-age=120" },
[&](Response res) {
req2.reset();
EXPECT_EQ(nullptr, res.error);
diff --git a/test/storage/http_load.cpp b/test/storage/http_load.cpp
index a518ec4be6..4feb790cbc 100644
--- a/test/storage/http_load.cpp
+++ b/test/storage/http_load.cpp
@@ -16,7 +16,7 @@ TEST_F(Storage, TEST_REQUIRES_SERVER(HTTPLoad)) {
const int max = 10000;
int number = 1;
- std::unique_ptr<FileRequest> reqs[concurrency];
+ std::unique_ptr<AsyncRequest> reqs[concurrency];
std::function<void(int)> req = [&](int i) {
const auto current = number++;
diff --git a/test/storage/http_other_loop.cpp b/test/storage/http_other_loop.cpp
index ab22d65237..20e7e2356a 100644
--- a/test/storage/http_other_loop.cpp
+++ b/test/storage/http_other_loop.cpp
@@ -13,7 +13,7 @@ TEST_F(Storage, TEST_REQUIRES_SERVER(HTTPOtherLoop)) {
util::RunLoop loop;
OnlineFileSource fs;
- std::unique_ptr<FileRequest> req = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/test" },
+ std::unique_ptr<AsyncRequest> req = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/test" },
[&](Response res) {
req.reset();
EXPECT_EQ(nullptr, res.error);
diff --git a/test/storage/http_reading.cpp b/test/storage/http_reading.cpp
index 607a5fd487..9682ec93cf 100644
--- a/test/storage/http_reading.cpp
+++ b/test/storage/http_reading.cpp
@@ -16,7 +16,7 @@ TEST_F(Storage, TEST_REQUIRES_SERVER(HTTPTest)) {
util::RunLoop loop;
OnlineFileSource fs;
- std::unique_ptr<FileRequest> req1 = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/test" },
+ std::unique_ptr<AsyncRequest> req1 = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/test" },
[&](Response res) {
req1.reset();
EXPECT_TRUE(util::ThreadContext::currentlyOn(util::ThreadType::Main));
@@ -41,7 +41,7 @@ TEST_F(Storage, TEST_REQUIRES_SERVER(HTTP404)) {
util::RunLoop loop;
OnlineFileSource fs;
- std::unique_ptr<FileRequest> req2 = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/doesnotexist" },
+ std::unique_ptr<AsyncRequest> req2 = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/doesnotexist" },
[&](Response res) {
req2.reset();
EXPECT_TRUE(util::ThreadContext::currentlyOn(util::ThreadType::Main));
@@ -67,7 +67,7 @@ TEST_F(Storage, TEST_REQUIRES_SERVER(HTTPTile404)) {
util::RunLoop loop;
OnlineFileSource fs;
- std::unique_ptr<FileRequest> req2 = fs.request({ Resource::Tile, "http://127.0.0.1:3000/doesnotexist" },
+ std::unique_ptr<AsyncRequest> req2 = fs.request({ Resource::Tile, "http://127.0.0.1:3000/doesnotexist" },
[&](Response res) {
req2.reset();
EXPECT_TRUE(util::ThreadContext::currentlyOn(util::ThreadType::Main));
@@ -92,7 +92,7 @@ TEST_F(Storage, TEST_REQUIRES_SERVER(HTTP200EmptyData)) {
util::RunLoop loop;
OnlineFileSource fs;
- std::unique_ptr<FileRequest> req = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/empty-data" },
+ std::unique_ptr<AsyncRequest> req = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/empty-data" },
[&](Response res) {
req.reset();
EXPECT_TRUE(util::ThreadContext::currentlyOn(util::ThreadType::Main));
@@ -117,7 +117,7 @@ TEST_F(Storage, TEST_REQUIRES_SERVER(HTTP204)) {
util::RunLoop loop;
OnlineFileSource fs;
- std::unique_ptr<FileRequest> req2 = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/no-content" },
+ std::unique_ptr<AsyncRequest> req2 = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/no-content" },
[&](Response res) {
req2.reset();
EXPECT_TRUE(util::ThreadContext::currentlyOn(util::ThreadType::Main));
@@ -142,7 +142,7 @@ TEST_F(Storage, TEST_REQUIRES_SERVER(HTTP500)) {
util::RunLoop loop;
OnlineFileSource fs;
- std::unique_ptr<FileRequest> req3 = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/permanent-error" },
+ std::unique_ptr<AsyncRequest> req3 = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/permanent-error" },
[&](Response res) {
req3.reset();
EXPECT_TRUE(util::ThreadContext::currentlyOn(util::ThreadType::Main));
diff --git a/test/storage/http_retry_network_status.cpp b/test/storage/http_retry_network_status.cpp
index 34d0ecaf19..249f74c264 100644
--- a/test/storage/http_retry_network_status.cpp
+++ b/test/storage/http_retry_network_status.cpp
@@ -23,7 +23,7 @@ TEST_F(Storage, TEST_REQUIRES_SERVER(HTTPNetworkStatusChange)) {
const Resource resource { Resource::Unknown, "http://127.0.0.1:3000/delayed" };
// This request takes 200 milliseconds to answer.
- std::unique_ptr<FileRequest> req = fs.request(resource, [&](Response res) {
+ std::unique_ptr<AsyncRequest> req = fs.request(resource, [&](Response res) {
req.reset();
EXPECT_EQ(nullptr, res.error);
ASSERT_TRUE(res.data.get());
@@ -57,7 +57,7 @@ TEST_F(Storage, TEST_REQUIRES_SERVER(HTTPNetworkStatusChangePreempt)) {
const auto start = Clock::now();
const Resource resource{ Resource::Unknown, "http://127.0.0.1:3001/test" };
- std::unique_ptr<FileRequest> req = fs.request(resource, [&](Response res) {
+ std::unique_ptr<AsyncRequest> req = fs.request(resource, [&](Response res) {
static int counter = 0;
const auto duration = std::chrono::duration<const double>(Clock::now() - start).count();
if (counter == 0) {
@@ -120,7 +120,7 @@ TEST_F(Storage, TEST_REQUIRES_SERVER(HTTPNetworkStatusOnlineOffline)) {
NetworkStatus::Set(NetworkStatus::Status::Online);
});
- std::unique_ptr<FileRequest> req = fs.request(resource, [&](Response res) {
+ std::unique_ptr<AsyncRequest> req = fs.request(resource, [&](Response res) {
req.reset();
EXPECT_EQ(nullptr, res.error);
diff --git a/test/storage/http_timeout.cpp b/test/storage/http_timeout.cpp
index b1df8c2fbb..42c7f39f56 100644
--- a/test/storage/http_timeout.cpp
+++ b/test/storage/http_timeout.cpp
@@ -16,7 +16,7 @@ TEST_F(Storage, TEST_REQUIRES_SERVER(HTTPTimeout)) {
int counter = 0;
const Resource resource { Resource::Unknown, "http://127.0.0.1:3000/test?cachecontrol=max-age=1" };
- std::unique_ptr<FileRequest> req = fs.request(resource, [&](Response res) {
+ std::unique_ptr<AsyncRequest> req = fs.request(resource, [&](Response res) {
counter++;
EXPECT_EQ(nullptr, res.error);
ASSERT_TRUE(res.data.get());
diff --git a/test/util/async_task.cpp b/test/util/async_task.cpp
index 95cf160548..4a80b5f3d9 100644
--- a/test/util/async_task.cpp
+++ b/test/util/async_task.cpp
@@ -105,7 +105,7 @@ TEST(AsyncTask, ThreadSafety) {
};
std::vector<std::unique_ptr<Thread<TestWorker>>> threads;
- std::vector<std::unique_ptr<mbgl::WorkRequest>> requests;
+ std::vector<std::unique_ptr<mbgl::AsyncRequest>> requests;
ThreadContext context = {"Test", ThreadType::Map, ThreadPriority::Regular};
for (unsigned i = 0; i < numThreads; ++i) {
diff --git a/test/util/thread.cpp b/test/util/thread.cpp
index 40e4d8ede4..9414d14f3c 100644
--- a/test/util/thread.cpp
+++ b/test/util/thread.cpp
@@ -67,7 +67,7 @@ TEST(Thread, invoke) {
const std::thread::id tid = std::this_thread::get_id();
RunLoop loop;
- std::vector<std::unique_ptr<mbgl::WorkRequest>> requests;
+ std::vector<std::unique_ptr<mbgl::AsyncRequest>> requests;
loop.invoke([&] {
EXPECT_EQ(tid, std::this_thread::get_id());
@@ -123,7 +123,7 @@ TEST(Thread, context) {
const std::thread::id tid = std::this_thread::get_id();
RunLoop loop;
- std::vector<std::unique_ptr<mbgl::WorkRequest>> requests;
+ std::vector<std::unique_ptr<mbgl::AsyncRequest>> requests;
loop.invoke([&] {
Thread<TestObject> thread({"Test", ThreadType::Worker, ThreadPriority::Low}, tid);