summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorLeith Bade <leith@mapbox.com>2014-12-03 21:57:55 +1100
committerLeith Bade <leith@mapbox.com>2014-12-03 21:57:55 +1100
commitf090d6b2642a4b28f9690c4724a2f702d82f4072 (patch)
tree83c04ce835897455fe0b570793c51edae5729265 /platform
parent8208dfaba34db13cb638edc5137ed532d272c16f (diff)
downloadqtlocation-mapboxgl-f090d6b2642a4b28f9690c4724a2f702d82f4072.tar.gz
Use uv::async and various other fixes
Diffstat (limited to 'platform')
-rw-r--r--platform/android/asset_request_baton_libzip.cpp29
-rw-r--r--platform/darwin/http_request_baton_cocoa.mm4
-rw-r--r--platform/default/asset_request_baton_noop.cpp12
-rw-r--r--platform/default/http_request_baton_curl.cpp4
4 files changed, 26 insertions, 23 deletions
diff --git a/platform/android/asset_request_baton_libzip.cpp b/platform/android/asset_request_baton_libzip.cpp
index a492079c25..1d2f055bfa 100644
--- a/platform/android/asset_request_baton_libzip.cpp
+++ b/platform/android/asset_request_baton_libzip.cpp
@@ -5,18 +5,21 @@
#include <boost/make_unique.hpp>
+#include <cerrno>
+// NOTE a bug in the Android NDK breaks std::errno
+// See https://code.google.com/p/android/issues/detail?id=72349
+// After this is fixed change usage errno to std::errno
#include <zip.h>
namespace mbgl {
-void AssetRequestBaton::run(uv_async_t *async) {
- AssetRequestBaton *ptr = (AssetRequestBaton *)async->data;
- assert(ptr->thread_id == uv_thread_self());
+void AssetRequestBaton::run(AssetRequestBaton *ptr) {
+ assert(ptr->threadId == uv_thread_self());
if (ptr->canceled || !ptr->request) {
// Either the AssetRequest object has been destructed, or the
// request was canceled.
- cleanup(async);
+ cleanup(ptr);
return;
}
@@ -27,8 +30,8 @@ void AssetRequestBaton::run(uv_async_t *async) {
const int message_size = zip_error_to_str(nullptr, 0, error, errno);
const std::unique_ptr<char[]> message = boost::make_unique<char[]>(message_size);
zip_error_to_str(message.get(), 0, error, errno);
- notify_error(async, 500, message.get());
- cleanup(async);
+ notify_error(ptr, 500, message.get());
+ cleanup(ptr);
return;
}
@@ -38,10 +41,10 @@ void AssetRequestBaton::run(uv_async_t *async) {
// Opening the asset failed or was canceled. We already have an open file handle
// though, which we'll have to close.
zip_error_get(apk, &error, nullptr);
- notify_error(async, error == ZIP_ER_NOENT ? 404 : 500, zip_strerror(apk));
+ notify_error(ptr, error == ZIP_ER_NOENT ? 404 : 500, zip_strerror(apk));
zip_close(apk);
apk = nullptr;
- cleanup(async);
+ cleanup(ptr);
return;
}
@@ -49,12 +52,12 @@ void AssetRequestBaton::run(uv_async_t *async) {
if ((zip_stat(apk, apk_file_path.c_str(), ZIP_FL_NOCASE, &stat) != 0) || ptr->canceled || !ptr->request) {
// Stating failed or was canceled. We already have an open file handle
// though, which we'll have to close.
- notify_error(async, 500, zip_strerror(apk));
+ notify_error(ptr, 500, zip_strerror(apk));
zip_fclose(apk_file);
apk_file = nullptr;
zip_close(apk);
apk = nullptr;
- cleanup(async);
+ cleanup(ptr);
return;
}
@@ -63,12 +66,12 @@ void AssetRequestBaton::run(uv_async_t *async) {
if (static_cast<zip_uint64_t>(zip_fread(apk_file, reinterpret_cast<void *>(data.get()), stat.size)) != stat.size || ptr->canceled || !ptr->request) {
// Reading failed or was canceled. We already have an open file handle
// though, which we'll have to close.
- notify_error(async, 500, zip_file_strerror(apk_file));
+ notify_error(ptr, 500, zip_file_strerror(apk_file));
zip_fclose(apk_file);
apk_file = nullptr;
zip_close(apk);
apk = nullptr;
- cleanup(async);
+ cleanup(ptr);
return;
}
@@ -90,7 +93,7 @@ void AssetRequestBaton::run(uv_async_t *async) {
}
apk = nullptr;
- cleanup(async);
+ cleanup(ptr);
}
}
diff --git a/platform/darwin/http_request_baton_cocoa.mm b/platform/darwin/http_request_baton_cocoa.mm
index 03fa3bb821..1c54dbdc1f 100644
--- a/platform/darwin/http_request_baton_cocoa.mm
+++ b/platform/darwin/http_request_baton_cocoa.mm
@@ -15,7 +15,7 @@ dispatch_once_t request_initialize = 0;
NSURLSession *session = nullptr;
void HTTPRequestBaton::start(const util::ptr<HTTPRequestBaton> &ptr) {
- assert(uv_thread_self() == ptr->thread_id);
+ assert(uv_thread_self() == ptr->threadId);
// Starts the request.
util::ptr<HTTPRequestBaton> baton = ptr;
@@ -131,7 +131,7 @@ void HTTPRequestBaton::start(const util::ptr<HTTPRequestBaton> &ptr) {
}
void HTTPRequestBaton::stop(const util::ptr<HTTPRequestBaton> &ptr) {
- assert(uv_thread_self() == ptr->thread_id);
+ assert(uv_thread_self() == ptr->threadId);
assert(ptr->ptr);
NSURLSessionDataTask *task = CFBridgingRelease(ptr->ptr);
diff --git a/platform/default/asset_request_baton_noop.cpp b/platform/default/asset_request_baton_noop.cpp
index e0d5755a7c..45083a50f8 100644
--- a/platform/default/asset_request_baton_noop.cpp
+++ b/platform/default/asset_request_baton_noop.cpp
@@ -4,19 +4,19 @@
namespace mbgl {
-void AssetRequestBaton::run(uv_async_t *async) {
- AssetRequestBaton *ptr = (AssetRequestBaton *)async->data;
- assert(ptr->thread_id == uv_thread_self());
+void AssetRequestBaton::run(AssetRequestBaton *ptr) {
+ assert(ptr->threadId == uv_thread_self());
if (ptr->canceled || !ptr->request) {
// Either the AssetRequest object has been destructed, or the
// request was canceled.
- cleanup(async);
+ cleanup(ptr);
return;
}
- notify_error(async, 500, "Assets not implemented on this platform.");
- cleanup(async);
+ // Just return a 500 error until implemented properly
+ notify_error(ptr, 500, "Assets not implemented on this platform.");
+ cleanup(ptr);
}
}
diff --git a/platform/default/http_request_baton_curl.cpp b/platform/default/http_request_baton_curl.cpp
index a5b0edbbf4..931f8955ec 100644
--- a/platform/default/http_request_baton_curl.cpp
+++ b/platform/default/http_request_baton_curl.cpp
@@ -595,14 +595,14 @@ void create_thread() {
// This function must be run from the main thread (== where the HTTPRequestBaton was created)
void HTTPRequestBaton::start(const util::ptr<HTTPRequestBaton> &ptr) {
- assert(uv_thread_self() == ptr->thread_id);
+ assert(uv_thread_self() == ptr->threadId);
uv_once(&once, create_thread);
uv_messenger_send(&start_messenger, new util::ptr<HTTPRequestBaton>(ptr));
}
// This function must be run from the main thread (== where the HTTPRequestBaton was created)
void HTTPRequestBaton::stop(const util::ptr<HTTPRequestBaton> &ptr) {
- assert(uv_thread_self() == ptr->thread_id);
+ assert(uv_thread_self() == ptr->threadId);
uv_once(&once, create_thread);
uv_messenger_send(&stop_messenger, new util::ptr<HTTPRequestBaton>(ptr));
}