[android] Use jni.hpp in http_request_android.cpp

This commit is contained in:
John Firebaugh
2016-02-28 20:30:58 -08:00
parent 9e0be736fc
commit 235f4ee6f6
8 changed files with 224 additions and 402 deletions

View File

@@ -0,0 +1,22 @@
#include "attach_env.hpp"
#include "jni.hpp"
namespace mbgl {
namespace android {
UniqueEnv AttachEnv() {
JNIEnv* env = nullptr;
jint err = theJVM->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6);
switch (err) {
case JNI_OK:
return UniqueEnv(env, JNIEnvDeleter(*theJVM, false));
case JNI_EDETACHED:
return UniqueEnv(jni::AttachCurrentThread(*theJVM).release(), JNIEnvDeleter(*theJVM, true));
default:
throw std::system_error(err, jni::ErrorCategory());
}
}
}
}

View File

@@ -0,0 +1,31 @@
#pragma once
#include <jni/jni.hpp>
namespace mbgl {
namespace android {
class JNIEnvDeleter {
private:
jni::JavaVM* vm = nullptr;
bool detach = false;
public:
JNIEnvDeleter() = default;
JNIEnvDeleter(jni::JavaVM& v, bool d)
: vm(&v), detach(d) {}
void operator()(jni::JNIEnv* p) const {
if (p && detach) {
assert(vm);
vm->DetachCurrentThread();
}
}
};
using UniqueEnv = std::unique_ptr<jni::JNIEnv, JNIEnvDeleter>;
UniqueEnv AttachEnv();
}
}

View File

