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

Unified Diff: libadblockplus-android/jni/JniLogSystem.cpp

Issue 29354787: Issue 4442 - Cache class and ctors references in JNI_Load/UnLoad (Closed)
Patch Set: reverted to NewTuple Created Nov. 21, 2016, 8:25 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « libadblockplus-android/jni/JniLogSystem.h ('k') | libadblockplus-android/jni/JniNotification.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: libadblockplus-android/jni/JniLogSystem.cpp
diff --git a/libadblockplus-android/jni/JniLogSystem.cpp b/libadblockplus-android/jni/JniLogSystem.cpp
index 002775cded976091063e50842dbf5101e6963039..d537a685bdc7dd7dc7fb10d64efcbed65aa3a5df 100644
--- a/libadblockplus-android/jni/JniLogSystem.cpp
+++ b/libadblockplus-android/jni/JniLogSystem.cpp
@@ -16,6 +16,24 @@
*/
#include "JniCallbacks.h"
+#include "JniLogSystem.h"
+
+// precached in JNI_OnLoad and released in JNI_OnUnload
+JniGlobalReference<jclass>* logLevelClass;
+
+void JniLogSystem_OnLoad(JavaVM* vm, JNIEnv* env, void* reserved)
+{
+ logLevelClass = new JniGlobalReference<jclass>(env, env->FindClass(PKG("LogSystem$LogLevel")));
+}
+
+void JniLogSystem_OnUnload(JavaVM* vm, JNIEnv* env, void* reserved)
+{
+ if (logLevelClass)
+ {
+ delete logLevelClass;
+ logLevelClass = NULL;
+ }
+}
static jlong JNICALL JniCtor(JNIEnv* env, jclass clazz, jobject callbackObject)
{
@@ -32,7 +50,7 @@ static void JNICALL JniDtor(JNIEnv* env, jclass clazz, jlong ptr)
}
JniLogSystemCallback::JniLogSystemCallback(JNIEnv* env, jobject callbackObject)
- : JniCallbackBase(env, callbackObject), AdblockPlus::LogSystem(), logLevelClass(new JniGlobalReference<jclass>(env, env->FindClass(PKG("LogSystem$LogLevel"))))
+ : JniCallbackBase(env, callbackObject), AdblockPlus::LogSystem()
{
}
« no previous file with comments | « libadblockplus-android/jni/JniLogSystem.h ('k') | libadblockplus-android/jni/JniNotification.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld