| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * This file is part of Adblock Plus <http://adblockplus.org/>, | 2  * This file is part of Adblock Plus <http://adblockplus.org/>, | 
| 3  * Copyright (C) 2006-2014 Eyeo GmbH | 3  * Copyright (C) 2006-2014 Eyeo GmbH | 
| 4  * | 4  * | 
| 5  * Adblock Plus is free software: you can redistribute it and/or modify | 5  * Adblock Plus is free software: you can redistribute it and/or modify | 
| 6  * it under the terms of the GNU General Public License version 3 as | 6  * it under the terms of the GNU General Public License version 3 as | 
| 7  * published by the Free Software Foundation. | 7  * published by the Free Software Foundation. | 
| 8  * | 8  * | 
| 9  * Adblock Plus is distributed in the hope that it will be useful, | 9  * Adblock Plus is distributed in the hope that it will be useful, | 
| 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
| 25   } | 25   } | 
| 26   CATCH_THROW_AND_RETURN(env, 0) | 26   CATCH_THROW_AND_RETURN(env, 0) | 
| 27 } | 27 } | 
| 28 | 28 | 
| 29 static void JNICALL JniDtor(JNIEnv* env, jclass clazz, jlong ptr) | 29 static void JNICALL JniDtor(JNIEnv* env, jclass clazz, jlong ptr) | 
| 30 { | 30 { | 
| 31   delete JniLongToTypePtr<AdblockPlus::WebRequestPtr>(ptr); | 31   delete JniLongToTypePtr<AdblockPlus::WebRequestPtr>(ptr); | 
| 32 } | 32 } | 
| 33 | 33 | 
| 34 JniWebRequest::JniWebRequest(JNIEnv* env, jobject callbackObject) | 34 JniWebRequest::JniWebRequest(JNIEnv* env, jobject callbackObject) | 
| 35   : JniCallbackBase(env, callbackObject), AdblockPlus::WebRequest() | 35   : JniCallbackBase(env, callbackObject), AdblockPlus::WebRequest(), | 
|  | 36     tupleClass(new JniGlobalReference<jclass>(env, env->FindClass(PKG("HeaderEnt
    ry")))), | 
|  | 37     serverResponseClass(new JniGlobalReference<jclass>(env, env->FindClass(PKG("
    ServerResponse")))) | 
| 36 { | 38 { | 
| 37   tupleClass.reset(new JniGlobalReference<jclass>(env, env->FindClass("com/githu
    b/rjeschke/neetutils/collections/Tuple"))); |  | 
| 38   serverResponseClass.reset(new JniGlobalReference<jclass>(env, env->FindClass(P
    KG("ServerResponse")))); |  | 
| 39 } | 39 } | 
| 40 | 40 | 
| 41 AdblockPlus::ServerResponse JniWebRequest::GET(const std::string& url, const Adb
    lockPlus::HeaderList& requestHeaders) const | 41 AdblockPlus::ServerResponse JniWebRequest::GET(const std::string& url, const Adb
    lockPlus::HeaderList& requestHeaders) const | 
| 42 { | 42 { | 
| 43   JNIEnvAcquire env(GetJavaVM()); | 43   JNIEnvAcquire env(GetJavaVM()); | 
| 44 | 44 | 
| 45   jclass clazz = env->GetObjectClass(GetCallbackObject()); | 45   jclass clazz = env->GetObjectClass(GetCallbackObject()); | 
| 46   jmethodID method = env->GetMethodID(clazz, "httpGET", "(Ljava/lang/String;Ljav
    a/util/List;)" TYP("ServerResponse")); | 46   jmethodID method = env->GetMethodID(clazz, "httpGET", "(Ljava/lang/String;Ljav
    a/util/List;)" TYP("ServerResponse")); | 
| 47 | 47 | 
| 48   AdblockPlus::ServerResponse sResponse; | 48   AdblockPlus::ServerResponse sResponse; | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 68     } | 68     } | 
| 69   } | 69   } | 
| 70 | 70 | 
| 71   CheckAndLogJavaException(*env); | 71   CheckAndLogJavaException(*env); | 
| 72 | 72 | 
| 73   return sResponse; | 73   return sResponse; | 
| 74 } | 74 } | 
| 75 | 75 | 
| 76 jobject JniWebRequest::NewTuple(JNIEnv* env, const std::string& a, const std::st
    ring& b) const | 76 jobject JniWebRequest::NewTuple(JNIEnv* env, const std::string& a, const std::st
    ring& b) const | 
| 77 { | 77 { | 
| 78   jmethodID factory = env->GetMethodID(tupleClass->Get(), "<init>", "(Ljava/lang
    /Object;Ljava/lang/Object;)V"); | 78   jmethodID factory = env->GetMethodID(tupleClass->Get(), "<init>", "(Ljava/lang
    /String;Ljava/lang/String;)V"); | 
| 79   return env->NewObject(tupleClass->Get(), factory, env->NewStringUTF(a.c_str())
    , env->NewStringUTF(b.c_str())); | 79   return env->NewObject(tupleClass->Get(), factory, env->NewStringUTF(a.c_str())
    , env->NewStringUTF(b.c_str())); | 
| 80 } | 80 } | 
| 81 | 81 | 
| 82 static JNINativeMethod methods[] = | 82 static JNINativeMethod methods[] = | 
| 83 { | 83 { | 
| 84   { (char*)"ctor", (char*)"(Ljava/lang/Object;)J", (void*)JniCtor }, | 84   { (char*)"ctor", (char*)"(Ljava/lang/Object;)J", (void*)JniCtor }, | 
| 85   { (char*)"dtor", (char*)"(J)V", (void*)JniDtor } | 85   { (char*)"dtor", (char*)"(J)V", (void*)JniDtor } | 
| 86 }; | 86 }; | 
| 87 | 87 | 
| 88 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_WebRequest
    _registerNatives(JNIEnv *env, jclass clazz) | 88 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_WebRequest
    _registerNatives(JNIEnv *env, jclass clazz) | 
| 89 { | 89 { | 
| 90   env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); | 90   env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); | 
| 91 } | 91 } | 
| OLD | NEW | 
|---|