@@ -3,54 +3,48 @@
#include <mbgl/storage/resource.hpp>
#include <mbgl/storage/response.hpp>
#include <mbgl/platform/log.hpp>
#include "jni.hpp"
#include <mbgl/util/async_task.hpp>
#include <mbgl/util/util.hpp>
#include <mbgl/util/string.hpp>
#include <jni.h>
#include <jni/jni.hpp>
#include "attach_env.hpp"
namespace mbgl {
namespace android {
void JNICALL nativeOnFailure(JNIEnv *env, jobject obj, jlong nativePtr, jint type, jstring message);
void JNICALL nativeOnResponse(JNIEnv *env, jobject obj, jlong nativePtr, jint code, jstring message, jstring etag, jstring modified, jstring cacheControl, jstring expires, jbyteArray body);
class HTTPAndroidRequest;
class HTTPAndroidContext : public HTTPContextBase {
class HTTPContext : public HTTPContextBase {
public:
explicit HTTPAndroidContext();
~HTTPAndroidContext();
HTTPRequestBase* createRequest(const Resource&, HTTPRequestBase::Callback) final;
JavaVM *vm = nullptr;
jobject obj = nullptr;
UniqueEnv env { android::AttachEnv() };
};
class HTTPAndroidRequest : public HTTPRequestBase {
class HTTPRequest : public HTTPRequestBase {
public:
HTTPAndroidRequest(HTTPAndroidContext*, const Resource&, Callback);
~HTTPAndroidRequest();
static constexpr auto Name() { return "com/mapbox/mapboxsdk/http/HTTPRequest"; };
HTTPRequest(jni::JNIEnv&, const Resource&, Callback);
void cancel() final;
void onFailure(JNIEnv*, int type, jstring message);
void onResponse(JNIEnv*, int code, jstring message, jstring etag, jstring modified, jstring cacheControl, jstring expires, jbyteArray body);
void onFailure(jni::JNIEnv&, int type, jni::String message);
void onResponse(jni::JNIEnv&, int code,
jni::String etag, jni::String modified,
jni::String cacheControl, jni::String expires,
jni::Array<jni::jbyte> body);
static jni::Class<HTTPRequest> javaClass;
jni::UniqueObject<HTTPRequest> javaRequest;
private:
void finish();
HTTPAndroidContext *context = nullptr;
bool cancelled = false;
std::unique_ptr<Response> response;
const std::shared_ptr<const Response> existingResponse;
jobject obj = nullptr;
util::AsyncTask async;
static const int connectionError = 0;
@@ -59,59 +53,27 @@ private:
static const int canceledError = 3;
};
jni::Class<HTTPRequest> HTTPRequest::javaClass;
void RegisterNativeHTTPRequest(jni::JNIEnv& env) {
HTTPRequest::javaClass = *jni::Class<HTTPRequest>::Find(env).NewGlobalRef(env).release();
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
jni::RegisterNativePeer<HTTPRequest>(env, HTTPRequest::javaClass, "mNativePtr",
METHOD(&HTTPRequest::onFailure, "nativeOnFailure"),
METHOD(&HTTPRequest::onResponse, "nativeOnResponse"));
}
// -------------------------------------------------------------------------------------------------
HTTPAndroidContext::HTTPAndroidContext()
: vm(mbgl::android::theJVM) {
JNIEnv *env = nullptr;
bool detach = mbgl::android::attach_jni_thread(vm, &env, "HTTPAndroidContext::HTTPAndroidContext()");
const std::vector<JNINativeMethod> methods = {
{"nativeOnFailure", "(JILjava/lang/String;)V", reinterpret_cast<void *>(&nativeOnFailure)},
{"nativeOnResponse",
"(JILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[B)V",
reinterpret_cast<void *>(&nativeOnResponse)}
};
if (env->RegisterNatives(mbgl::android::httpRequestClass, methods.data(), methods.size()) < 0) {
env->ExceptionDescribe();
}
obj = env->CallStaticObjectMethod(mbgl::android::httpContextClass, mbgl::android::httpContextGetInstanceId);
if (env->ExceptionCheck() || (obj == nullptr)) {
env->ExceptionDescribe();
}
obj = env->NewGlobalRef(obj);
if (obj == nullptr) {
env->ExceptionDescribe();
}
mbgl::android::detach_jni_thread(vm, &env, detach);
HTTPRequestBase* HTTPContext::createRequest(const Resource& resource, HTTPRequestBase::Callback callback) {
return new HTTPRequest(*env, resource, callback);
}
HTTPAndroidContext::~HTTPAndroidContext() {
JNIEnv *env = nullptr;
bool detach = mbgl::android::attach_jni_thread(vm, &env, "HTTPAndroidContext::~HTTPAndroidContext()");
env->DeleteGlobalRef(obj);
obj = nullptr;
mbgl::android::detach_jni_thread(vm, &env, detach);
vm = nullptr;
}
HTTPRequestBase* HTTPAndroidContext::createRequest(const Resource& resource, HTTPRequestBase::Callback callback) {
return new HTTPAndroidRequest(this, resource, callback);
}
HTTPAndroidRequest::HTTPAndroidRequest(HTTPAndroidContext* context_, const Resource& resource_, Callback callback_)
HTTPRequest::HTTPRequest(jni::JNIEnv& env, const Resource& resource_, Callback callback_)
: HTTPRequestBase(resource_, callback_),
context(context_),
async([this] { finish(); }) {
std::string etagStr;
std::string modifiedStr;
@@ -121,56 +83,30 @@ HTTPAndroidRequest::HTTPAndroidRequest(HTTPAndroidContext* context_, const Resou
modifiedStr = util::rfc1123(*resource.priorModified);
}
JNIEnv *env = nullptr;
bool detach = mbgl::android::attach_jni_thread(context->vm, &env, "HTTPAndroidContext::HTTPAndroidRequest()");
jni::UniqueLocalFrame frame = jni::PushLocalFrame(env, 10);
jstring resourceUrl = mbgl::android::std_string_to_jstring(env, resource.url);
jstring userAgent = mbgl::android::std_string_to_jstring(env, "MapboxGL/1.0");
jstring etag = mbgl::android::std_string_to_jstring(env, etagStr);
jstring modified = mbgl::android::std_string_to_jstring(env, modifiedStr);
obj = env->CallObjectMethod(context->obj, mbgl::android::httpContextCreateRequestId, reinterpret_cast<jlong>(this), resourceUrl, userAgent, etag, modified);
if (env->ExceptionCheck() || (obj == nullptr)) {
env->ExceptionDescribe();
}
static auto constructor =
javaClass.GetConstructor<jni::jlong, jni::String, jni::String, jni::String, jni::String>(env);
obj = env->NewGlobalRef(obj);
if (obj == nullptr) {
env->ExceptionDescribe();
}
env->CallVoidMethod(obj, mbgl::android::httpRequestStartId);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
}
mbgl::android::detach_jni_thread(context->vm, &env, detach);
javaRequest = javaClass.New(env, constructor,
reinterpret_cast<jlong>(this),
jni::Make<jni::String>(env, resource.url),
jni::Make<jni::String>(env, "MapboxGL/1.0"),
jni::Make<jni::String>(env, etagStr),
jni::Make<jni::String>(env, modifiedStr)).NewGlobalRef(env);
}
HTTPAndroidRequest::~HTTPAndroidRequest() {
JNIEnv *env = nullptr;
bool detach = mbgl::android::attach_jni_thread(context->vm, &env, "HTTPAndroidContext::~HTTPAndroidRequest()");
env->DeleteGlobalRef(obj);
obj = nullptr;
mbgl::android::detach_jni_thread(context->vm, &env, detach);
}
void HTTPAndroidRequest::cancel() {
void HTTPRequest::cancel() {
cancelled = true;
JNIEnv *env = nullptr;
bool detach = mbgl::android::attach_jni_thread(context->vm, &env, "HTTPAndroidContext::cancel()");
UniqueEnv env = android::AttachEnv();
env->CallVoidMethod(obj, mbgl::android::httpRequestCancelId);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
}
static auto cancel = javaClass.GetMethod<void ()>(*env, "cancel");
mbgl::android::detach_jni_thread(context->vm, &env, detach);
javaRequest->Call(*env, cancel);
}
void HTTPAndroidRequest::finish() {
void HTTPRequest::finish() {
if (!cancelled) {
assert(response);
notify(*response);
@@ -179,31 +115,33 @@ void HTTPAndroidRequest::finish() {
delete this;
}
void HTTPAndroidRequest::onResponse(JNIEnv* env, int code, jstring /* message */, jstring etag, jstring modified, jstring cacheControl, jstring expires, jbyteArray body) {
void HTTPRequest::onResponse(jni::JNIEnv& env, int code,
jni::String etag, jni::String modified, jni::String cacheControl,
jni::String expires, jni::Array<jni::jbyte> body) {
response = std::make_unique<Response>();
using Error = Response::Error;
if (etag != nullptr) {
response->etag = mbgl::android::std_string_from_jstring(env, etag);
if (etag) {
response->etag = jni::Make<std::string>(env, etag);
}
if (modified != nullptr) {
response->modified = util::parseTimePoint(mbgl::android::std_string_from_jstring(env, modified).c_str());
if (modified) {
response->modified = util::parseTimePoint(jni::Make<std::string>(env, modified).c_str());
}
if (cacheControl != nullptr) {
response->expires = parseCacheControl(mbgl::android::std_string_from_jstring(env, cacheControl).c_str());
if (cacheControl) {
response->expires = parseCacheControl(jni::Make<std::string>(env, cacheControl).c_str());
}
if (expires != nullptr) {
response->expires = util::parseTimePoint(mbgl::android::std_string_from_jstring(env, expires).c_str());
if (expires) {
response->expires = util::parseTimePoint(jni::Make<std::string>(env, expires).c_str());
}
if (code == 200) {
if (body != nullptr) {
jbyte* bodyData = env->GetByteArrayElements(body, nullptr);
response->data = std::make_shared<std::string>(reinterpret_cast<char*>(bodyData), env->GetArrayLength(body));
env->ReleaseByteArrayElements(body, bodyData, JNI_ABORT);
if (body) {
auto data = std::make_shared<std::string>(body.Length(env), char());
jni::GetArrayRegion(env, *body, 0, data->size(), reinterpret_cast<jbyte*>(&(*data)[0]));
response->data = data;
} else {
response->data = std::make_shared<std::string>();
}
@@ -222,8 +160,8 @@ void HTTPAndroidRequest::onResponse(JNIEnv* env, int code, jstring /* message */
async.send();
}
void HTTPAndroidRequest::onFailure(JNIEnv* env, int type, jstring message) {
std::string messageStr = mbgl::android::std_string_from_jstring(env, message);
void HTTPRequest::onFailure(jni::JNIEnv& env, int type, jni::String message) {
std::string messageStr = jni::Make<std::string>(env, message);
response = std::make_unique<Response>();
using Error = Response::Error;
@@ -245,24 +183,14 @@ void HTTPAndroidRequest::onFailure(JNIEnv* env, int type, jstring message) {
async.send();
}
} // namespace android
std::unique_ptr<HTTPContextBase> HTTPContextBase::createContext() {
return std::make_unique<HTTPAndroidContext>();
return std::make_unique<android::HTTPContext>();
}
uint32_t HTTPContextBase::maximumConcurrentRequests() {
return 20;
}
void JNICALL nativeOnFailure(JNIEnv* env, jobject, jlong nativePtr, jint type, jstring message) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeOnFailure");
assert(nativePtr != 0);
return reinterpret_cast<HTTPAndroidRequest*>(nativePtr)->onFailure(env, type, message);
}
void JNICALL nativeOnResponse(JNIEnv* env, jobject, jlong nativePtr, jint code, jstring message, jstring etag, jstring modified, jstring cacheControl, jstring expires, jbyteArray body) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeOnResponse");
assert(nativePtr != 0);
return reinterpret_cast<HTTPAndroidRequest*>(nativePtr)->onResponse(env, code, message, etag, modified, cacheControl, expires, body);
}
}
} // namespace mbgl

View File

@@ -8,8 +8,6 @@
#include <array>
#include <vector>
#include <jni.h>
#include <android/native_window_jni.h>
#include <sys/system_properties.h>
@@ -32,6 +30,8 @@
namespace mbgl {
namespace android {
void RegisterNativeHTTPRequest(JNIEnv&);
JavaVM* theJVM;
std::string cachePath;
@@ -101,14 +101,6 @@ jfieldID rectFTopId = nullptr;
jfieldID rectFRightId = nullptr;
jfieldID rectFBottomId = nullptr;
jclass httpContextClass = nullptr;
jmethodID httpContextGetInstanceId = nullptr;
jmethodID httpContextCreateRequestId = nullptr;
jclass httpRequestClass = nullptr;
jmethodID httpRequestStartId = nullptr;
jmethodID httpRequestCancelId = nullptr;
jclass customLayerClass = nullptr;
jfieldID customLayerIdId = nullptr;
jfieldID customLayerContextId = nullptr;
@@ -2181,6 +2173,8 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
return JNI_ERR;
}
mbgl::android::RegisterNativeHTTPRequest(*env);
latLngClass = env->FindClass("com/mapbox/mapboxsdk/geometry/LatLng");
if (latLngClass == nullptr) {
env->ExceptionDescribe();
@@ -2487,42 +2481,6 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
return JNI_ERR;
}
httpContextClass = env->FindClass("com/mapbox/mapboxsdk/http/HTTPContext");
if (httpContextClass == nullptr) {
env->ExceptionDescribe();
return JNI_ERR;
}
httpContextGetInstanceId = env->GetStaticMethodID(httpContextClass, "getInstance", "()Lcom/mapbox/mapboxsdk/http/HTTPContext;");
if (httpContextGetInstanceId == nullptr) {
env->ExceptionDescribe();
return JNI_ERR;
}
httpContextCreateRequestId = env->GetMethodID(httpContextClass, "createRequest", "(JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lcom/mapbox/mapboxsdk/http/HTTPContext$HTTPRequest;");
if (httpContextCreateRequestId == nullptr) {
env->ExceptionDescribe();
return JNI_ERR;
}
httpRequestClass = env->FindClass("com/mapbox/mapboxsdk/http/HTTPContext$HTTPRequest");
if (httpRequestClass == nullptr) {
env->ExceptionDescribe();
return JNI_ERR;
}
httpRequestStartId = env->GetMethodID(httpRequestClass, "start", "()V");
if (httpRequestStartId == nullptr) {
env->ExceptionDescribe();
return JNI_ERR;
}
httpRequestCancelId = env->GetMethodID(httpRequestClass, "cancel", "()V");
if (httpRequestCancelId == nullptr) {
env->ExceptionDescribe();
return JNI_ERR;
}
customLayerClass = env->FindClass("com/mapbox/mapboxsdk/layers/CustomLayer");
if (customLayerClass == nullptr) {
env->ExceptionDescribe();
@@ -3129,41 +3087,6 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
return JNI_ERR;
}
httpContextClass = reinterpret_cast<jclass>(env->NewGlobalRef(httpContextClass));
if (httpContextClass == nullptr) {
env->ExceptionDescribe();
env->DeleteGlobalRef(latLngClass);
env->DeleteGlobalRef(latLngBoundsClass);
env->DeleteGlobalRef(iconClass);
env->DeleteGlobalRef(markerClass);
env->DeleteGlobalRef(polylineClass);
env->DeleteGlobalRef(polygonClass);
env->DeleteGlobalRef(runtimeExceptionClass);
env->DeleteGlobalRef(nullPointerExceptionClass);
env->DeleteGlobalRef(arrayListClass);
env->DeleteGlobalRef(projectedMetersClass);
env->DeleteGlobalRef(pointFClass);
env->DeleteGlobalRef(rectFClass);
}
httpRequestClass = reinterpret_cast<jclass>(env->NewGlobalRef(httpRequestClass));
if (httpRequestClass == nullptr) {
env->ExceptionDescribe();
env->DeleteGlobalRef(latLngClass);
env->DeleteGlobalRef(latLngBoundsClass);
env->DeleteGlobalRef(iconClass);
env->DeleteGlobalRef(markerClass);
env->DeleteGlobalRef(polylineClass);
env->DeleteGlobalRef(polygonClass);
env->DeleteGlobalRef(runtimeExceptionClass);
env->DeleteGlobalRef(nullPointerExceptionClass);
env->DeleteGlobalRef(arrayListClass);
env->DeleteGlobalRef(projectedMetersClass);
env->DeleteGlobalRef(pointFClass);
env->DeleteGlobalRef(rectFClass);
env->DeleteGlobalRef(httpContextClass);
}
// Offline global definitions begin
offlineManagerClass = reinterpret_cast<jclass>(env->NewGlobalRef(offlineManagerClass));
@@ -3181,8 +3104,6 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
env->DeleteGlobalRef(projectedMetersClass);
env->DeleteGlobalRef(pointFClass);
env->DeleteGlobalRef(rectFClass);
env->DeleteGlobalRef(httpContextClass);
env->DeleteGlobalRef(httpRequestClass);
}
listOfflineRegionsCallbackClass = reinterpret_cast<jclass>(env->NewGlobalRef(listOfflineRegionsCallbackClass));
@@ -3200,8 +3121,6 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
env->DeleteGlobalRef(projectedMetersClass);
env->DeleteGlobalRef(pointFClass);
env->DeleteGlobalRef(rectFClass);
env->DeleteGlobalRef(httpContextClass);
env->DeleteGlobalRef(offlineManagerClass);
}
offlineRegionClass = reinterpret_cast<jclass>(env->NewGlobalRef(offlineRegionClass));
@@ -3219,8 +3138,6 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
env->DeleteGlobalRef(projectedMetersClass);
env->DeleteGlobalRef(pointFClass);
env->DeleteGlobalRef(rectFClass);
env->DeleteGlobalRef(httpContextClass);
env->DeleteGlobalRef(offlineManagerClass);
env->DeleteGlobalRef(listOfflineRegionsCallbackClass);
}
@@ -3239,7 +3156,6 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
env->DeleteGlobalRef(projectedMetersClass);
env->DeleteGlobalRef(pointFClass);
env->DeleteGlobalRef(rectFClass);
env->DeleteGlobalRef(httpContextClass);
env->DeleteGlobalRef(offlineManagerClass);
env->DeleteGlobalRef(listOfflineRegionsCallbackClass);
env->DeleteGlobalRef(offlineRegionClass);
@@ -3260,7 +3176,6 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
env->DeleteGlobalRef(projectedMetersClass);
env->DeleteGlobalRef(pointFClass);
env->DeleteGlobalRef(rectFClass);
env->DeleteGlobalRef(httpContextClass);
env->DeleteGlobalRef(offlineManagerClass);
env->DeleteGlobalRef(listOfflineRegionsCallbackClass);
env->DeleteGlobalRef(offlineRegionClass);
@@ -3282,7 +3197,6 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
env->DeleteGlobalRef(projectedMetersClass);
env->DeleteGlobalRef(pointFClass);
env->DeleteGlobalRef(rectFClass);
env->DeleteGlobalRef(httpContextClass);
env->DeleteGlobalRef(offlineManagerClass);
env->DeleteGlobalRef(listOfflineRegionsCallbackClass);
env->DeleteGlobalRef(offlineRegionClass);
@@ -3305,7 +3219,6 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
env->DeleteGlobalRef(projectedMetersClass);
env->DeleteGlobalRef(pointFClass);
env->DeleteGlobalRef(rectFClass);
env->DeleteGlobalRef(httpContextClass);
env->DeleteGlobalRef(offlineManagerClass);
env->DeleteGlobalRef(listOfflineRegionsCallbackClass);
env->DeleteGlobalRef(offlineRegionClass);
@@ -3329,7 +3242,6 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
env->DeleteGlobalRef(projectedMetersClass);
env->DeleteGlobalRef(pointFClass);
env->DeleteGlobalRef(rectFClass);
env->DeleteGlobalRef(httpContextClass);
env->DeleteGlobalRef(offlineManagerClass);
env->DeleteGlobalRef(listOfflineRegionsCallbackClass);
env->DeleteGlobalRef(offlineRegionClass);
@@ -3354,7 +3266,6 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
env->DeleteGlobalRef(projectedMetersClass);
env->DeleteGlobalRef(pointFClass);
env->DeleteGlobalRef(rectFClass);
env->DeleteGlobalRef(httpContextClass);
env->DeleteGlobalRef(offlineManagerClass);
env->DeleteGlobalRef(listOfflineRegionsCallbackClass);
env->DeleteGlobalRef(offlineRegionClass);
@@ -3380,7 +3291,6 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
env->DeleteGlobalRef(projectedMetersClass);
env->DeleteGlobalRef(pointFClass);
env->DeleteGlobalRef(rectFClass);
env->DeleteGlobalRef(httpContextClass);
env->DeleteGlobalRef(offlineManagerClass);
env->DeleteGlobalRef(listOfflineRegionsCallbackClass);
env->DeleteGlobalRef(offlineRegionClass);
@@ -3488,14 +3398,6 @@ extern "C" JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved) {
rectFRightId = nullptr;
rectFBottomId = nullptr;
env->DeleteGlobalRef(httpContextClass);
httpContextGetInstanceId = nullptr;
httpContextCreateRequestId = nullptr;
env->DeleteGlobalRef(httpRequestClass);
httpRequestStartId = nullptr;
httpRequestCancelId = nullptr;
// Offline delete begins
env->DeleteGlobalRef(offlineManagerClass);

View File

@@ -95,14 +95,6 @@ extern jfieldID rectFTopId;
extern jfieldID rectFRightId;
extern jfieldID rectFBottomId;
extern jclass httpContextClass;
extern jmethodID httpContextGetInstanceId;
extern jmethodID httpContextCreateRequestId;
extern jclass httpRequestClass;
extern jmethodID httpRequestStartId;
extern jmethodID httpRequestCancelId;
// Offline declarations start
extern jclass offlineManagerClass;