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: Stupid auto-formatter^^ Created Feb. 4, 2015, 12:04 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..00c4b945f4976c2d3c89e1d5167145a8615517b9 100644
--- a/jni/JniFilterChangeCallback.cpp
+++ b/jni/JniFilterChangeCallback.cpp
@@ -31,23 +31,29 @@ static void JNICALL JniDtor(JNIEnv* env, jclass clazz, jlong ptr)
delete JniLongToTypePtr<JniFilterChangeCallback>(ptr);
}
-JniFilterChangeCallback::JniFilterChangeCallback(JNIEnv* env, jobject callbackObject)
- : JniCallbackBase(env, callbackObject), jsValueClass(new JniGlobalReference<jclass>(env, env->FindClass(PKG("JsValue"))))
+JniFilterChangeCallback::JniFilterChangeCallback(JNIEnv* env,
+ jobject callbackObject)
+ : JniCallbackBase(env, callbackObject), jsValueClass(
+ new JniGlobalReference<jclass>(env, env->FindClass(PKG("JsValue"))))
{
}
-void JniFilterChangeCallback::Callback(const std::string& arg, const AdblockPlus::JsValuePtr jsValue)
+void JniFilterChangeCallback::Callback(const std::string& arg,
+ const AdblockPlus::JsValuePtr jsValue)
{
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