Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: libadblockplus-android/jni/JniJsValue.cpp

Issue 29345737: Issue 4146 - Fix failing UpdateCheckTest.testApplicationUpdateAvailable test in libadblockplus-andr… (Closed)
Left Patch Set: moved entry points to JniLibrary.cpp Created Sept. 14, 2016, 7:38 a.m.
Right Patch Set: using jni version define from Utils.h Created Sept. 16, 2016, 6:30 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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
25 25
26 void JniJsValue_OnLoad(JavaVM* vm, JNIEnv* env, void* reserved) 26 void JniJsValue_OnLoad(JavaVM* vm, JNIEnv* env, void* reserved)
27 { 27 {
28 // precache for performance and avoid attaching threads 28 // precache for performance and avoid attaching threads
29 jclass localJsValueClass = env->FindClass(PKG("JsValue")); 29 jclass localJsValueClass = env->FindClass(PKG("JsValue"));
30 globalJsValueClass = (jclass)env->NewGlobalRef(localJsValueClass); 30 globalJsValueClass = (jclass)env->NewGlobalRef(localJsValueClass);
31 jsValueClassCtor = env->GetMethodID(globalJsValueClass, "<init>", "(J)V"); 31 jsValueClassCtor = env->GetMethodID(globalJsValueClass, "<init>", "(J)V");
32 env->DeleteLocalRef(localJsValueClass); 32 env->DeleteLocalRef(localJsValueClass);
33 } 33 }
34 34
35 void JniJsValue_OnUnload(JavaVM* vm, JNIEnv* env, void* reserved)
36 {
37 if (globalJsValueClass)
38 {
39 env->DeleteGlobalRef(globalJsValueClass);
40 }
41 }
42
35 static jboolean JNICALL JniIsUndefined(JNIEnv* env, jclass clazz, jlong ptr) 43 static jboolean JNICALL JniIsUndefined(JNIEnv* env, jclass clazz, jlong ptr)
36 { 44 {
37 try 45 try
38 { 46 {
39 return JniGetJsValue(ptr)->IsUndefined() ? JNI_TRUE : JNI_FALSE; 47 return JniGetJsValue(ptr)->IsUndefined() ? JNI_TRUE : JNI_FALSE;
40 } 48 }
41 CATCH_THROW_AND_RETURN(env, JNI_FALSE) 49 CATCH_THROW_AND_RETURN(env, JNI_FALSE)
42 } 50 }
43 51
44 static jboolean JNICALL JniIsNull(JNIEnv* env, jclass clazz, jlong ptr) 52 static jboolean JNICALL JniIsNull(JNIEnv* env, jclass clazz, jlong ptr)
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 { (char*)"asBoolean", (char*)"(J)Z", (void*)JniAsBoolean }, 224 { (char*)"asBoolean", (char*)"(J)Z", (void*)JniAsBoolean },
217 { (char*)"asList", (char*)"(J)Ljava/util/List;", (void*)JniAsList }, 225 { (char*)"asList", (char*)"(J)Ljava/util/List;", (void*)JniAsList },
218 { (char*)"getProperty", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*) JniGetProperty }, 226 { (char*)"getProperty", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*) JniGetProperty },
219 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor } 227 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor }
220 }; 228 };
221 229
222 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_JsValue_re gisterNatives(JNIEnv *env, jclass clazz) 230 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_JsValue_re gisterNatives(JNIEnv *env, jclass clazz)
223 { 231 {
224 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); 232 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0]));
225 } 233 }
226
227 void JniJsValue_OnUnload(JavaVM *vm, JNIEnv *env, void *reserved)
Felix Dahlke 2016/09/15 13:01:19 Nit: Asterisk should be next to the type according
anton 2016/09/15 13:18:11 Acknowledged.
228 {
229 if (globalJsValueClass)
230 {
231 env->DeleteGlobalRef(globalJsValueClass);
232 }
233 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld