Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 { | 48 { |
49 try | 49 try |
50 { | 50 { |
51 return JniPtrToLong(new AdblockPlus::WebRequestSharedPtr(std::make_shared<Jn iWebRequest>(env, callbackObject))); | 51 return JniPtrToLong(new AdblockPlus::WebRequestSharedPtr(std::make_shared<Jn iWebRequest>(env, callbackObject))); |
52 } | 52 } |
53 CATCH_THROW_AND_RETURN(env, 0) | 53 CATCH_THROW_AND_RETURN(env, 0) |
54 } | 54 } |
55 | 55 |
56 static void JNICALL JniDtor(JNIEnv* env, jclass clazz, jlong ptr) | 56 static void JNICALL JniDtor(JNIEnv* env, jclass clazz, jlong ptr) |
57 { | 57 { |
58 delete JniLongToTypePtr<AdblockPlus::WebRequestPtr>(ptr); | 58 delete JniLongToTypePtr<AdblockPlus::WebRequestSharedPtr>(ptr); |
anton
2017/06/02 06:55:23
don't we have to cast it to WebRequestSharedPtr? (
sergei
2017/06/02 07:32:43
Good catch.
| |
59 } | 59 } |
60 | 60 |
61 JniWebRequest::JniWebRequest(JNIEnv* env, jobject callbackObject) | 61 JniWebRequest::JniWebRequest(JNIEnv* env, jobject callbackObject) |
62 : JniCallbackBase(env, callbackObject), AdblockPlus::WebRequest() | 62 : JniCallbackBase(env, callbackObject), AdblockPlus::WebRequest() |
63 { | 63 { |
64 } | 64 } |
65 | 65 |
66 AdblockPlus::ServerResponse JniWebRequest::GET(const std::string& url, | 66 AdblockPlus::ServerResponse JniWebRequest::GET(const std::string& url, |
67 const AdblockPlus::HeaderList& requestHeaders) const | 67 const AdblockPlus::HeaderList& requestHeaders) const |
68 { | 68 { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 static JNINativeMethod methods[] = | 151 static JNINativeMethod methods[] = |
152 { | 152 { |
153 { (char*)"ctor", (char*)"(Ljava/lang/Object;)J", (void*)JniCtor }, | 153 { (char*)"ctor", (char*)"(Ljava/lang/Object;)J", (void*)JniCtor }, |
154 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor } | 154 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor } |
155 }; | 155 }; |
156 | 156 |
157 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_WebRequest _registerNatives(JNIEnv *env, jclass clazz) | 157 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_WebRequest _registerNatives(JNIEnv *env, jclass clazz) |
158 { | 158 { |
159 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); | 159 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); |
160 } | 160 } |
LEFT | RIGHT |