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

Unified Diff: jni/JniFilterChangeCallback.cpp

Issue 4761138508070912: Issue 1848 - Clean up local reference handling (Closed)
Patch Set: Created Jan. 22, 2015, 6:53 p.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 | « jni/JniFilter.cpp ('k') | jni/JniFilterEngine.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: jni/JniFilterChangeCallback.cpp
diff --git a/jni/JniFilterChangeCallback.cpp b/jni/JniFilterChangeCallback.cpp
index a1b19011470495265b67a71fd75ff8ccf4d5e38f..3fe26c87cf03d00350912d51e85d316a021dca01 100644
--- a/jni/JniFilterChangeCallback.cpp
+++ b/jni/JniFilterChangeCallback.cpp
@@ -40,14 +40,15 @@ void JniFilterChangeCallback::Callback(const std::string& arg, const AdblockPlus
{
JNIEnvAcquire env(GetJavaVM());
- jclass clazz = env->GetObjectClass(GetCallbackObject());
- jmethodID method = env->GetMethodID(clazz, "filterChangeCallback", "(Ljava/lang/String;" TYP("JsValue") ")V");
+ jmethodID method = env->GetMethodID(
+ *JniLocalReference<jclass>(*env, env->GetObjectClass(GetCallbackObject())),
+ "filterChangeCallback", "(Ljava/lang/String;" TYP("JsValue") ")V");
if (method)
{
- jstring jArg = env->NewStringUTF(arg.c_str());
- jobject jJsValue = NewJniJsValue(*env, jsValue, jsValueClass->Get());
- env->CallVoidMethod(GetCallbackObject(), method, jArg, jJsValue);
+ JniLocalReference<jstring> jArg(*env, env->NewStringUTF(arg.c_str()));
+ JniLocalReference<jobject> jJsValue(*env, NewJniJsValue(*env, jsValue, jsValueClass->Get()));
+ env->CallVoidMethod(GetCallbackObject(), method, *jArg, *jJsValue);
}
CheckAndLogJavaException(*env);
« no previous file with comments | « jni/JniFilter.cpp ('k') | jni/JniFilterEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld